Shop OBEX P1 Docs P2 Docs Learn Events
individual rfid recognition spin code — Parallax Forums

individual rfid recognition spin code

I'm using the rfid demo in obex. I would like to assign code to specific rfid tags once recognized. I've tried changing the demo code to suit my needs, but I haven't been able to get further than anything scanned just falling into a simple pass or fail from the tag list in "dat" as a whole. Does anyone have rfid spin code that would single out specific tags?

Comments

  • kwinnkwinn Posts: 8,697
    If you are referring to the RFID_Demo.spin by Gavin Garner then it already checks to see if the scanned tag is in the list and prints that to an lcd. Typical access systems are set up so that any tag found on the list are allowed access (unlock the door).

    If you want tags to perform specific functions you would have to list those functions with the tag information and add the code that performs those functions in place of the debug statements.
    For instance, you could add a byte after each tag that could allow up to 8 functions to be performed, one for each bit that is a 1 in that byte. Another option would be to have that byte indicate one of up to 256 functions.
  • Thanks Kwinn, it is the demo by Gavin Garner i'm using. I'm not sure how to add a byte after each tag. My last effort before posting was the bottom portion (below) of the id tag check. It looks like Gavins code at the top uses a series of not equal to comparisons in an "and" group as a general pass or fail. I thought an "equal to" test for each one would work for singling out the rfid tag. could I change anything in the bottom portion of code and have it work? currently any tag that is in the tag list will turn on leds for other tag numbers when scanned. It displays their tag id correctly in the serial terminal, but somehow treats them the same as long as theyre in the tag list.



    PUB CheckRFID
    repeat i from 0 to 9 'Compare tag's 10 unique ID #s against ID #s stored in data table
    if RFIDdata[i+1]<>Tag1 and RFIDdata[i+1]<>Tag2 and RFIDdata[i+1]<>Tag3
    if RFIDdata[i+1]<>Tag4 and RFIDdata[i+1]<>Tag5 and RFIDdata[i+1]<>Tag6 'etc.
    return 0 'If one of the IDs does not match, return a zero
    return 1 'If one of the ID sequences matched, return a one

    .................................................................................................................................................................................................
    PUB CheckRFID
    repeat i from 0 to 9 'Compare tag's 10 unique ID #s against ID #s stored in data table
    if RFIDdata[i+1]==Tag1
    outa[11]~~ 'led to indicate tag 1was scanned
    if RFIDdata[i+1]==Tag2
    outa[12]~~ 'led to indicate tag 2 was scanned................ect.
  • JonnyMacJonnyMac Posts: 8,927
    edited 2018-02-24 21:33
    With Transworld (a big Halloween and Escape Rooms convention) right around the corner I've been doing a lot of RFID programming.

    I pulled code from a customer customer project to knock together the attached demo. It will scan for a tag and then can give you an index (0..n) for that tag if it is known; a bad tag returns an index of -1. This can be used as an index into other things. In the demo, I have a list of names; each is associated with a specific tag. The demo starts a background cog which runs a simple RTC -- in the end you get a simple time-clock demo that shows who clocked in or out and when that happened.

    It's easy code; you should be able to adapted it.

    BTW... my customer's project is pretty neat. While in the escape room you can find five skulls. You set a skull in the center of a Quija Board and the next clue gets spelled out by the board. Each of the skulls has a tag and there is a reader embedded in the board.
  • Did some exploring and learning some time ago - maybe you can make use of my code.
    Erlend
  • Thanks Jon, that sounds like a fun project! For this program the RX and TX on pins 31, 30 are connected internal right? I was trying to view the display through the pst, but I wasn't seeing anything. Also do I need to do anything with SDA1, and SCL1 pins 29, 28, those are internal to load the eeprom right? I'm using the professional development board. Are the eeprom/serial pins in the con section for buiding a board from scratch?
    con { io pins }                                                  
                                                                     
      RX1     = 31  { I }                                           ' serial / programming
      TX1     = 30  { O }                                            
                                                                     
      SDA1    = 29  { I/O }                                         ' i2c / eeprom
      SCL1    = 28  { I/O } 
    
      LED     = 27  { O }
      
      RFID_RX = 17  { I } 
      RFID_EN = 16  { O }
      
    
  • Thanks Erlend, I was able to get going. Are the rfid tag numbers code dependent? I noticed a tag for Gavin Garners code is:
    51,53,48,49,68,53,65,55,57,68. The same tag scanned on Erlends code is:3501D5A79D.
  • JonnyMacJonnyMac Posts: 8,927
    edited 2018-02-26 01:00
    The Propeller uses pins 31 and 30 for programming and communicating with terminals like PST. The EEPROM is connected to pins 29 and 28. As these are common to all programs I have them in my templates. You don't have to do anything with these pins.

    I was testing with a PAB which has an LED on P27 and servo connections on P17 an P16 that I used to connect my reader.

    Remember... you have to read and store your tags before running the program. In main you'll want to uncomment the call to read_tags. Download the program with F10, open PST with F12, make sure the baud is 115200 and the com port is correct, click on Enable (unless its already enabled), then click in the entry line and press a key. Move your tags to the reader and you should see the tag string in the output. I ran this code with five tags -- you can see them in the DAT section Since I have those tags you have to change that section with your tag strings.
  • Thanks Jon, it's working now. I had not uncommented the "read tags" method before.
  • mikea wrote: »
    Thanks Erlend, I was able to get going. Are the rfid tag numbers code dependent? I noticed a tag for Gavin Garners code is:
    51,53,48,49,68,53,65,55,57,68. The same tag scanned on Erlends code is:3501D5A79D.
    Same code, different coding; Gavin is using series of ascii codes, I am using series of hex numbers as text (eg. 68 is ascii code for "D")
    Erlend

Sign In or Register to comment.