Getting Stuck
nwojesse
Posts: 10
Both of the basic stamps that I am using get stuck on a FOR...NEXT loop.
Here is the code:
' Robotics with the Boe-Bot - BothServosThreeSeconds.bs2
' Run both servos in opposite directions for three seconds, then reverse
' the direction of both servos and run another three seconds.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
counter VAR Byte
FOR counter = 1 TO 122
· PULSOUT 13, 850
· PULSOUT 12, 650
· PAUSE 20
NEXT
FOR counter = 1 TO 122
· PULSOUT 13, 650
· PULSOUT 12, 850
· PAUSE 20
NEXT
END
The only problem is that the servos just keep running the first FOR..NEXT loop and never moves on to the second.
P.S. I am using·two properly wired Boe-Bots.
Here is the code:
' Robotics with the Boe-Bot - BothServosThreeSeconds.bs2
' Run both servos in opposite directions for three seconds, then reverse
' the direction of both servos and run another three seconds.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
counter VAR Byte
FOR counter = 1 TO 122
· PULSOUT 13, 850
· PULSOUT 12, 650
· PAUSE 20
NEXT
FOR counter = 1 TO 122
· PULSOUT 13, 650
· PULSOUT 12, 850
· PAUSE 20
NEXT
END
The only problem is that the servos just keep running the first FOR..NEXT loop and never moves on to the second.
P.S. I am using·two properly wired Boe-Bots.
Comments
·
With tired batteries, the voltage drops too low when the servos demand more current for the direction change.· The BASIC Stamp has a brownout detection circuit that shuts it down until the supply voltage returns to acceptable levels.· When the BASIC Stamp starts up again, it starts at the beginning of the program.·
·
You might notice a hesitation between each time·it executes the first FOR...NEXT loop.· During that time, the second FOR...NEXT loop starts and the sudden reverse of the motors draws too much current, causing the supply voltage to drop.· The BASIC Stamp shuts itself back down, so the servos stop drawing power.· The supply voltage returns, and the program starts over again at the beginning, with the first FOR...NEXT loop.
·
In Robotics with the Boe-Bot, we put a piezospeaker on the Boe-Bot and add a FREQOUT command to the beginning of the program.· If the Boe-Bot beeps in the middle of a maneuver, it's a sign that the batteries are tiring out.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Post Edited (nwojesse) : 10/19/2006 2:36:07 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.