27403 Parallax Inc, 27403 Datasheet - Page 197

GUIDE APP ROBOTCS W/SUMOBOT V1.0

27403

Manufacturer Part Number
27403
Description
GUIDE APP ROBOTCS W/SUMOBOT V1.0
Manufacturer
Parallax Inc
Datasheet

Specifications of 27403

Accessory Type
Manual
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
SumoBot®
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant
Moving the State Routines to Subroutines
Here is the Main Routine from the upcoming example program SumoWrestler.bs2, a
revision of TestSumoWrestler.bs2 in which all of the state routines have been moved to
subroutines. It's quite clean and easy to read, isn't it?
' -----[ Main Routine ]-------------------------------------------------------
DO
LOOP
The code block for each navigation state now resides in a subroutine. Here is an example
of
unchanged from the way it was in the main routine. The only difference is usually the
label and
qtiLF
qtiRF = ~qtiSigRight
LOW qtiPwrLeft
LOW qtiPwrRight
RETURN
IF qtiLF = 1 THEN
ELSEIF qtiRF = 1 THEN
ELSEIF irLF = 1 AND irRF = 1 THEN
ELSEIF irLF = 1 THEN
ELSEIF irRF = 1 THEN
ELSEIF irLS = 1 THEN
ELSEIF irRS = 1 THEN
ELSE
ENDIF
Avoid_Tawara_Left
GOSUB Avoid_Tawara_Left
GOSUB Avoid_Tawara_Right
GOSUB Go_Forward
GOSUB Track_Front_Left_Object
GOSUB Track_Front_Right_Object
GOSUB Track_Side_Left_Object
GOSUB Track_Side_Left_Object
GOSUB Search_Pattern
' -----[ Subroutine - Avoid_Tawara_Left ]------------------------------
Avoid_Tawara_Left:
RETURN
= ~qtiSigLeft
FOR counter = 1 TO 15
command.
.
For the most part, the actual code in each subroutine is
' Snapshot of QTI signal states
' Turn off QTIS
' Left qti sees line?
' State = avoid left tawara
' Right qti sees line?
' State = avoid right tawara
' Both? Lunge forward
' State = Go forward
' Just left?
' State = Track front left obj.
' Just right?
' State = Track front right obj.
' Left side?
' State = track side left obj.
' Right side?
' State = track side right obj.
' Nothing sensed?
' State = Search pattern
' Back up

Related parts for 27403