Reading RFID tags

From Mech
Jump to navigationJump to search

Original Assignment

Interface your PIC with an RFID reader (see here) and demonstrate recognition of various RFID tags.


Overview

Radio Frequency Identification (RFID) is a generic term used to describe technology that uses radio waves to identify objects via transponder tags. The tags emit a radio frequency that translates to a unique serial code which corresponds with its identification which is read by an RFID reader. Active RFID transponders contain their own battery supply which allows a constant signal, but they are bulky(battery) and expensive, therefore they are usually restricted to larger objects such as crates for shipping supplies. With passive RFID transponders, the RFID reader emits a radio frequency which causes a coiled antenna in the RFID transponder tag to generate a magnetic field which powers the RFID transponder. This generated power allows the RFID transponder tag to emit its specific radio frequency to the reader which it uses to identify the tag.

The mechatronics lab uses the Parallax RFID Card Reader, Serial (#28140) and kit [1]. The reader reads passive RFID transponder tags up to 4 inches away from the reader. The RFID communicates using rs232 and transmits a 12-byte ASCII string. The first byte (start byte) is always $0A and the last byte (stop byte) is always $0D. The 10 middle digits are the 10 unique id digits that are unique to every RFID transponder. The r

Circuit

Rfid diag.jpg
RFID SOUT to PIC RC7
RFID VCC to PIC +5 
RFID GND to PIC GND
RFID /ENAMBLE to PIC RC7
PIC RC6 to TTL-232R Yellow Wire (note: this is output signal to view on PC)
PIC GND to TTL-232R Black Wire (note: this is connecting the grounds together)

TTL-232R

Code

The following code reads in the RFID tag from the RFID Card Reader and then writes it out to a ps232 connection. In our tests we used a TTL-232R with a baud of 2400. This allows you to view the RFID unique ID on the computer.

/*
   RFID_Input.c J.Cooper and C.Ryan 2009-2-04
   Read in from RFID Card on pin RC7
   Write out RFID unique number on pin RC6
*/
#include <18f4520.h>
#fuses HS,NOLVP,NOWDT,NOPROTECT        
#use delay(clock=40000000)         // 40 MHz crystal on PCB
#use rs232(baud=2400, UART1)      // hardware UART; uses  RC6/TX and RC7/RX

int16 i;
char value[12];//12 values of tag ID

void main() {
     output_low(PIN_D7); //Set enable to low

     for (i=0; i<12; i++) { //read in the 12 values
           value[i]=getc();
     }
     printf("rfid# %c %c %c %c %c %c %c %c %c %c \r\n", value[1] value[2] value[3] value[4] value[5] value[6] value[7] value[8] value[9] value[10]); //display 10 unique id digits
}

Further Reading

Product Website

Data Sheet