RFID with Propeller
I'm new to Spin, so is there some .spin file I can download to use the parallax RFID reader? I did some searching on this forum, the parallax website, and google, but I could only find Basic Stamp files. Normally I would take the time to learn how to use it, but I have to get it to work in less than a week.

Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
http://forums.parallax.com/showthread.php?p=574524
Example 22 shows the RFID reader connected to the Propeller with a TV display.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
i see nothink for finish the first repeat (just after RFID.start )? So i think that your program loop infinitely on it (It will be the same for the next repeat).
I think that you need to add a QUIT in the IF
like that :
PUB main 'The main function DIRA[noparse][[/noparse] 0 ]~~ DIRA[noparse][[/noparse] 1 ]~~ DIRA[noparse][[/noparse] 2 ]~~ RFID.start(RxPin,EnablePin,@RfidBuffer) REPEAT IF RfidListener bytemove(@id1,@OldId,10) OUTA[noparse][[/noparse] 0 ]~~ QUIT IF RfidListener bytemove(@id2,@OldId,10) OUTA[noparse][[/noparse] 1 ] ~~ QUIT waitcnt(cnt + 30_000_000)But it's probably not yet good because there are no waiting loop before the second 'IF RfidListener' block.
Best regards,
dro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
Post Edited (inservi) : 2/3/2007 6:15:23 PM GMT
I think the test 'IF RfidBuffer==0' is wrong because you test only one byte and the tag # readed can some time contain a 0 at this first ?
dro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
Here's my code for RfidListener:
PRI RfidListener IF compare(@RfidBuffer,@OldId,10)==false bytemove(@OldId,@RfidBuffer,10) return true ELSE return false PRI compare(addr1,addr2,size) repeat size if byte[noparse][[/noparse]addr1++] <> byte[noparse][[/noparse]addr2++] return false return true▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Theron Luhn
"There are two things that are infinate: Human Stupidity and the universe. I'm not sure about the latter." - Mark Twain
Post Edited (codeking) : 2/3/2007 6:09:54 PM GMT
dro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Theron Luhn
"There are two things that are infinate: Human Stupidity and the universe. I'm not sure about the latter." - Mark Twain
Witch RFID object do you using ?
I downloaded the 'RFID.Tag.ID.Demo - Archive [noparse][[/noparse]Date 2006.10.25 Time 12.42].zip'. In this objetct, it is possible to read 'RFIDbuffer' when a tag is reading simultaneously by RFID. That is not good because it is possible to read a tag # unfinished !
I think that we have to add a flag to the RFID object for indicate when is a valid reading finished. but that is not the more urgent stuff.
dro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
Post Edited (inservi) : 2/3/2007 6:34:33 PM GMT
PUB start(RXPin,EnablePin,RFIDbuffer, flag) <--------- stop result := cog := cognew(ReadTAG(RXPin,EnablePin,RFIDbuffer, flag),@Stack)+ 1 <--------------- PRI ReadTAG(RXPin,EnablePin,RFIDAddress, flag )|i <----------------- (forgeted befor) dira[noparse][[/noparse]EnablePin]~~ ' Set Enable pin as an OUTPUT repeat i~ ' clear i ; i := 0 repeat until result == {StartByte}$0A ' Look for RFID Start byte result := Serin(RXPin) ' read RFID byte if result == false ' If result = false then a Serial ' timeout occurred give reader a ' break and Disable. outa[noparse][[/noparse]EnablePin]~~ ' Disable RFID ; Make Enable pin ' HIGH waitcnt(cnt + clkfreq) ' Wait for 1 sec outa[noparse][[/noparse]EnablePin]~ ' Enable RFID ; Make Enable pin ' LOW byte[noparse][[/noparse]flag]:=false <------- not realy necessary if your code reset it each time repeat result := Serin(RXPin) ' read RFID byte if result == {StopByte}$0D ' Look for RFID Stop byte quit byte[noparse][[/noparse]RFIDAddress+i] := result ' Update RFID buffer i := i + 1 <# 9 ' increment RFID buffer pointer ; byte[noparse][[/noparse]flag]:=true <--------and in your code some think like :
VAR byte flag <---- PUB main 'The main function DIRA[noparse][[/noparse] 0 ]~~ DIRA[noparse][[/noparse] 1 ]~~ DIRA[noparse][[/noparse] 2 ]~~ flag := false < ---- RFID.start(RxPin,EnablePin,@RfidBuffer, @flag) <---- REPEAT IF RfidListener bytemove(@id1,@OldId,10) OUTA[noparse][[/noparse]0]~~ quit REPEAT IF RfidListener bytemove(@id2,@OldId,10) OUTA[noparse][[/noparse] 1 ]~~ quit waitcnt(cnt + 30_000_000) PRI RfidListener if flag == true <---- bytemove(@OldId,@RfidBuffer,10) flag := false <----- return true ELSE return falsedro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
Post Edited (inservi) : 2/3/2007 8:26:45 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Theron Luhn
"There are two things that are infinate: Human Stupidity and the universe. I'm not sure about the latter." - Mark Twain
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 RxPin = 16 'The pin attatched to the SOUT pin EnablePin = 17 'The pin attatched to the /ENABLE pin VAR byte RfidBuffer[noparse][[/noparse]10] byte OldId[noparse][[/noparse]10] byte id1[noparse][[/noparse]10] byte id2[noparse][[/noparse]10] byte id3[noparse][[/noparse]10] byte id4[noparse][[/noparse]10] byte idCount byte idByte byte flasher long EnDisStack[noparse][[/noparse]10] OBJ RFID : "RFID" PUB main 'The main function DIRA[noparse][[/noparse]0]~~ DIRA~~ DIRA~~ RFID.start(RxPin,EnablePin,@RfidBuffer) REPEAT IF RfidListener bytemove(@id1,@OldId,10) OUTA[noparse][[/noparse]0]~~ quit REPEAT IF RfidListener bytemove(@id2,@OldId,10) OUTA~~ quit waitcnt (cnt + 150_000_000) OUTA~~ flasher := 20 REPEAT flasher !OUTA[noparse][[/noparse]0] !OUTA !OUTA waitcnt(cnt + 3_000_000) OUTA[noparse][[/noparse]0]~ OUTA~ OUTA~ REPEAT IF RfidListener IF compare(@OldId,@Id1,10) OUTA~~ ELSE OUTA~~ waitcnt(cnt + 150_000_000) quit REPEAT IF RfidListener IF compare(@OldId,@Id2,10) OUTA[noparse][[/noparse]0]~~ ELSE OUTA~~ waitcnt(cnt + 300_000_000) quit PRI RfidListener REPEAT idByte FROM 0 to 9 IF RfidBuffer[noparse][[/noparse]idByte]==0 return false IF compare(@RfidBuffer,@OldId,10)==false bytemove(@OldId,@RfidBuffer,10) bytefill(@RfidBuffer,0,10) return true ELSE return false PRI compare(addr1,addr2,size) repeat size if byte[noparse][[/noparse]addr1++] <> byte[noparse][[/noparse]addr2++] return false return true▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Theron Luhn
"There are two things that are infinate: Human Stupidity and the universe. I'm not sure about the latter." - Mark Twain
As you see, the outa[noparse][[/noparse] 1 ]~~ (other than 0) appear as outa~~ without brace (because the HTML confusing).
Could-you resend the code with a space befor and after the subscript as : 'outa[noparse][[/noparse] 1 ] ' so the code appear complete.
And also the RFID object ?
Thanks,
dro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
Post Edited (inservi) : 2/5/2007 4:42:17 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Theron Luhn
"There are two things that are infinate: Human Stupidity and the universe. I'm not sure about the latter." - Mark Twain
Post Edited (codeking) : 2/6/2007 3:11:33 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Theron Luhn
"There are two things that are infinate: Human Stupidity and the universe. I'm not sure about the latter." - Mark Twain
At the first look, i don't locate the problem. I will now simulate for trace and after post the result. a few later (2 or 3 hour). As i don't have the RFID board, i must modifying the RFID object for send a code when i push a button ( at the same speed, about 2400 baud).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
The program look to be near ok for do what you want.
Here are the behavior: (if i well understand what you want)
-Recording badges
- waiting for read the first badge
- put the badge code 1 into id1 and light on led 1 ( port 0 )
- waiting for read the second badge
- put the badge code 2 into id2 and light on led 2 ( port 1 )
- blink all leds
-Reading badges
- waiting to read the badge 1 then light on led 1
There, it is probably an error in the code :
IF compare(@OldId,@Id1,10)
OUTA[noparse][[/noparse] 1 ]~~ ' you probably need to output hight the port 0 and not the port 1
- waiting to read the badge 2 then light on led 2
There, it is probably an error in the code :
IF compare(@OldId,@Id2,10)
OUTA[noparse][[/noparse] 0 ]~~ ' you probably need to output hight the port 1 and not the port 0
At the reading stage, you need to read the badges in the right order and not two time the same because into RfidListener, RfidBuffer must be different than OldId.
Is it realy that you want ?
dro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
PRI RfidListener REPEAT idByte FROM 0 to 9 IF RfidBuffer[noparse][[/noparse]idByte]==0 return false IF compare(@RfidBuffer,@OldId,10)==false bytemove(@OldId,@RfidBuffer,10) bytefill(@RfidBuffer,0,10) return true ELSE return falseMy guess is that the problem is that RfidBuffer goes to some unexpected value. This is where plugging the prop into the TV would help for debugging. I'll see if I can get the right cable.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Theron Luhn
"There are two things that are infinate: Human Stupidity and the universe. I'm not sure about the latter." - Mark Twain
I think that you need to re-initialize 'RfidBuffer' also if the badge is readed a secon time
IF compare(@RfidBuffer,@OldId,10)==false ' This test constrain to read an different badge than previous bytemove(@OldId,@RfidBuffer,10) bytefill(@RfidBuffer,0,10) return true ELSE bytefill(@RfidBuffer,0,10) ' <--------------- added return falseHere is the test code witch is working as you want i hope.
dro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
Post Edited (inservi) : 2/7/2007 1:19:52 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Theron Luhn
"There are two things that are infinate: Human Stupidity and the universe. I'm not sure about the latter." - Mark Twain
Your are welcome.
dro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com
·
About witch FindMatch method do you think ?
dro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com
·
In the DAT section, they are 7 tags ID defined for sample. The adresse of this table of tags is given by @START_OF_TAGS. (you must of course, type your tags IDs in this table)
FindMatch return the position number of readed tag in this table or 0 if the tag readed is not in this table.
If you have a tag with ID "0415AB6481" FindMatch will return 3
I hope that you can understand my poor English.
dro.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com
·