Interfacing μRFID with AVR ATmega16 Mini Development Board
AVR ATmega16 mini development board has on-board connector for interfacing microRFID reader. The reader reads the 10-byte address of a card within its range. Communication between μRFID reader & controller is via USART module. The sample code given below is written to display the address of the card on LCD.
The locations of jumpers and microRFID reader slot on the mini development board are shown in the pictures given below.
Note: Keep the jumpers J1, J2, J13 & J14 open while using RFID reader.
SchematicSample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
/************************************************************************************* HEADER FILES **************************************************************************************/ #define F_CPU 8000000L #include<avr/io.h> /* Header File Inclusion */ #include<util/delay.h> /* Delay File Inclusion */ /************************************************************************************* FUNCTION DECLARATIONS **************************************************************************************/ void Display(char loc, const char *LCD); void Command(unsigned char cmd); void Data(unsigned char dat); /************************************************************************************* VARIABLE DECLARATIONS **************************************************************************************/ volatile char Rec_Array[17]; volatile char j; int i; /************************************************************************************* MAIN FUNCTION **************************************************************************************/ int main() { DDRB = 0xFF; /* LCD data lines */ DDRD = 0X62; /* PORTD 2nd Is set Output(RD1=1)and RD2=0 & set input Controllines(RS(PD5),RW(GND),EN(PD6) */ PORTD = 0x1C; UCSRA = 0X00; /* Clears TXC & RXC Flag Bit */ UCSRB = 0X18; /* Transmission Enabling (TXEN=1) */ UCSRC = 0X86; /* URSEL=1,UMSEL=0,UCSZ1=1,UCSZ0=0 */ UBRRL = 51; /* Serial Baudrate=9600 */ _delay_us(15); /* Minimum Delay To Power On LCD To Recieve Mode */ Command(0x30); /* LCD Specification Cmdmands */ _delay_us(5); Command(0x30); /* LCD Specification Cmdmands */ _delay_us(2); Command(0x30); /* LCD Specification Cmdmands */ Command(0x38); /* LCD Double Line Display Cmdmand */ Command(0x06); /* LCD Auto Increment Location Address Cmdmand */ Command(0x0C); /* LCD Display ON Cmdmand */ Command(0x01); /* LCD Display Clear Cmdmand */ _delay_us(1200); Display(0x80, "RFID Test..."); while(1) { while((UCSRA & 0X80)!=0X80); /* Reading data fom buffer */ Rec_Array[j]=UDR; /* RFID card no stored into array */ j++; /* increment array index */ if (j==12) { /* checking 12 digit no rx complete */ Rec_Array[j]='\0'; /* adding null character */ j=0; Command(0x01); _delay_us(1000); Command(0xC3); for(i=0;i<=11;i++) /* display rfid number */ { Data(Rec_Array[i]); /* LCD display function */ } } } } /************************************************************************************* * Function : Command * * * * Description : Function to send a command to LCD * * * * Parameters : cmd - command to be sent * **************************************************************************************/ void Command(unsigned char cmd) { PORTD |= 0X40; /* contol line RS-0(cmd register),R/W-GND(write), E-1(enable) */ PORTB = cmd; /* command loaded to data port */ _delay_us(50); /* Minimun Delay For Hold On Data */ PORTD = 0X00; /* contol line RS-0(cmd register),R/W-GND(write), E-0(enable) */ } /************************************************************************************* * Function : Data * * * * Description : Function to display data on LCD * * * * Parameters : dat - data to be displayed * **************************************************************************************/ void Data(unsigned char dat) { PORTD |= 0X60; /* contol line RS-1(data register), R/W - GND(write), E-1(enable) */ PORTB = dat; /* data loaded to data port */ _delay_us(50); /* Minimun Delay For Hold On Data */ PORTD = 0X00; /* contol line RS-0(data register), R/W - GND(write), E-0(enable) */ } /************************************************************************************* * Function : Display * * * * Description : Function to display string in LCD * * * * Parameters : loc - location * * LCD - String to be displayed * **************************************************************************************/ void Display(char loc, const char *LCD) { Command(loc); /* Address of location to display data */ while(*LCD!='\0') /* Check for termination character */ { Data(*LCD); /* Display the character on LCD */ LCD++; /* Increment the pointer */ } } /************************************************************************************* END OF PROGRAM **************************************************************************************/ |
Topics related to AVR ATmega16 Mini Development Board
- AVR ATmega16 Mini Development Board – Overview
- AVR ATmega16 Mini Development Board - Interfacing LED
- AVR ATmega16 Mini Development Board – Interfacing LCD
- AVR ATmega16 Mini Development Board – Serial communication(USART)
- AVR ATmega16 Mini Development Board – Interfacing Switch
- AVR ATmega16 Mini Development Board – Interfacing Buzzer
- AVR ATmega16 Mini Development Board - Interfacing POT(ADC)
- AVR ATmega16 Mini Development Board – Interfacing Temperature sensor
- AVR ATmega16 Mini Development Board – Interfacing Servo Motor
- AVR ATmega16 Mini Development Board – Interfacing μRFID
Resources
- Softwares
- Datasheets
How to buy?
- Click here to buy rhydoLABZ AVR ATmega16 Development Board-Mini
- Click here to buy rhydoLABZ AVR ATmega32 Development Board-Mini
- Click here to buy rhydoLABZ µRFID Reader (EM-18 compatible)
SupportPlease share your ideas with us, visit our forum for discussion