Getting started with RFID reader - troubles & questions
jb9
Posts: 7
Sorry this is kind of long, but I wanted to include all the details.
I picked up an RFID reader the other day and I'm trying to interface it with a PIC, so I'm hoping the non-parallax processor doesn't make me unhelpable
I don't have an IC to connect either the reader or the pic directly to a PC's serial port yet (have some on the way), so debugging is interesting, to say the least. At this point, I'm trying to get the reader to scan an ID and write it to EEPROM. Here's the code (written in PIC C), in case anyone wants to try to see what I'm doing:
It's reading 26 bytes (to scan 2 full codes with start/stop bytes and a couple extra garbage bytes just in case). It reads one byte, writes it to EEPROM, then loops around to read again. It's also writing the byte count out in lala land as a sanity check.
When I start it up and hold an ID in front of the reader, the LEDs connected to PORTA go a couple cycles where they change rapidly (scanning an ID?), then pause briefly (delay before it reads again?), then cange rapidly again, and so on. It looks like maybe 3 cycles or 2.5, but not a clean two cycles like I would expect.
After it stops (numbytes == 26 I presume). I unplug it, read the EEPROM, and it has this:
It appears to have read a garbage byte or two, then it starts repeating a pattern, sort of. I don't see the expected Start Byte, 10 data bytes, Stop Byte, or any pattern lasting 12 bytes, for that matter. The C4s and C5s sometimes change back and forth if I run it again. I'm wondering if this pattern might mean something to someone or if there might be another obvious fix to get this reading IDs correctly. I have an app all written out for it. Once I get the reader going, I'll be just about done.
I picked up an RFID reader the other day and I'm trying to interface it with a PIC, so I'm hoping the non-parallax processor doesn't make me unhelpable
I don't have an IC to connect either the reader or the pic directly to a PC's serial port yet (have some on the way), so debugging is interesting, to say the least. At this point, I'm trying to get the reader to scan an ID and write it to EEPROM. Here's the code (written in PIC C), in case anyone wants to try to see what I'm doing:
#include <htc.h> #include<pic.h> __CONFIG(WDTDIS & LVPDIS & BORDIS & MCLRDIS & INTIO); unsigned char getc(void) { /* retrieve one byte */ while(!RCIF) /* set when register is not empty */ continue; return RCREG; } main() { int cnt, value; unsigned char numBytes=0; char c; /* 2400 baud */ SPBRG = 129; BRGH = 0; /* Other serial setup*/ SYNC = 0; SPEN = 1; CREN = 1; RCIE = 0; TXIE = 0; RX9 = 0; TX9 = 0; TXEN = 1; TRISB = 0xFF; // Set bits for USART TRISA=0; PORTA=0; while( numBytes < 26) { c = getc(); PORTA = numBytes; EEPROM_WRITE(numBytes,c); EEPROM_WRITE(0x60+numBytes,numBytes); numBytes++; } }
It's reading 26 bytes (to scan 2 full codes with start/stop bytes and a couple extra garbage bytes just in case). It reads one byte, writes it to EEPROM, then loops around to read again. It's also writing the byte count out in lala land as a sanity check.
When I start it up and hold an ID in front of the reader, the LEDs connected to PORTA go a couple cycles where they change rapidly (scanning an ID?), then pause briefly (delay before it reads again?), then cange rapidly again, and so on. It looks like maybe 3 cycles or 2.5, but not a clean two cycles like I would expect.
After it stops (numbytes == 26 I presume). I unplug it, read the EEPROM, and it has this:
0000: 00 00 C4 FF 85 C4 FF 8D <= bytes from ID scans 0008: C5 FF 84 C5 FE 85 C5 FF 0010: 84 C5 FF 8D C5 FF 85 C4 0018: FF 85 FF FF FF FF FF FF 0020: FF FF FF FF FF FF FF FF 0028: FF FF FF FF FF FF FF FF <= uninitialized memory 0030: FF FF FF FF FF FF FF FF 0038: FF FF FF FF FF FF FF FF 0040: FF FF FF FF FF FF FF FF 0048: FF FF FF FF FF FF FF FF 0050: FF FF FF FF FF FF FF FF 0058: FF FF FF FF FF FF FF FF 0060: 00 01 02 03 04 05 06 07 <= sanity check bytes 0068: 08 09 0A 0B 0C 0D 0E 0F 0070: 10 11 12 13 14 15 16 17 0078: 18 19 FF FF FF FF FF FF
It appears to have read a garbage byte or two, then it starts repeating a pattern, sort of. I don't see the expected Start Byte, 10 data bytes, Stop Byte, or any pattern lasting 12 bytes, for that matter. The C4s and C5s sometimes change back and forth if I run it again. I'm wondering if this pattern might mean something to someone or if there might be another obvious fix to get this reading IDs correctly. I have an app all written out for it. Once I get the reader going, I'll be just about done.
Comments
·· I can't help you on the PIC side (No PIC knowledge), however, all that's needed to connect the RFID reader to the PC is a MAX232 or equivalent RS-232 Driver chip.· With that you can feed the output directly into HyperTerminal or another PC application serially.· You still need to power the reader from a clean 5V P/S and tie the /Enable line to Vss (GND).· I hope this helps.· Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com