Shop OBEX P1 Docs P2 Docs Learn Events
RFID-How to enter a RFID tag code into a single variable??-HELP — Parallax Forums

RFID-How to enter a RFID tag code into a single variable??-HELP

panayiotis96panayiotis96 Posts: 2
edited 2013-02-01 02:32 in BASIC Stamp
Hello everyone,
I despairingly trying to get the code of an RFID tag and enter it in a single variable so that i can perform if-statements.
I have both RFID reader and 5 passive tags and i'm using the source code that offered by parallax. I am also using the Basic Stamp microcontroller.
I'm trying to create a student's identification system where each student will have his own tag. When the tag is passed from the scanner all the details of the student will be appeared on a computer screen. So if i had the tag code by using an if-statement i will preview the student's details using the debug command. But into the source code offered by parallax the code is previewed on the screen by debugging 10 times each character.
My knowledge on programming this equipment is relatively pure so can you please help me?? I'll really appreciate it!!
Thank you so much

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-01-28 09:39
    You can't do it (fit a complete 40-bit RFID code into a 16-bit variable ... the largest available on the Stamp). If you look at the sample code for the RFID reader, you'll see that the RFID codes are stored as 5 successive byte values and there's a subroutine that goes through a loop comparing these bytes against successive bytes of the RFID code one at a time and stopping on the first mismatch.

    Some of the bits of the RFID tag code contain a code for the manufacturer of the tags and this is always fixed. You may be able to check once for this part of the RFID code. You may find that the part of the code that is unique to each tag is only 16 or 24 bits and you may be able to make the entries in your student table smaller and use a simpler IF statement.

    I still suggest that you use the whole 40-bit RFID tag code with entries in the student table 5 bytes in size and use the subroutine in the example code to look up tags in a table. The subroutine gives you the number of the entry in the table or a value that indicates that the tag is not in the table. This entry number is small and will fit in a single byte and makes the rest of your code much easier as long as you don't change the table.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-01-28 20:30
    Welcome to the forums! Just out of curiosity, why can't you use IF...THEN statements with 5-byte tag codes? It is a little more complicated, but not impossible. In another RFID Tag related thread I helped someone create a program that uses IF...THEN (Well, SELECT...CASE) to activate certain I/O lines depending on which tag was selected. In the demo code once a tag is identified a single number is associated with it, which happens to correspond to the order in the table it was. This can provide you an easy method of branching based on a particular tag.
  • panayiotis96panayiotis96 Posts: 2
    edited 2013-02-01 02:32
    Thank you very much for your help!!
Sign In or Register to comment.