RFID reading problem
Greetings guys,
I'm having this problem on my BASIC Stamp program where, when I scan a tag across the reader, it displays the correct ascii code, but tells me that it's a bad tag. Also, I'm using the BASIC Stamp 1 code from the RFID Tag reader documentation. Can anyone help?
I'm having this problem on my BASIC Stamp program where, when I scan a tag across the reader, it displays the correct ascii code, but tells me that it's a bad tag. Also, I'm using the BASIC Stamp 1 code from the RFID Tag reader documentation. Can anyone help?
Comments
I'm working with the orginator of this thread for his senior project. To be specific, when we use this code with his BS1:
DEBUG "Tag Identification number is: ",# tag0,# tag1,# tag2,# tag3,# tag4,# tag5,# tag6,# tag7,# tag8,# tag9,CR
We then get a printout like this:
Tag Identification number is: 146 130 130 186 202 186 186 194 178 106
My understanding is that these are decimal values, and that if we want to read them in they should be in ASCII characters - like the Parallax example code below:
[FONT=Courier New][SIZE=1][FONT=Courier New][SIZE=1] [LEFT]EEPROM ("0F0184F20B") ' valid tags EEPROM ("0F01D9D263") EEPROM ("04129C1B43") EEPROM ("0000000000") ' space for other tags[/LEFT] EEPROM ("0000000000") [/SIZE][/FONT][/SIZE][/FONT]
But here's our problem; When we convert our decimal values to ASCII character codes, we get something in the extended ASCII range, like this:
EEPROM ("’‚,ºÊººÂ²j")
We've read the RFID reader PDF guide (v2.2), and haven't been able to succesfully get a tag we read in to match a tag in that we've stored in EEPROM. My guess is that we're either not printing deicmal values when using DEBUG, or that our conversion is off - way off.
Please help.
Lamar
Note that, if you prefer using hexadecimal for your debug display, you can use "$" instead of "#".
[FONT=Courier New][SIZE=1][FONT=Courier New][SIZE=1] ' ========================================================================= [SIZE=2]'[/SIZE] [SIZE=2]' File....... RFID_basic.BS1[/SIZE] [SIZE=2]' Purpose.... RFID Tag Reader[/SIZE] [SIZE=2]' Author..... (c) Parallax, Inc. -- All Rights Reserved[/SIZE] [SIZE=2]' E-mail..... support@parallax.com[/SIZE] [SIZE=2]' Started....[/SIZE] [SIZE=2]' Updated.... 07 FEB 2005[/SIZE] [SIZE=2]'[/SIZE] [SIZE=2]' {$STAMP BS1}[/SIZE] [SIZE=2]' {$PBASIC 1.0}[/SIZE] [SIZE=2]'[/SIZE] [SIZE=2]' =========================================================================[/SIZE] [SIZE=2] [/SIZE] [SIZE=2]' -----[ Program Description ]---------------------------------------------[/SIZE] [SIZE=2]'[/SIZE] [SIZE=2]' Reads tags from a Parallax RFID reader and compares to known tags (stored[/SIZE] [SIZE=2]' in EEPROM table). If tag is found, the program will disable a lock.[/SIZE] [SIZE=2] [/SIZE] [SIZE=2]' -----[ Revision History ]------------------------------------------------[/SIZE] [SIZE=2] [/SIZE] [SIZE=2]' -----[ I/O Definitions ]-------------------------------------------------[/SIZE] [SIZE=2]SYMBOL Enable = 0 ' low = reader on[/SIZE] [SIZE=2]SYMBOL RX = 1 ' serial from reader[/SIZE] [SIZE=2] [/SIZE] [SIZE=2] [/SIZE] [SIZE=2]' -----[ Constants ]-------------------------------------------------------[/SIZE] [SIZE=2] [/SIZE] [SIZE=2] [/SIZE] [SIZE=2] [/SIZE] [SIZE=2]' -----[ Variables ]-------------------------------------------------------[/SIZE] [SIZE=2]SYMBOL tag0 = B0 ' RFID bytes buffer[/SIZE] [SIZE=2]SYMBOL tag1 = B1[/SIZE] [SIZE=2]SYMBOL tag2 = B2[/SIZE] [SIZE=2]SYMBOL tag3 = B3[/SIZE] [SIZE=2]SYMBOL tag4 = B4[/SIZE] [SIZE=2]SYMBOL tag5 = B5[/SIZE] [SIZE=2]SYMBOL tag6 = B6[/SIZE] [SIZE=2]SYMBOL tag7 = B7[/SIZE] [SIZE=2]SYMBOL tag8 = B8[/SIZE] [SIZE=2]SYMBOL tag9 = B9[/SIZE] [SIZE=2]SYMBOL tagNum = B10 ' from EEPROM table[/SIZE] [SIZE=2]SYMBOL pntr = B11 ' pointer to char in table[/SIZE] [SIZE=2]SYMBOL char = B12 ' character from table[/SIZE] [SIZE=2] [/SIZE] [SIZE=2] [/SIZE] [SIZE=2] [/SIZE] [SIZE=2]' -----[ Initialization ]--------------------------------------------------[/SIZE] [SIZE=2]Reset:[/SIZE] [SIZE=2]HIGH Enable ' turn off RFID reader[/SIZE] [SIZE=2] [/SIZE] [SIZE=2] [/SIZE] [SIZE=2]' -----[ Program Code ]----------------------------------------------------[/SIZE] [SIZE=2]Main:[/SIZE] [SIZE=2]PAUSE 100[/SIZE] [SIZE=2]LOW Enable ' activate the reader[/SIZE] [SIZE=2]SERIN RX, T2400, ($0A) ' wait for header[/SIZE] [SIZE=2]SERIN RX, T2400, tag0, tag1, tag2, tag3, tag4 ' get tag bytes[/SIZE] [SIZE=2]SERIN RX, T2400, tag5, tag6, tag7, tag8, tag9[/SIZE] [SIZE=2]PAUSE 100[/SIZE] [SIZE=2]HIGH Enable ' deactivate reader[/SIZE] [SIZE=2]Display_Tag:[/SIZE] [SIZE=2]DEBUG "Tag Identification number is: ",# tag0,# tag1,# tag2,# tag3,# tag4,# tag5,# tag6,# tag7,# tag8,# tag9,CR[/SIZE] [SIZE=2]GOTO main[/SIZE] [/SIZE][/FONT][/SIZE][/FONT]
So we get the header byte 0x0A (byte 0 of 12). Next we get the first byte of the RFID tag (byte 1 of 12), which prints out as 146. As you've suggested, this is out of normal decimal range for ASCII characters ( > than 127 ). We've used $ to display in Hex. Still the same result.
I'm starting to think that perhaps this line is bad:
[SIZE=2]SERIN RX, T2400, ($0A) ' wait for header[/SIZE]
Tonight we'll try to save the first byte of the serial transmission to a variable, instead of ($0A). Perhaps, we aren't fully reading the first byte and are geting an offset that throws off all the values we get...? I'm thinking in binary. Like 00001010 is the first byte, and maybe we are reading only the first four bits 0000. Then we read 1010 (the seconds 4 bits) and then the next 4 bits of the first real byte of RFID tag identification.
The only reason I'm skeptical about this theory is because we're using the sample code from Parallax... which, if incorrect, would have a lot of forum posts about this. I've dug a lot, and haven't found someone with this exact problem. Hopefully it's somthing simple.
Thanks again for your help. Any further suggestions would be greatly appreciated.
Lamar
We'll provide specific information on how we have the RFID reader connected to the BS1 this afternoon. Although, if it is garbage we are reading in, it's very consistent. We can swipe the same tag 5 or 6 times and always get the same result.
The same goes for other tags we have tried. Each tag is unique, and after each swipe the unique code is always displayed.
<http://electronics.stackexchange.com/questions/49318/why-most-does-rfid-tags-use-hexadecimal-number> provides a good source for understanding why HEX a little better.
Given this info... I would do one of two things: 1) Continue to use the unique 10 x DEC value, storing the string in EEPROM as a valid tag, or 2) Convert the DEC values to HEX and store those values for later use. Either way I think you still have a unique identification number for each of your tags.