Professional Documents
Culture Documents
Introduction :
RFID stands for Radio Frequency Identification. RFID module can read or write small amount of
data into a Passive RFID tag, which can be used in identification process in various systems
like Attendance system, security system, voting system etc. RFID is very convenient and easy
technology.
To read the Passive RFID cards and tag, we need a microcontroller with UART hardware. If we
select a microcontroller without UART, we need to implement software UART. Here we are using
PIC Microcontroller PIC16F877A for interfacing RFID. We will simply read the unique
identification no. of RFID tags and display it on 16x2 LCD
Components Required :
1. PIC16F877A
2. 20Mhz Crystal
3. 2pcs 33pF ceramic disc capacitor
4. 16x2 Character LCD
5. A breadboard
6. 10k preset pot
7. 4.7k resistor
8. Single strand wires to connect
9. A 5V adapter
10. RF Module EM-18
11. 5V Buzzer
12. 100uF & .1uF 12V capacitor
13. BC557 Transistor
14. LED
15. 2.2k and 470R resistor
There are three types of RFID tags available, Passive, Active or Battery-assisted passive. Different
kind of RFID tags with a different kind of shapes and sizes are available in the market. Few of
them use different frequency for communication purpose. We will use 125Khz Passive RFID cards
which holds the unique ID data. Here are the RFID card and tags we are using for this project.
Working of RFID :
One thing needs to be kept in mind that the output of EM-18 reader uses 5V logic level. We could
use another microcontroller which uses a lower logic level, but in such cases, the additional logic
level converter is required. In few cases, the UART pin of the 3.3V microcontroller is often 5V
tolerant.
The UART output provides 12-bit ASCII data. First 10 bits are RFID tag number, which is the
unique ID and last two digits are used for error testing. Those last two digits are the XOR of the
tag number. EM-18 module will read the data from 125 KHz Passive RFID tags or cards.
Those tags or IDs have a factory programmed memory array which stores the unique ID number.
As those are passive, so no battery is present in the card or tags, they get energized by the magnetic
field of the RF Transceiver module. These RFID tags are made using the EM4102 CMOS
IC which is clocked by the magnetic field too.
Circuit Diagram :
Code :
#define _XTAL_FREQ 8000000
#define RS RB2
#define EN RB3
#define D4 RB4
#define D5 RB5
#define D6 RB6
#define D7 RB7
#include <xc.h>
#include "lcd.h";
#include "uart.h";
#include <pic16f877a.h>
// BEGIN CONFIG
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data
EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write
protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code
protection off)
//END CONFIG
void main()
char i,rfid[13];
Lcd_Set_Cursor(1,1);
if(UART_Data_Ready())
for(i=0;i<12;)
if(UART_Data_Ready())
rfid[i] = UART_Read();
i++;
Lcd_Set_Cursor(2,1);
Lcd_Write_String(rfid);
}
else
Lcd_Set_Cursor(1,1);
Lcd_Write_String("Error ");