Stepping Boe-Bot forward, not moving normally!
Miltos
Posts: 16
I've noticed that when Boe-Bot navigates with IR (Infrared Headlights), it's actually steping very quickly moving forward cause the "forward subroutine":
Is there any other way to program it without this stepping forwarding and make it move normal?
P.S I copy the full code for examination. The freqout instructions makes Boe-Bot to sound as R2D2 from the StarWars...
Forward: PULSOUT SERVO_Right,650 PULSOUT SERVO_Left, 850 PAUSE 20 RETURN
Is there any other way to program it without this stepping forwarding and make it move normal?
P.S I copy the full code for examination. The freqout instructions makes Boe-Bot to sound as R2D2 from the StarWars...
' {$STAMP BS2}' {$PBASIC 2.5} '<------Variables---------> irDetectLeft VAR Bit irDetectRight VAR Bit counter VAR Word 'variable for PULSOUT loop '<------Constants---------> SERVO_Left CON 12 ' Right Servo SERVO_Right CON 13 ' Left Servo DO FREQOUT 7,1,38500 irDetectLeft=IN8 FREQOUT 1,1,38500 irDetectRight=IN0 DEBUG HOME, "irDetectLeft= ", BIN1 irDetectLeft,CR, "irDetectRight= ", BIN1 irDetectRight,CR PAUSE 100 IF (irDetectLeft=0) AND (irDetectRight=0) THEN DEBUG "R2D2:surprised sound", CR HIGH 3 HIGH 10 FREQOUT 2, 10, 2000 FREQOUT 2, 10, 2100 FREQOUT 2, 10, 2200 FREQOUT 2, 10, 2300 FREQOUT 2, 30, 2400 FREQOUT 2, 40, 2500 FREQOUT 2, 10, 3000 FREQOUT 2, 10, 3100 FREQOUT 2, 10, 3200 FREQOUT 2, 20, 3500 FREQOUT 2, 90, 3900 FREQOUT 2, 100, 4500 FREQOUT 2, 100, 4000 FREQOUT 2, 10, 3900 FREQOUT 2, 10, 2800 FREQOUT 2, 10, 2700 FREQOUT 2, 30, 2600 FREQOUT 2, 40, 2500 FREQOUT 2, 10, 2200 FREQOUT 2, 10, 2100 FREQOUT 2, 10, 2000 FREQOUT 2, 100, 1000 GOSUB Backwards GOSUB Turn_Left GOSUB Turn_Left ELSEIF (irDetectRight=0) THEN HIGH 3 DEBUG "R2D2:Musical Scale", CR FREQOUT 2, 100, 3520 PAUSE 1 FREQOUT 2, 100, 3729 PAUSE 1 FREQOUT 2, 100, 3322 PAUSE 1 FREQOUT 2, 100, 3136 PAUSE 1 FREQOUT 2, 100, 3720 PAUSE 1 FREQOUT 2, 100, 3929 PAUSE 1 FREQOUT 2, 100, 3522 PAUSE 1 FREQOUT 2, 100, 3336 PAUSE 1 FREQOUT 2, 100, 3900 GOSUB Backwards GOSUB Turn_Left ELSEIF (irDetectLeft=0) THEN HIGH 10 DEBUG "R2D2:Musical Scale", CR FREQOUT 2, 100, 3520 PAUSE 1 FREQOUT 2, 100, 3729 PAUSE 1 FREQOUT 2, 100, 3322 PAUSE 1 FREQOUT 2, 100, 3136 PAUSE 1 FREQOUT 2, 100, 3720 PAUSE 1 FREQOUT 2, 100, 3929 PAUSE 1 FREQOUT 2, 100, 3522 PAUSE 1 FREQOUT 2, 100, 3336 PAUSE 1 FREQOUT 2, 100, 3900 GOSUB Backwards GOSUB Turn_Right ELSE LOW 3 LOW 10 GOSUB Forward ENDIF LOOP Forward: PULSOUT SERVO_Right,650 PULSOUT SERVO_Left, 850 PAUSE 20 RETURN Turn_Left: FOR counter = 1 TO 20 PULSOUT SERVO_Left, 650 PULSOUT SERVO_Right, 650 PAUSE 20 NEXT RETURN Turn_Right: FOR counter = 1 TO 20 PULSOUT SERVO_Left, 850 PULSOUT SERVO_Right, 850 PAUSE 20 NEXT RETURN Backwards: FOR counter = 1 TO 40 PULSOUT SERVO_Left, 650 PULSOUT SERVO_Right, 850 PAUSE 20 NEXT RETURN
Comments
The Stamp can do only one thing at a time. Normally, in this program, the Stamp does the IR sensing and related decision making in the time between servo control pulses. There's about 20 milliseconds after a servo pulse is generated before the next pulse has to be sent (or the servo shuts down). That's normally enough time for a few PBasic statements including the IR sensing and the other servo's control pulse to be generated. With the DEBUG statements and sound effects, there are huge extra hunks of time used.
thanks for your prompt reply...I will comment the DEBUG statement and the "sound effects" and let you know. Thanks again...
Cheers,
Jessica
I've just commented the DEBUG statement and Voila!!! Boe-Bot is moving forward NORMALLY. Thank you. The FREQOUT commands do not affect considerabley the motion, I left them uncommented...
Jessica, thanks for your reply too. I will follow your instructions and let you know.