PIC16F877A – Interfacing EM-18 Compatible μRFID
The PIC 16F877A 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.
SchematicSample Code
The sample code to interface μRFID reader is given below. On reading an RFID card, its ID is displayed on LCD.
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 |
/************************************************************************* HEADER FILES **************************************************************************/ #include<pic.h> /************************************************************************* FUNCTION DECLARATIONS **************************************************************************/ void Delay_us(char Delay); void Delay_100us(unsigned long int Delay); void Data(char Value); void Cmd(char Value); void Send2Lcd(const char Adr, const char *Lcd); /************************************************************************* VARIABLE DECLARATIONS **************************************************************************/ int bx=0,rfid=0,i=0; char msg[14],R=0; /************************************************************************* MAIN FUNCTION **************************************************************************/ void main() { TRISC = 0X80; /* RC7(Rx) configured as i/p, RC0(RS),RC1(EN) as o/p */ TRISD = 0X00; /* PORTD(data lines) configured as o/p */ Delay_us(35); Cmd(0X30); /* LCD Specification Commands */ Delay_us(35); Cmd(0X30); /* LCD Specification Commands */ Delay_us(35); Cmd(0X30); /* LCD Specification Commands */ Delay_us(35); Cmd(0X38); /* Double Line Display Command */ Cmd(0X06); /* Auto Increment Location Address Command */ Cmd(0X0C); /* Display ON Command */ Cmd(0X01); /* Clear Display Command */ Delay_100us(30); Send2Lcd(0x80," rhydoLABZ "); Send2Lcd(0xc0," RFID TEST "); TXSTA = 0X24; RCSTA = 0X90; SPBRG = 0X81; while(1) { while(RCIF==0); /* Wait here till data is received */ RCIF = 0; /* Clear Receive interrupt flag */ R = RCREG; /* Copy the received character */ msg[bx] = R; /* Store the ID no: in an array */ bx++; /* Increment the array index */ if(bx==12) /* Check if all the 12 numbers are received*/ { msg[bx]='\0'; /* Terminate the string with null character*/ bx=0; /* Clear array index */ Cmd(0xC2); for(i=0; msg[i]!='\0'; i++)/* Display the no: on LCD */ { Data(msg[i]); } Delay_100us(15000);Delay_100us(15000); Send2Lcd(0xc0," RFID TEST "); } } } /************************************************************************* * Function : Cmd * * * * Description : Function to send a command to LCD * * * * Parameters : Value - command to be sent * **************************************************************************/ void Cmd(int Value) { PORTD = Value; /* Write the command to data lines */ RC0 = 0; /* RS-0(command register) */ RC1 = 1; /* E-1(enable) */ Delay_us(25); RC1 = 0; /* E-0(enable) */ } /************************************************************************* * Function : Data * * * * Description : Function to display single character on LCD * * * * Parameters : Value - character to be displayed * **************************************************************************/ void Data(int Value) { PORTD = Value; /* Write the character to data lines */ RC0 = 1; /* RS-1(data register) */ RC1 = 1; /* E-1(enable) */ Delay_us(25); RC1 = 0; /* E-0(enable) */ } /************************************************************************* * Function : Send2LCD * * * * Description : Function to display string on LCD * * * * Parameters : Adr - location * * String to be displayed * **************************************************************************/ void Send2Lcd(const char Adr, const char *Lcd) { Cmd(Adr); /* Address of location to display string */ while(*Lcd!='\0') /* Check for termination character */ { Data(*Lcd); /* Display the character on LCD */ Lcd++; /* Increment the pointer */ } } /************************************************************************* * Function : Delay_us * * * * Description : Function for 1 microsecond delay * * * * Parameter : Delay - delay in microseconds * **************************************************************************/ void Delay_us(char Delay) { while((--Delay)!=0); } /************************************************************************* * Function : Delay_100us * * * * Description : Function for delay * * * * Parameter : Delay - delay in microseconds * **************************************************************************/ void Delay_100us(unsigned long int Delay) { Delay=Delay*15; while((--Delay)!=0); } /*************************** END OF PROGRAM ****************************/ |
Topics related to PIC16F877A Development Board-Mini
- PIC16F877A Mini Development Board – Overview
- PIC16F877A Mini Development Board – Interfacing LED
- PIC16F877A Mini Development Board – Interfacing LCD
- PIC16F877A Mini Development Board – Serial communication(USART)
- PIC16F877A Mini Development Board – Interfacing Switch
- PIC16F877A Mini Development Board – Interfacing Buzzer
- PIC16F877A Mini Development Board – Interfacing POT(ADC)
- PIC16F877A Mini Development Board – Interfacing Temperature sensor
- PIC 16F877A Mini Development Board – Interfacing Servo Motor
- PIC 16F877A Mini Development Board – Interfacing μRFID Reader
Resources
- Datasheets
How to buy?
- Click here to buy rhydoLABZ PIC 16F877A Mini Development Board
- Click here to buy rhydoLABZ PIC 18F4520 Mini Development Board
- Click here to buy rhydoLABZ PIC 18F4550 Mini Development Board
- Click here to buy rhydoLABZ PIC 18F4580 Mini Development Board
- Click here to buy rhydoLABZ µ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.