Sie sind auf Seite 1von 3

The RFID module used here gives a 12 byte unique ID of a particular tag in serial RS232 logic level

format. Hence a level converter MAX232 is used in between RFID receiver module and microcontroller.
The connections of RFID module and ATmega16 are shown in thecircuit diagram. The ground pin of
MAX232 and serial output of RFID module is made common. A cross cable connection is set up between
the RFID module and the MAX232 by connecting transmitter pin of one to the receiver pin of the other
and vice versa as shown in the circuit diagram.
Note: In case the output of the RFID module is in TTL format, there is no need of MAX232. In such a case
the output of the RFID module can be directly given to the microcontroller.
Pin 2 of max 232
Pin 3 of max 232
Pin 5 ground pin of max 232

Pin 3 of RFID modem


Pin 2 of RFID modem
Pin 5 ground of RFID modem

Code description
In order to understand the code for RFID (given below) which is interfaced with ATmega16, one must
have a basic knowledge of serial communication and LCD. The serial data from RFID module can be
taken by microcontroller either by polling or by using serial interrupt concepts. (To understand the
difference between them, refer to tutorial on Interrupts) This article explores the interfacing of RFID
module with AVR microcontroller (ATmega16) using the polling technique. The code described here
keeps monitoring the serial input till it receives all the twelve bytes from the RFID module.
Receiving 12 byte serial interrupt data by polling method:
Steps to receive twelve byte serial data
i.

Initialize USART in read mode.

ii.

Get a 12 byte string (RFID card no.)

void getcard_id(void) // Function to get 12 byte ID no. from rfid card


{
for(i=0;i<12;i++)
{
card[i]= usart_getch(); // receive card value byte by byte
}
return;
}
iii.

Display that 12 byte data on LCD.

void LCD_display(void) // Function for displaying ID no. on LCD


{
for(i=0;i<12;i++)
{

LCD_write(card[i]); // display card value byte by byte


}
return;
}
Also see RFID interfacing with AVR using interrupts.

Das könnte Ihnen auch gefallen