RFID comparing
Chrissz
Posts: 6
I'm trying to let my robot do a specific task which is given by 1 of my 3 different tags.
So I have a BoeBot bot a RFID reader underneath it wich reads tags in the road.
Now I want to let my BoeBot drive a specific route (specified in a sub-routine) according to on which tag it's driving.
So for instance:
Tag1 = Straight ahead
Tag2 = Right Turn
Tag3 = Left Turn
My robot is driving on a line and when the line stops the RFID reader will be activated and waits for a tag. Which is right beneath the reader when the robot stops, and then decide where to go.
So my question is:
How do I point a Tag to a 'gosub' (Sub Routine)?
In super simple code:
IF Tag1 = RfidTag THEN GOSUB route1 ELSE
IF Tag2 = RfidTag THEN GOSUB route2 ELSE
IF Tag3 = RfidTag THEN GOSUB route3 ELSE
repeat whole sequence
ENDIF
I would really appreciate some help with this.
This is what I got right now:
And this only gives me this text in my DEBUG Console:
Post Edited (Chrissz) : 11/5/2009 11:22:23 AM GMT
So I have a BoeBot bot a RFID reader underneath it wich reads tags in the road.
Now I want to let my BoeBot drive a specific route (specified in a sub-routine) according to on which tag it's driving.
So for instance:
Tag1 = Straight ahead
Tag2 = Right Turn
Tag3 = Left Turn
My robot is driving on a line and when the line stops the RFID reader will be activated and waits for a tag. Which is right beneath the reader when the robot stops, and then decide where to go.
So my question is:
How do I point a Tag to a 'gosub' (Sub Routine)?
In super simple code:
IF Tag1 = RfidTag THEN GOSUB route1 ELSE
IF Tag2 = RfidTag THEN GOSUB route2 ELSE
IF Tag3 = RfidTag THEN GOSUB route3 ELSE
repeat whole sequence
ENDIF
I would really appreciate some help with this.
This is what I got right now:
And this only gives me this text in my DEBUG Console:
Door Closed blok1blok1blok1blok1blok1blok1blok1blok1blok1blok1blok1blok1blok1blok1blok1 blok1blok1blok1blok1blok1blok1blok1blok1blok1blok1blok1blok1blok1blok1blok1 0: Acces Denied
' -----[noparse][[/noparse] I/O Definitions ]------------------------------------------------- Enable PIN 0 ' low = reader on RX PIN 1 ' serial from reader Spkr PIN 2 ' speaker output Latch PIN 12 ' lock/latch control ' -----[noparse][[/noparse] Constants ]------------------------------------------------------- T2400 CON 396 T4800 CON 188 SevenBit CON $2000 Inverted CON $4000 Open CON $8000 Baud CON T2400 LastTag CON 3 ' -----[noparse][[/noparse] Variables ]------------------------------------------------------- buf VAR Byte(10) ' RFID bytes buffer tagNum VAR Nib ' from EEPROM table idx VAR Byte ' tag byte index char VAR Byte ' character from table pulse VAR Byte ' -----[noparse][[/noparse] EEPROM Data ]----------------------------------------------------- Tag1 DATA "0F0296ADFD" ' valid tags Tag2 DATA "0F0296D21E" Tag3 DATA "0F0296ADEB" Name0 DATA "Acces Denied", CR, 0 Name1 DATA "Acces Granted, Welcome Tag 1(White)", CR, 0 Name2 DATA "Acces Granted, Welcome Tag 2(Black)", CR, 0 Name3 DATA "Tag 3 (Small Round)", CR, 0 ' -----[noparse][[/noparse] Initialization ]-------------------------------------------------- Reset: HIGH Enable ' turn of RFID reader 'GOSUB close_door DEBUG "Door Closed", CR ' lock the door! ' -----[noparse][[/noparse] Program Code ]---------------------------------------------------- Main: LOW Enable ' activate the reader SERIN RX, T2400, [noparse][[/noparse]WAIT($0A), STR buf\10] ' wait for hdr + ID HIGH Enable ' deactivate reader Check_List: FOR tagNum = 1 TO LastTag ' scan through known tags FOR idx = 0 TO 9 ' scan bytes in tag READ (tagNum - 1 * 10 + idx), char ' get tag data from table IF (Tag1 <> buf(idx)) THEN GOSUB route1 ELSEIF (Tag2 <> buf(idx)) THEN GOSUB route2 ELSEIF (Tag3 <> buf(idx)) THEN GOSUB route3 ' compare tag to table ELSE GOSUB main ENDIF NEXT Bad_Char: ' try next tag NEXT END ' -----[noparse][[/noparse] Subroutines ]----------------------------------------------------- route1: DEBUG "blok1" RETURN route2: DEBUG "blok2" RETURN route3: DEBUG "blok3" RETURN
Post Edited (Chrissz) : 11/5/2009 11:22:23 AM GMT
Comments
I already thought I screwed up the code pretty bad.
I noticed my mistakes when I read your post. [noparse]:)[/noparse]
Definitely going to fix that tomorrow.
Could you please give me a small example of how I could compare multiple Tags with the EEPROM stored tags, because I really couldn't figure it out.
I only can get it working like it's been explained in the RFID manual on the Parallax product page, where the scanned tag is being compared to the EEEPROM data and as long if it's stored in the EEEPROM, all the tags will trigger the same action. And I want to trigger three different actions with three different tags...
Hope someone can help me with this because I really need to get it working tomorrow morning, else we're stuck again and we will waste a lot of precious time at school.
And since there's no teacher on my school who knows how BStamp works, I totally rely on you guys.
I really appreciate all of your help. And I don't know where else I could find more specific information about this, other than the parallax website.
The challenge now is to convert that to PBASIC. But, if you just remember that there is a reason behind the code you can come up with a solution.
BTW, I say number and not character or letter because the string is a sequence of hex numbers (in ASCII, true, but it is still represents a number). If you aren't familiar with hex I suggest that you find an online tutorial and work it out. It will help immensely.
Tag_Found:
ON tagNum GOSUB Routine0,· Routine1, Routine2, Routine3
I· hope this helps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 11/6/2009 3:12:20 AM GMT