RFID Interfacing with 8051 Microcontroller

Radio Frequency Identification (RFID) is a system that uses radio waves to identify an object, person wirelessly. A typical RFID system consists of:

Basically, RFID operation is simple. Firstly, antenna of the RFID reader will be emitting radio signals which will activate the RFID tag or transponder. An RFID tag is programmed with information. When the RFID tag comes within the zone of radio waves emitted from the RFID reader, the tag gets activated. RFID reader will decode the data in the tag and is passed to the PC for further processing.

                                                     RFID Reader  

                                                                                                                        RFID Reader                                                                                                                                     

Data transmitted from the tag can be product, location or any other information. The main popularity of the RFID system was that it has the ability to track moving objects. RFID tag consists of a chip with an antenna. The chip helps to store 2Kb of data. Also RFID tags can work on different frequencies. When the tag comes in reach with the RFID reader, the reader will detect the tag and sends a unique code of data present in the tag serially.

                                       RFID Card

                                                                                              RFID Card

Is RFID smarter Than Barcodes?

Barcodes attached to objects is a representation of data that is machine readable. They represent the data with the help of parallel lines with definite width and spacing’s. Today, RFID are considered to be smarter than barcodes due to the following reasons as given in the table.

Features

RFID

Barcodes

Read rate

High

Low

Security

High

Low

Durability

High

Low

Line of Sight

Not required

Required

Event triggering

Yes

No

Read, write capability

Can read, write, modify, update

Only read

How to interface RFID with Microcontroller?

Inorder to perform RFID interfacing, the major components to be used are:

Hardware Components

  1. 8051 microcontroller
  2. RFID reader
  3. RFID Tag
  4. MAX232 IC
  5. LCD

8051 Microcontroller

Atmel AT89s51/52 is an 8-bit microcontroller. The main specifications of the controller are:

  • 128X8 bit Internal RAM
  • Can be erased and programmed many number of times.
  • It has 4 ports like P0, P1, P2, and P3.
  • Interrupt Source
  • 4Kbytes of Flash Memory.
  • Watchdog timer.

MAX232 IC

RFID module cannot be connected directly with the 8051 microcontroller. For this purpose, MAX232 IC is used here. MAX232 can convert TTL/CMOS logic levels to RS232 logic levels for serial communication with the PC. Actually, the microcontroller used here operates at TTL logic. But serial communication with the PC works on RS232 standards.  The link between the controller and the PC takes MAX232 IC.

LCD

Liquid crystal display being a flat panel display is used to display electronic information like images, text etc.

LCD command codes

                                       LCD Command Codes                                                                              

Software Components

  1. Programming in Embedded C
  2. Using Keil C compiler
  3. Programmer

KEIL Software

KEIL microvision software is one of the platform used to write embedded C program.

You can download the KEIL Microvision software from  https://www.keil.com/download/product/.

Programmer

8051 programmer is one of the reliable tools for fast programming of 8051 microcontroller. 

Program for RFID Interfacing with 8051 Microcontroller

#include<reg52.h>

sfr ldata=0x80;

sbit rs=P1^2;

sbit rw=P1^1;

sbit en= P1^0;

void lcdcmd (unsigned char value);

void lcddata(unsigned char value);

void msdelay(unsigned int t);

void receive(unsigned char d);

unsigned char cardid[12];

void main()

{

    int l;

    TMOD=0x20;           

    TH1=0XFD;

    SCON=0x40;

    TR1=1; 

    lcdcmd(0x38);

    msdelay(250);

    lcdcmd(0x0c);

    msdelay(250);

    lcdcmd(0x01);

    msdelay(250);

    lcdcmd(0x06);

    msdelay(250);

    lcdcmd(0x80);

    msdelay(250);

    while(1)

    {

         receive();

         lcdcmd(0xC1);       

         for(l=0;l<12;l++)

         {

              lcddata(cardid[l]);

          }

      }

}

void lcdcmd (unsigned char value)

{

ldata=value;

rs=0;

rw=0;

en=1;

msdelay(1);

en=0;

return;

}

void lcddata(unsigned char value)

{

ldata=value;

rs=1;

rw=0;

en=1;

msdelay(1);

en=0;

return;

}

void msdelay(unsigned int t)

{

unsigned int i,j;

for(i=0;i<t;i++)

for(j=0;j<1275;j++);

}

void receive(unsigned char d)

{

     unsigned char d;

     for(d=0;d<12;d++)

     {

         while(RI==0);

         cardid[d]=SBUF;

         RI=0;

    }


}


Note: To know related to Smart cards, just go through the link

Related Items