Using RFID to change subroutine of robot.
Chrissz
Posts: 6
Hi,
For a school project we are programming a Boe-Bot which uses the Line Rider for navigation.
Also we want it to navigate by just using code.
We mounted a RFID reader underneath the robot and now we want it to Follow a line and at the same time check for any RFID tags in on the ground.
The code we are using right now wil ride a line but when its going to check for a RFID tag it stops. We want it to continue riding the line as long as there is no RFID tag.
Could someone please help us. We have been cracking our heads on this for two full days now...
Our Code so far:
For a school project we are programming a Boe-Bot which uses the Line Rider for navigation.
Also we want it to navigate by just using code.
We mounted a RFID reader underneath the robot and now we want it to Follow a line and at the same time check for any RFID tags in on the ground.
The code we are using right now wil ride a line but when its going to check for a RFID tag it stops. We want it to continue riding the line as long as there is no RFID tag.
Could someone please help us. We have been cracking our heads on this for two full days now...
Our Code so far:
' {$STAMP BS2} ' {$PBASIC 2.5} ' -----[noparse][[/noparse] I/O Definitions ]------------------------------------------------- Enable PIN 0 ' low = reader on RX PIN 1 ' serial from reader Spkr PIN 2 ' speaker output led PIN 3 ' Led Light ' -----[noparse][[/noparse] Constants ]------------------------------------------------------- T2400 CON 396 ' -----[noparse][[/noparse] Variables ]------------------------------------------------------- buf VAR Byte(10) ' RFID bytes buffer idx VAR Byte ' tag byte index qtis VAR Nib ' Line follower counter VAR Byte ' -----[noparse][[/noparse] Initialisation ]--------------------------------------------------- OUTB = %1111 ' -----[noparse][[/noparse] Program Code ]---------------------------------------------------- main: DO GOSUB rfid PAUSE 1 GOSUB line_rider PAUSE 1 LOOP line_rider: FOR counter = 1 TO 16 GOSUB Check_Qtis DEBUG CR, "Riding Line...", CR DEBUG BIN4 ? qtis, CRSRUP SELECT Qtis CASE %1000 PULSOUT 13, 650 PULSOUT 12, 650 PULSOUT 14, 1050 CASE %1100 PULSOUT 13, 750 PULSOUT 12, 650 PULSOUT 14, 1050 CASE %0100 PULSOUT 13, 800 PULSOUT 12, 650 PULSOUT 14, 1050 CASE %0110 PULSOUT 13, 850 PULSOUT 12, 650 PULSOUT 14, 1050 CASE %0010 PULSOUT 13, 850 PULSOUT 12, 700 PULSOUT 14, 1050 CASE %0011 PULSOUT 13, 850 PULSOUT 12, 750 PULSOUT 14, 1050 CASE %0001 PULSOUT 13, 850 PULSOUT 12, 850 PULSOUT 14, 1050 CASE ELSE PAUSE 5 PULSOUT 14, 1050 ENDSELECT NEXT RETURN rfid: LOW Enable SERIN RX, T2400, [noparse][[/noparse]WAIT($0A), STR buf\10] ------------!!** Right now It just stops here because it can't find a tag **!! We just want it to continue riding the line... HIGH Enable FREQOUT Spkr, 50, 3400 HIGH led FOR idx = 0 TO 9 DEBUG buf(idx) NEXT PAUSE 1 LOW led RETURN Check_Qtis: DIRB = %1111 PAUSE 0 DIRB = %0000 PAUSE 0 qtis = INB RETURN
Comments
Could you please tell me what this: ($0A) refers to? It's used in the 'WAIT' label, but how do I modify this to make it wait for 1/100 sec or a second are whatever time period I need.
It's is not described in my manual "BASIC STAMP Syntax and reference MANUAL" it's the only manual we have at our school.
In this manual this is what is described about
Timeout:
is an option variable/constant/expression (0-65535)
that tells SERIN how long to wait for incoming data.
If data does not arrive in time, the program will jump
to the adress specified by Tlabel
[noparse][[/noparse]i[noparse][[/noparse]Tlabel:
is an option label that must be provided along with Timeout,
indicating where the program should go in the event that data
does not arrive within the period specified by Timeout.
Next problem:
How to make the label direct to another subroutine... STR buf\10
Right now it's sending to a string where the DATA of the RFID tag is stored right?, please correct me if I'm wrong.
Please help us..
The Tlabel is used for a GOTO if the Timeout is exceeded. You'd do something like:
It's working like a charm!!
You Rock! [noparse];)[/noparse]
Thank you very very much.
When we finish our project I will put some vids and pics online.
Again, thank you for your help.
Kind Regards,
Chris