Você está na página 1de 7

More

Next Blog

Create Blog

Sign In

PROELX
Blog For AVR

Home

Components

Downloads

Adverts
.

INCLUDES

RFID interfacing with avr

GPS interfacing with avr

RF Module interfacing with avr

Stepper Motor With AVR

Saturday, December 17, 2011


How to interface RFID with AVR microcontroller (ATmega16)
Knowingly or unknowingly the RFID technology is used by us in our day to day life. The most familiar example is seen in
MNCs, schools and offices for daily attendance or automatic door opening system. The RFID contains two parts, namely, tag
and receiver modem. When an RFID tag comes in the range of receiver, the tag gets activated and transmits its unique
identification code to the receiver module.
The output of the RFID receiver is the unique ID in either serial (RS232) or wiegand format. Most of the receivers are
equipped with additional hardware to send the extracted code in the above format, which can then be used by digital signal
processors. This article shows the interfacing of ATmega16 with RFID.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

Visitors since AUG 14,2011


Followers

pdfcrowd.com

processors. This article shows the interfacing of ATmega16 with RFID.

Join this site


w ith Google Friend Connect

Members (15)

Already a member? Sign in

Labels
Flash Labels by Harish

Blog Archive
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 RFID modem
Pin 3 of max 232 Pin 2 of RFID modem
Pin 5 ground pin of max 232 Pin 5 ground of RFID modem

2011 (28)
December (28)
USB Programmer for AVR
How to take input from a particular pin of ATmega1...
How to interface LED with AVR Microcontroller
(ATm...
How to interface keypad with AVR microcontroller (...
How to display text on 16x2 LCD using AVR
microcon...
How to use inbuilt ADC of AVR microcontroller
(ATm...
How to interface AVR microcontroller with PC using...

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++)
{

open in browser PRO version

How to interface serial ADC0831 with AVR


microcont...
How to interface Servo Motor with AVR
Microcontrol...
How to configure Watchdog Timers of AVR
Microcontr...
How to interface RFID with AVR microcontroller
(AT...
How to interface GPS with AVR microcontroller
(ATm...
INTERFACE RF MODULE WITH ATMEGA8
DRIVING STEPPER MOTOR WITH ATMEGA16
8*8 Dot Matrix Scrolling LED
MMC card Based Wav Player (ATMEGA32)
Simple calculator using avr microcontroller
BASCOM-AVR

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

card[i]= usart_getch();
}
return;

// receive card value byte by byte

BASCOM-AVR
AVR Terminal
AVR Delay Calculator

}
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;
}

An asm Introduction And The Embedded "Hello


World"...
Assembler Basics
Numbers
CONVERSIONS
ISD4004 based voice recorder
Embedded Hardware and Software
Interface LM35 with Atmega16
Reading and writing SD card using Atmega16
2012 (2)

// Program to get the 12 byte string and display it on LCD by Polling method:
/*
The RFID unique code is been displayed on LCE
LCD DATA port----PORT B
ctrl port------PORT D
rs-------PD0
rw-------PD1
en-------PD2

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

*/
#define F_CPU 12000000UL
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
#include
#include
#define LCD_DATA PORTA
// LCD data port
#define ctrl PORTB
#define en PB2
// enable signal
#define rw PB1
// read/write signal
#define rs PB0
// register select signal
void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);
void usart_init();
unsigned int usart_getch();
unsigned char i, card[12];
void getcard_id(void);
void LCD_display(void);
int main(void)
{
DDRA=0xff;
//LCD_DATA port as output port
DDRB=0x07;
//ctrl as out put
init_LCD();
//initialization of LCD
delay_ms(50);
// delay of 50 milliseconds
usart_init();
// initiailztion of USART
LCD_write_string("Unique ID No."); //Function to display string on LCD
while(1)
{
getcard_id(); // Function to get RFID card no. from serial port
LCD_cmd(0xC0); // to go in second line and zeroth position on LCD
LCD_display();
// a function to write RFID card no. on LCD
}
return 0;
}

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

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;
}
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;
}
void init_LCD(void)
{
LCD_cmd(0x38);
_delay_ms(1);

//initializtion of 16x2 LCD in 8bit mode

LCD_cmd(0x01);
_delay_ms(1);

//clear LCD

LCD_cmd(0x0E);
_delay_ms(1);

//cursor ON

LCD_cmd(0x80);
_delay_ms(1);
return;

// ---8 go to first line and --0 is for 0th position

}
void LCD_cmd(unsigned char cmd)
{
LCD_DATA=cmd;
ctrl =(0<
_delay_ms(1);
ctrl =(0<
_delay_ms(50);
return;
}

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

void LCD_write(unsigned char data)


{
LCD_DATA= data;
ctrl = (1<
_delay_ms(1);
ctrl = (1<
_delay_ms(50);
return ;
}
void usart_init()
{
UCSRB |= (1 << RXEN) | (1 << TXEN); // Turn on the transmission and reception circuitry
UCSRC |= (1 << URSEL) | (1<
// Use 8-bit character sizes
UBRRL = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value..
// into the low byte of the UBRR register
UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value..
// into the high byte of the UBRR register
}
unsigned int usart_getch()
{
while ((UCSRA & (1 << RXC)) == 0); // Do nothing until data have been received..
// and is ready to be read from UDR
return(UDR); // return the byte
}
void LCD_write_string(unsigned char *str) // take address value of the string in pointer *str
{
int i=0;
while(str[i]!='\0')
// loop will go on till the NULL characters is soon in string
{
LCD_write(str[i]); // sending data on LCD byte by byte
i++;
}
return;
}
Posted by Nikhil Shrestha (KEC,KALIMATI) at 12:25 AM
Labels: interface

Recommend this on Google

No comments:

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Post a Comment

Enter your comment...

Comment as:

Publish

Select profile...

Preview

Newer Post

Home

Older Post

Subscribe to: Post Comments (Atom)

Picture Window template. Template images by Maliketh. Powered by Blogger.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Você também pode gostar