Monday, March 3, 2014

Creating a RFID Reader From Scratch Part 1

For a couple of years now, each fall, I've been attending the ritual of collecting sheep from their  summer pastures in the mountains to get them back to their farm and owners for the winter. The way this works is that people are walking around in the mountain looking for sheep, and when finding them they are herded back to a central collection place. I've been part of the group that stays at the collection place and sort the animals to the correct owner. Currently there are about seven farmers collecting sheep to the same place, and about 1000 - 1400 sheep that is collected, weighted and sorted in the course of two days.

A couple of years ago it became mandatory in Norway to mark each sheep with an electronic ear tag (RFID) that identifies the animal with country, farm and animal number. Being an engineer I came to the conclusion that it must be possible to either get a reader or make a reader for this ear tag myself. This could then speed up the weighing and sorting process by reading the owner of the animal by radio signals instead of manually reading the owner of every sheep. So I started looking around on the internet for an affordable commercial RFID reader, which it is heaps and loads of, but most of them are for 125 kHz or 13.56 MHz, only a few for the 134.2 kHz required to read the animal tags and with a hefty price tag. So I decided to use my RF degree from university and try to implement my own reader.

In the first iteration of the project I started looking for RFID reader modules/IC's, e.g. something like this one from Sparkfun, but for the animal RFID frequency. After looking around and not finding modules that seemed to be a good fit, at least easy to use and implement I decided to have a go at creating a reader from scratch, and really put my RF background to the test.

The principle of a RFID reader is quite simple, you have to generate a radio signal at the correct RF frequency, expose the RFID tag, and then the tag will use the received signal to power itself and generate a radio signal on the same frequency and transmit this back to the reader. A figure for such a system is shown below:


The main challenge in this system is the same as for most radio systems, the receiving signal is very weak. But in a RFID reader system you have an additional factor which you normally try to keep as far away from your "normal" receiver as possible, and that is a strong transmitter in close proximity interfering with the message you are trying to read. This means that constructing the transmitter part (the left part of the figure above) needs careful considerations, but also the receiver needs careful construction to be able to cope with the transmitting signal which is millions of times stronger than the received signal, and yet be capable of decoding the signal.

So the challenge was clear... or was it: build a RFID reader for the 134.2 kHz with an unknown, modulation and data encoding scheme. What I did then was to start looking around the internet for similar projects, I found non on animal RFID, and only a few projects for "normal" RFID, but then I stumbled across this one: https://instruct1.cit.cornell.edu/Courses/ee476/FinalProjects/s2006/cjr37/Website/index.htm, which is a school project where they have implemented a RFID door look system from scratch, and more importantly with discreet components. This meant that the circuit could be tuned to fit my project. However given that the RF modulation would be the same or similar for my animal RFID tags. But it turns out that this project had a very interesting reference: Microchip has posted an application note on RFID readers from discreet components: http://ww1.microchip.com/downloads/en/DeviceDoc/51115F.pdf. And suddenly there was a hope for my project after all.

The next hurdle was to find some more information on the exact implementation of the ear tag itself, and it turns out that there is an ISO standard that defines the animal RFID: ISO11784 and ISO11785 (http://en.wikipedia.org/wiki/ISO_11784_%26_11785). The standard operates with two (or three) different protocols one is the full duplex (FDX & FDX-B) and the other half duplex (HDX). The difference is that on the FDX protocol the RFID tag sends data at the same time as the transmitter sends its RF energy to power the internal logic of the tag, the HDX type you burst the tag with power for a given time and then you turn off the transmitter and wait for a reply. There are pros and cons with both protocols, that I will not cover in details in this article, but the most obvious once are that in the HDX system the readers receiver can be simpler because the readers transmitter is off and will not interfere with the signal of the message from the tag, while in the FDX system the transmitter must remain on while the entire communication is flowing, making it difficult for the reader receiver to "hear" the information coming from the RFID tag. But for the FDX system the tag itself is simpler, in the HDX tag you would need a capacitor to store the energy needed to transmit the signal back to the reader, and capacitors takes up space and are expensive. The easiest comparison that I can think of is that you can picture that you need to shout a given amount of sound to your friend for him or she can be able to reply. In the HDX system you will be shouting to your friend for a certain amount of time, before you shut up and your friend is able to whisper his or hers message back to you. In the FDX system you would need to shout the entire time while your friend is trying to whisper his or hers message back to you, obviously making the communication very difficult.

Now I at least had a few clues to go after, so I  began some initial testing. I had a few of the ear tags to test on so I started to expose them with RF energy using a simple signal generator and a coiled up insulated copper wire to act as an antenna. In the other end of the coil i put a resistor to ground and an oscilloscope across the resistor. This allowed me to clearly see the 134.2 kHz sine wave plus a bunch of noise. Moving the ear tag closer and further from the "antenna" (insulated copper wire coil) I saw a distinct change is the noise pattern, so I started searching for the HDX "signatures", i.e. 124.2 kHz and 134.2 kHz after turning off the "transmitter", I was kind of hoping that it was a HDX system and not a FDX system having the idea that the HDX would be easier to implement when I came to that point. But I saw no signs of any RF activity after turning off the transmitter, only when the transmitter was on, and in the area of the FDX tags. So I started working on the hypothesis that the system was either FDX or FDX-B with ASK (amplitude shift keying) and DBP differential bi-phase keying (more on this in later parts of the RFID series).

I started working on implementing the ASK reader described in chapter 4 in the Microchip PDF. With discreet components on a prototype PCB. In the next part in this series of articles on the RFID design I will show what modifications needed to be done on both the transmitter part and the receiver part to make it work with a different frequency. Thank you for reading so far, and keep tuned for the next parts in the series, where I will look in detail on the actual implementation and suggest a complete solution using SMD components and my reflow oven (will make another post on the reflow oven) to produce the result below:


4 comments:

  1. You know, Atmel sells 134.2KHz tags, and still sells a kit that uses a third party single chip reader. You might want to check out: http://www.atmel.com/images/atmel-9321-ata2270-ek2_application-note.pdf. They used to sell a 134.2KHz reader, the U2270, but since the Heilbron factory closure they stopped making it. Using anything Microchip is blasphemy.

    ReplyDelete
  2. Hello Dear,It was a beneficial workout for me to go through your webpage.

    ReplyDelete
    Replies
    1. Thank you, I will hopefully be able to add part 2 of this series as soon as possible.

      Delete
  3. This is truly a beneficial guide on creating RFID readers. Thanks for sharing such information.

    ReplyDelete