Shop OBEX P1 Docs P2 Docs Learn Events
RFID reading problem — Parallax Forums

RFID reading problem

LarossLaross Posts: 1
edited 2013-02-19 08:48 in General Discussion
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?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-02-06 20:38
    Please attach the source code of the actual program you're running ... use the Go Advanced button and the Attachment Manager that appears in the reply entry window. What messages does the program display?
  • lwague2lwague2 Posts: 3
    edited 2013-02-11 15:31
    Mike,

    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
  • Mike GreenMike Green Posts: 23,101
    edited 2013-02-11 21:14
    Somehow, these values (tag0 to tag9) look wrong for ASCII characters. Normally ASCII character codes are in the range 0-127 and most of these are not in that range. The RFID reader does not send extended ASCII characters. I'd work first at figuring out why the tagN values are wrong. They should be in the range of 48-57 ("0"-"9") and 65-70 ("A"-"F") with 10 (LF) as the marker for the start of the ID and 13 (CR) as the marker for the end.

    Note that, if you prefer using hexadecimal for your debug display, you can use "$" instead of "#".
  • lwague2lwague2 Posts: 3
    edited 2013-02-12 07:33
    Thanks Mike - This is the code we're using to print the bytes from the RFID tag.
    [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
  • Mike GreenMike Green Posts: 23,101
    edited 2013-02-12 08:19
    Well, you're using the example provided by Parallax and there's nothing I can see wrong with that. The line "SERIN RX, T2400, ($0A)" is perfectly fine. How do you have the RFID reader connected to the BS1? Remember that the "SERIN RX, T2400, ($0A)" will synchronize with any bitstream that comes along that looks like ...1001010000. This could be complete garbage (noise) for all you know.
  • lwague2lwague2 Posts: 3
    edited 2013-02-12 08:38
    I see... So we will modify our code to read in the first byte and compare it to 0x0A. We won't go through until we get a match, and then we'll store the bytes that follow, and finally display them.

    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.
  • OrbilusOrbilus Posts: 10
    edited 2013-02-19 08:48
    @Laross-- I read your post and the example .pdf provided by Parallax, and immediately thought HEX. Did some research and come to find out all RFID tags are addressed similar to a MAC address on any other type of e-device (10 x HEX characters). After putting your RFID tag output (146,130,130,186, 202,186,186,194,178,106) through a HEX-DEC converter you get 92,82,82,BA,CA,BA,BA,C2,B2,6A (similar output to the example only twice the length), binary output for each value is 8 x 0/1s (much longer, but original source format).

    <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.
Sign In or Register to comment.