Beruflich Dokumente
Kultur Dokumente
(/)
We know in ofces, shopping malls and in many other places where only the person with authorization
card is allowed to enter the room. These systems use RFID communication system. RFID is used in
shopping malls to stoptheft as the products aretagged with RFID chip and when a person leaves the
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 1/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
building with the RFID chip an alarm is raised automatically. The RFID tag is designed as small as part
of sand. The RFID authentication systems are easy to design and are cheap in cost. Some schools and
colleges nowadays use RFID based attendance systems.
Adsby Google
RFIDSystems
RFIDCardReader
In this project we are going to design a RFID based toll plaza system for security purposes. So this
system open gates and allow people only with the authorized RFID tags. The authorized tags holder
IDs are programmed in to the ATMEGAMicrocontroller and only those holders are allowed to leave or
enter the premises.
Components Required
Hardware: ATmega32 microcontroller, power supply (5v), AVR-ISP Programmer, JHD_162ALCD (16x2
LCD module), 100uF capacitor (connected across power supply), button, 10K resistor, 100nF
capacitor, LED (two pieces), EM-18 (RFID reader module), L293D motor driver IC, 5V DC motor.
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 2/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
Adsby Google
RFIDNFC
AttendanceSystem
(/fullimage?i=circuitdiagram_mic/RFID-Toll-Plaza-Circuit-2.gif)
PCB/PCBAFabrication
HiTechManufacturerChina,LowCostOne
Stop,Precision,Quick,OrderNow!
In the toll plaza circuit shown above, PORTA of ATMEGA32 is connected to data port of LCD. Here we
should remember to disable the JTAG communication in PORTC to ATMEGA by changing the fuse
bytes, if we wans to use the PORTC as a normal communication port. In 16x2 LCD, there are 16 pins
over all if there is a back light, if there is no back light there will be 14 pins. We can power or leave the
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 3/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
back light pins. Now in the 14 pins there are 8 data pins (7-14 or D0-D7), 2 power supply pins (1&2 or
VSS & VDD or gnd & +5v), 3rd pin for contrast control (VEE-controls how thick the characters should be
shown), 3 control pins (RS & RW & E).
PCB/PCBA
Fabrication
HiTechManufacturerChina,LowCost
OneStop,Precision,Quick,OrderNow!
In the circuit, you can observe that I have only took two control pins. This gives the exibility of better
understanding. The contrast bit and READ/WRITE are not often used so they can be shorted to ground.
This puts LCD in highest contrast and read mode. We just need to control ENABLE and RS pins to send
characters and data accordingly.
The connections which are made for LCD, are given below:
PIN5 or RW (Read/Write) to ground (puts LCD in read mode eases the communication for user)
PIN7 or D0 to PA0
PIN8 or D1 to PA1
PIN9 or D2 toPA2
PIN10 or D3 to PA3
PIN11 or D4 to PA4
PIN12 or D5 to PA5
PIN13 or D6 to PA6
PIN14 or D7 to PA7
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 4/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
In the circuit, you can see we have used 8bit communication (D0-D7). However this is not a compulsory
and we can use 4bit communication (D4-D7) but with 4 bit communication program becomes a bit
complex, so I preferred8 bit communication.
So from mere observation ofabove table we are connecting 10 pins of LCD to controller in which 8 pins
are data pins and 2 pins for control.
Before moving ahead, we need to understand about the serial communication. The RFID module here
sends data to the controller in serial. It has other mode of communication but for easy communication
we are choosing RS232. The RS232 pin of module is connected to RXD pin of ATMEGA.
Now for the RFID module interface, the following features are required:
2. Since the communication is serial we need to know whenever the data bye is received, so that we
can stop the program until complete byte is received. This is done by enabling a data receive complete
interrupt.
3. RFID sends data to controller in 8bit mode. So two characters will be sent to the controller at a time.
This is shown in above gure.
4. From above gure, there are no parity bits, one stop bit in the data sent by the module.
The above features are set in the controller registers; we are going to discuss them briey,
RED (RXEN): This bit represents receive data feature. This bit must be set for the data from the module
to be received by the controller. It also enables RXD pin of controller.
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 5/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
BROWN (RXCIE): This bit must be set for getting an interrupt after successful data reception. By
enabling this bit we get to know, right after 8 bit data receive.
PINK (URSEL): This bit must be set before enable other bits in UCSRC. After setting, other needed bits
in UCSRC,URSEL must be disabled or put to zero.
YELLOW (UCSZ0,UCSZ1,UCSZ2):These three bits are used for selecting the number of data bits we are
receiving or sending in a single go.
Since the data sent by RFID module is 8bit data type, we have to set UCSZ0, UCSZ1 to one and UCSZ2
to zero.
ORANGE (UMSEL): This bit is set based on whether the system is communicating asynchronously
(both use different clock) or synchronously (both use same clock).
Since module and controller use different clock, this bit must be set to zero or left alone as they are all
set to zero by default.
GREEN (UPM1, UPM0): These two bits are adjusted based on bit parity we are using in communication.
Since RFID module sends data with no parity, we have set both UPM1, UPM0 to zero or they can be left
alone as all bits in any registers are set to zero by default.
BLUE (USBS): This bit is used for choosing the number of stop bits we are using during
communication.
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 6/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
Since RFID module sends data with one stop bit, we just have to leave USBS bit alone.
Now at last we need to set the baud rate, from gure above it is clear that the RFID module sends data
to controller with a baud rate of 9600bps (bits per second).
The UBRRH value is chosen by cross referring baud rate and CPU crystal frequency, So by cross
reference UBRR value is seen as 6, and so the baud rate is set.
Now as shown in gure, two pins from controller goes to L293D, which is a H-BRIDGE used to
control speed and direction of rotation for low power DC motors (http://circuitdigest.com/electronic-
circuits/dc-motor-speed-control).
L293D is an H-BRIDGE IC designed for driving low power DC motors and is shown in gure, this IC
consists two h-bridges and so it can drive two DC motors. So this IC can be used to drive robotmotors
from the signals of microcontroller.
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 7/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
Now as discussed before this IC has ability to change the direction of rotation of DC motor. This is
achieved by controlling the voltage levels at INPUT1 and INPUT2.
So as shown in above table, for clock wise rotation 2A should be high and 1A should be low. Similarly
for anti clockwise 1A should be high and 2A should be low.
Whenever an authorized card is brought near the module, the motor is programmed to move clockwise
for a second, to show the toll gate is opened after a second it comes back, telling the toll gate is
closed.The working of toll plaza is best explained in step by step of C code give below.
Programming Explanation
Below is the line to line explanation for the code of this RFID Toll Plaza System. You can understand the
concept and working of this project by reading the code below. To download or copy, you can nd the
complete code at the bottomof page.
#dene E 5// giving name enable to 5th pin of PORTD, since it is connected to LCD enable pin
#dene RS 6// giving name registerselection to 6th pin of PORTD, since it is connected to LCD RS pin
int main(void)
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 8/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
DDRD = 0b11111110;
UBRRH &=~(1<<URSEL);
UBRRL=6;//setting the baud rate // The following contains ID of tags, these must be changed for
different tags, These must be updated for the project to work
/* After dumping the program in the controller one must take the cards which must be authorized and
get the tags ID. These are obtained by placing the tag near RFID module and the ID will be shown on
the screen. After getting the IDs, the program must be updated by replacing the below ID numbers with
new ID numbers.
Now in above we are authorizing only ve cards, these can be changed to any number.
For example consider the default program is dumped in the controller, get the cards which should be
authorized. Place one after other near module, you will get the ID for each one as xxxxxxxx (907a4F87),
If there are 7 tags we have, then we will have 7 eight bit ID. */
//char ADMIT[7][4]={{(0x90),(0x7a),(0x4F),(0x87)},[},{},{},{},{},{}}
//Now once all the IDs are written, those ID tags are considered as authorized
char SHOWA [4]; // allotting memory for showing the ID send by module
int i=0;
send_a_command(0x38);
9 //telling lcd we are using 8bit command /data mode
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 9/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
_delay_ms(50);
3
send_a_command(0b00001111); // LCD SCREEN ON and courser blinking
while(1)
COUNTA=UDR; // UDR stores the eight bit data received and is taken into an integer.
COUNTA=UDR;
itoa(COUNTA,SHOWA,16);
send_a_string(SHOWA);
COUNTA=UDR;
itoa(COUNTA,SHOWA,16);
send_a_string(SHOWA);
COUNTA=UDR;
9
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 10/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
itoa(COUNTA,SHOWA,16);
3
send_a_string(SHOWA);
send_a_string(" ");
UCSRB &=~(1<<RXEN);//disabling the receive data until the tag ID is checked for authorization
for (i=0;i<5;i++)
if ((MEM[0]==ADMIT[i][0])&(MEM[1]==ADMIT[i][1])&(MEM[2]==ADMIT[i][2])&(MEM[3]==ADMIT[i][3]))
{ // checking for authorization buy comparing two characters at a time with the characters in the
memory
_delay_ms(220);//delay
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
UCSRB
241 |=(1<<RXEN); // enabling receive data from module
}9
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 11/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
PORTA = command;
PORTA= 0;
PORTA= character;
_delay_ms(50);
PORTA = 0;
while(*string_of_characters > 0)
send_a_character(*string_of_characters++);
}
Adsby Google
RFIDTimeandAttendance
RFIDChip
Code:
256
Shares
#include <avr/io.h>
#dene F_CPU 1000000
#include <util/delay.h>
241
#include <stdlib.h>
#dene enable 5
9
#dene registerselection 6
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 12/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
int main(void)
{
DDRA = 0xFF;
DDRB = 0b11111111;
PORTB|=(1<<PINB0)|(1<<PINB1);
DDRD = 0b11111110;
_delay_ms(50);
UCSRB |=(1<<RXEN)|(1<<RXCIE);
UCSRC |=(1<<URSEL)|(1<<UCSZ0)|(1<<UCSZ1);
UCSRC &=~(1<<UMSEL);
UBRRH &=~(1<<URSEL);
UBRRL=6;
char ADMIT [5][4]={{(0x97),(0xa1),(0x90),(0x92)},{(0x97),(0xa1),(0x90),(0x93)},{(0x97),(0xa1),(0x90),(0x94)},{(0x97),
(0xa1),(0x90),(0x95)},{(0x97),(0xa1),(0x90),(0x96)}};
int16_t COUNTA = 0;
char SHOWA [4];
int i=0;
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 13/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
while(!(UCSRA&(1<<RXC)));
3
{
}
COUNTA=UDR;
itoa(COUNTA,SHOWA,16);
send_a_string(SHOWA);
MEM[2]=COUNTA;
while(!(UCSRA&(1<<RXC)));
{
}
COUNTA=UDR;
itoa(COUNTA,SHOWA,16);
send_a_string(SHOWA);
MEM[3]=COUNTA;
send_a_string(" ");
send_a_command(0x80 + 0x40 + 0);
UCSRB &=~(1<<RXEN);
for (i=0;i<5;i++)
{
if ((MEM[0]==ADMIT[i][0])&(MEM[1]==ADMIT[i][1])&(MEM[2]==ADMIT[i][2])&(MEM[3]==ADMIT[i][3]))
{
PORTB|=(1<<PINB3);
PORTB&=~(1<<PINB0);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
PORTB|=(1<<PINB0);
PORTB&=~(1<<PINB1);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
_delay_ms(220);
PORTB&=~(1<<PINB3);
256
PORTB|=(1<<PINB1);
Shares
}
}
UCSRB |=(1<<RXEN);
241
}
}
9
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 14/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
Video:
256
Shares
CircuitDigest highly recommends EasyEDA (https://easyeda.com/) for circuit and PCB design
241
Low Cost & Fast PCB Prototypes - EasyEDA (https://easyeda.com/order)
10 pcs 2 layers only $10, Join for EasyEDA.com Free & Get $5 Cash Coupon
9(https://easyeda.com/order)
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 15/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
Comments (1)
reply (/comment/reply/80/4192)
prawinchaurasiya
i want to rd code
Jul 20, 2016
FEATURED PROJECTS AND CIRCUITS
Leave a comment
Your name *
E-mail *
(/microcontroller-projects/call-and- (/microcontroller-projects/arduino- (/microcontroller-projects/iot-
The content of this eld is kept private and will not be shown publicly.
message-using-arduino-sim900- alarm-clock) temperature-humidity-monitoring-
gsm) Arduino Based Digital Clock using-arduino)
Subject
Call and Message using with Alarm (/microcontroller- Live Temperature and
View all Featured Projects (/featured-electronics-projects-and-circuits)
Comment *
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 16/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
Web page addresses and e-mail addresses turn into links automatically.
3
Lines and paragraphs break automatically.
Save Preview
RELATED CONTENT
LATEST POSTS
(/project/arduino-based-tilt-to-unlock-box)
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 17/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
(/microcontroller-projects/ping-pong-game-using-arduino-accelerometer)
(/microcontroller-projects/call-and-message-using-arduino-sim900-gsm)
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 18/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
(/microcontroller-projects/chatroom-using-arduino-and-processing)
Create a Private Chat Room using Arduino, nRF24L01 and Processing (/microcontroller-
projects/chatroom-using-arduino-and-processing)
(/project/iot-based-raspberry-pi-microwave)
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 19/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
(/electronic-circuits/automatic-rain-sensing-car-wiper)
Ask Question
256
(/node/add/forum)
Shares
9
E-mail or username *
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 20/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
3
Password *
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 21/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 22/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 23/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 24/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 25/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 26/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 27/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 28/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 29/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 30/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 31/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
Subscribe
Popular Topics: Robotics Projects (/robotics-projects) | Arduino Uno Projects (/arduino-uno-projects) | Electronics
256
Projects (/electronics-projects) |555 Timer Circuits (/555-timer-circuits) | ATmega32 Projects (/atmega32-projects) |
Shares
ATmega8 Projects (/atmega8-projects) | Raspberry Pi Projects (/simple-raspberry-pi-projects-for-beginners) | 4017
Circuits (/4017-circuits)
241
9
Copyright 2016Circuit Digest (http://circuitdigest.com/). All rights reserved
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 32/33
8/30/2016 RFIDBasedTollPlazaSystemusingAVRMicrocontroller(ATmega32)
256
Shares
241
http://circuitdigest.com/microcontrollerprojects/rfidbasedtollplazasystem 33/33