AT89S52 Mini Development Board – Interfacing μRFID (EM-18 Compatible)
The AT89S52 Mini Development Board provides on board support for interfacing RFID reader. Radio-frequency identification (RFID) technology enables remote and automated gathering and sending of information between RFID tags or transponders and readers using a wireless link. Using RFID the exchange of data between tags and readers is rapid, automatic and does not require direct contact or line of sight. The RFID module can be interfaced with the board using the same serial reception program used for testing the UART. When a Card (tag) is brought near the RFID reader, it tries to communicate with the tag, receives the data and decodes it. Finally it send the data over the Tx line. The UART module in MCU receives the data and thus used for further applications. The sample code below describes interfacing of UART and RFID module and thus displays the data over the LCD.
Schematic
Sample 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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
/************************************************************************* HEADER FILES **************************************************************************/ #include<REGX52.H> #define LCD_PORT P0 #define EN P1_0 #define RS P1_2 /************************************************************************* FUNCTION DECLARATIONS **************************************************************************/ void LCD_Initial(); void LCD_Command(char value); void LCD_Data(char value); void Delay_ms(unsigned long int Delay); void Delay_us(int Delay); void UART_Initial(void); /************************************************************************* VARIABLE DECLARATIONS **************************************************************************/ char Rec_Data; char Rec_Array[17]; char rx_flg=0,j=0,i=0; char dis1[]="rhydoLABZ-RFID"; char dis2[]="Use a Tag"; /************************************************************************* MAIN FUNCTION **************************************************************************/ void main() { UART_Initial(); /* Initialize UART */ LCD_Initial(); /* Initialize LCD */ LCD_Command(0x81); /* LCD Location */ for(i=0; dis1[i]!='\0'; i++) LCD_Data(dis1[i]); /* Display the array dis1 */ LCD_Command(0xC2); /* LCD Location */ for(i=0; dis2[i]!='\0'; i++) LCD_Data(dis2[i]); /* Display the array dis2 */ while(1) { if(RI==1) /* Set by hardware at the end of 8th bit */ { RI = 0; Rec_Data = SBUF; /* Store the received value in a variable */ Rec_Array[j] = Rec_Data; /* Store the RFID card no: in an array */ j++; /* Increment array index */ if (j==12) /* Checking 12 digit no. rx complete */ { Rec_Array[j]='\0'; /* Adding null character */ j=0; LCD_Command(0x01); Delay_us(200); LCD_Command(0x80); LCD_Data('I'); LCD_Data('D'); LCD_Data(':'); /* Display the RFID card no: on LCD */ for(i=0; Rec_Array[i]!='\0'; i++) LCD_Data(Rec_Array[i]); Delay_ms(1000); Delay_ms(1000); LCD_Command(0x01); Delay_us(200); LCD_Command(0x81); for(i=0; dis1[i]!='\0'; i++) LCD_Data(dis1[i]); LCD_Command(0xC2); for(i=0; dis2[i]!='\0'; i++) LCD_Data(dis2[i]); } } } } /************************************************************************* * Function : UART_Initial * * * * Description : Function to initialize UART * * * * Parameters : none * **************************************************************************/ void UART_Initial(void) { TMOD = 0X21; /* Baudrate from Timer1 in Auto-Reload mode */ SCON = 0X50; /* UART Mode1 and REN set to enable Reception */ TF1 = 0; /* Clear TIMER1 overflow flag */ TR1 = 0; /* Clear TR1 to turn off timer 1 */ TH1 = 0XFD; /* Load value to Timer 1 High Byte Register */ TL1 = 0XFD; /* Load value to Timer 1 Low Byte Register */ TR1 = 1; /* Set TR1 to turn on timer 1 */ } /************************************************************************* * Function : LCD_Initial * * * * Description : Function to initialize LCD * * * * Parameters : none * **************************************************************************/ void LCD_Initial() { LCD_Command(0x30); /* LCD Specification Command */ Delay_us(5); LCD_Command(0x30); /* LCD Specification Command */ Delay_us(5); LCD_Command(0x30); /* LCD Specification Command */ Delay_us(5); LCD_Command(0x38); /* Double Line Display Command */ LCD_Command(0x06); /* Auto Increment Location Address Command */ LCD_Command(0x0C); /* Display ON Command */ LCD_Command(0x01); /* Clear Display Command */ Delay_us(200); } /************************************************************************* * Function : LCD_Command * * * * Description : Function to send a command to LCD * * * * Parameters : value - command to be sent * **************************************************************************/ void LCD_Command(char value) { RS = 0; /* RS-0(command register) */ EN = 1; /* E-1(Enable pin high) */ LCD_PORT = value; /* Write the command to data lines */ Delay_us(5); EN = 0; /* E-0(Enable pin low) */ } /************************************************************************* * Function : LCD_Data * * * * Description : Function to display single character on LCD * * * * Parameters : value - character to be displayed * **************************************************************************/ void LCD_Data(char value) { RS = 1; /* RS-1(data register) */ EN = 1; /* E-1(Enable pin high) */ LCD_PORT = value; /* Write the character to data lines */ Delay_us(5); EN = 0; /* E-0(Enable pin low) */ } /************************************************************************* * Function : Delay_us * * * * Description : Function for 1 microsecond delay * * * * Parameter : Delay - delay in microseconds * **************************************************************************/ void Delay_us(int Delay) { while((--Delay)!=0); } /************************************************************************* * Function : Delay_ms * * * * Description : Function for 1 millisecond delay * * * * Parameter : Delay - delay in milliseconds * **************************************************************************/ void Delay_ms(unsigned long int Delay) { Delay = Delay*15; while(--Delay!=0); } /*************************** END OF PROGRAM ****************************/ |
Topics related to AT89S52 Mini Development Board
- AT89S52 Mini Development Board – Overview
- AT89S52 Mini Development Board – LED Interfacing
- AT89S52 Mini Development Board – LCD Interfacing
- AT89S52 Mini Development Board – Serial communication
- AT89S52 Mini Development Board – EEPROM Interfacing
- AT89S52 Mini Development Board – Buzzer Interfacing
- AT89S52 Mini Development Board – Servo Motor Interfacing
- AT89S52 Mini Development Board – Switch Interfacing
- AT89S52 Mini Development Board – RFID Interfacing
Resources
- Softwares
- Datasheets
How to buy?
- Click here to buy the rhydoLABZ AT89S52 Mni Development Board (Mini) V1.01
- Click here to buy the rhydoLABZ AT89S52 Development Board
- Click here to buy the rhydoLABZ AT89S52-24PU Microcontroller
- Click here to buy the rhydoLABZ ATMEL 89SXX ISP Programmer (RS232)
- Click here to buy µRFID Reader (EM-18 compatible)
SupportPlease share your ideas with us, visit our forum for discussion
Leave a Reply
You must be logged in to post a comment.