individual rfid recognition spin code
mikea
Posts: 283
in Propeller 1
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
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.
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.
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.
Erlend
51,53,48,49,68,53,65,55,57,68. The same tag scanned on Erlends code is:3501D5A79D.
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.
Erlend