need help with "roaming with IR pairs" program
BenO
Posts: 5
this is the program and there is an error with the "Back_Up" command.·help ·'
[noparse][[/noparse] Title ]
' Robotics with the Boe-Bot - RoamingWithIr.bs2
' Adapt RoamingWithWhiskers.bs2 for use with IR pairs
' {$STAMP BS2}······························ ' Stamp directive.
' {$PBASIC 2.5}····························· ' PBASIC directive.
DEBUG "Program Running!"
'
[noparse][[/noparse] Variables ]
· irDetectLeft· VAR···· Bit
· irDetectRight VAR···· Bit
· pusleCount··· VAR···· Byte
'
[noparse][[/noparse] Initialization ]
FREQOUT 4, 2000, 3000······················· ' Signal program start/reset
'
[noparse][[/noparse] Main Routine ]
DO
· FREQOUT 8, 1, 38500······················· ' Store IR detection values in
· irDetectLeft = IN9························ ' bit variables
· FREQOUT 2, 1, 38500
· irDetectRight = IN0
· IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
··· GOSUB Back_Up··························· ' Both IR pairs detect obstacle
··· GOSUB Turn_Left························· ' Back up and U-turn (left twice)
··· GOSUB Turn_Left
· ELSEIF· (irDetectLeft = 0) THEN··········· ' Left IR pair detects
··· GOSUB Back_Up··························· ' Back up & turn right
··· GOSUB Turn_Right
· ELSEIF (irDetectRight = 0) THEN··········· ' Right IR pair detects
··· GOSUB Back_Up··························· ' Back up & turn left
··· GOSUB Turn_Left
· ELSE······································ ' Both IR pairs 1, no detects
··· GOSUB Forward_Pulse····················· ' Apply a forward pulse
· ENDIF····································· ' and check again
LOOPis is the program and there is an error with the "Back_Up" command.
[noparse][[/noparse] Title ]
' Robotics with the Boe-Bot - RoamingWithIr.bs2
' Adapt RoamingWithWhiskers.bs2 for use with IR pairs
' {$STAMP BS2}······························ ' Stamp directive.
' {$PBASIC 2.5}····························· ' PBASIC directive.
DEBUG "Program Running!"
'
[noparse][[/noparse] Variables ]
· irDetectLeft· VAR···· Bit
· irDetectRight VAR···· Bit
· pusleCount··· VAR···· Byte
'
[noparse][[/noparse] Initialization ]
FREQOUT 4, 2000, 3000······················· ' Signal program start/reset
'
[noparse][[/noparse] Main Routine ]
DO
· FREQOUT 8, 1, 38500······················· ' Store IR detection values in
· irDetectLeft = IN9························ ' bit variables
· FREQOUT 2, 1, 38500
· irDetectRight = IN0
· IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
··· GOSUB Back_Up··························· ' Both IR pairs detect obstacle
··· GOSUB Turn_Left························· ' Back up and U-turn (left twice)
··· GOSUB Turn_Left
· ELSEIF· (irDetectLeft = 0) THEN··········· ' Left IR pair detects
··· GOSUB Back_Up··························· ' Back up & turn right
··· GOSUB Turn_Right
· ELSEIF (irDetectRight = 0) THEN··········· ' Right IR pair detects
··· GOSUB Back_Up··························· ' Back up & turn left
··· GOSUB Turn_Left
· ELSE······································ ' Both IR pairs 1, no detects
··· GOSUB Forward_Pulse····················· ' Apply a forward pulse
· ENDIF····································· ' and check again
LOOPis is the program and there is an error with the "Back_Up" command.
Comments
The "Back_Up command" (actually it's a subroutine) isn't even shown in the listing you offered, so it will be a bit difficult to offer any assistance at all.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com