Boe-Bot is stuck in a loop, HELP!!!
adaniel10
Posts: 10
I was following the textbook 'Robotics with the Boe-Bot' and I followed every example carefully. I adjusted the servos so they stop moving at 750 by tweaking the potentiometer (to center them).
When I follow this example, the boe-bot moves perfectly:
' Robotics with the Boe-Bot - ServosP13CcwP12Cw.bsx
' Run the servo connected to P13 at full speed counterclockwise
' and the servo connected to P12 at full speed clockwise.
' {$STAMP BS2sx}
' {$PBASIC 2.5}
DEBUG "Program Running!"
DO
PULSOUT 13, 850 ' left motor full speed
PULSOUT 12, 650 ' right motor full speed
PAUSE 20
LOOP
But when I try to move on to the next example, the boe-bot only moves forward and does not reverse backwards:
' Robotics with the Boe-Bot - BothServosThreeSeconds.bsx
' Run both servos in opposite directions for three seconds, then reverse
' the direction of both servos and run another three seconds.
' {$STAMP BS2sx}
' {$PBASIC 2.5}
DEBUG "Program Running!"
counter VAR Byte
' goes forwards
FOR counter = 1 TO 122
PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20
NEXT
'goes backwards
FOR counter = 1 TO 122
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT
END
Can someone please help me, I am stuck in this problem for ages. I dont know why the robot only moves forward and keeps on resetting itself. When the speed of the motors are reduced (i mean very reduced), it then flows through the program till the end. I dont know why this is the case. Hope someone knows how to solve this issue.
Thanks.
When I follow this example, the boe-bot moves perfectly:
' Robotics with the Boe-Bot - ServosP13CcwP12Cw.bsx
' Run the servo connected to P13 at full speed counterclockwise
' and the servo connected to P12 at full speed clockwise.
' {$STAMP BS2sx}
' {$PBASIC 2.5}
DEBUG "Program Running!"
DO
PULSOUT 13, 850 ' left motor full speed
PULSOUT 12, 650 ' right motor full speed
PAUSE 20
LOOP
But when I try to move on to the next example, the boe-bot only moves forward and does not reverse backwards:
' Robotics with the Boe-Bot - BothServosThreeSeconds.bsx
' Run both servos in opposite directions for three seconds, then reverse
' the direction of both servos and run another three seconds.
' {$STAMP BS2sx}
' {$PBASIC 2.5}
DEBUG "Program Running!"
counter VAR Byte
' goes forwards
FOR counter = 1 TO 122
PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20
NEXT
'goes backwards
FOR counter = 1 TO 122
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT
END
Can someone please help me, I am stuck in this problem for ages. I dont know why the robot only moves forward and keeps on resetting itself. When the speed of the motors are reduced (i mean very reduced), it then flows through the program till the end. I dont know why this is the case. Hope someone knows how to solve this issue.
Thanks.
Comments
Try a fresh set of batteries and report back.
Tried using fresh batteries but still no effect
When I increased the pause to 1000, the robot started going forwards and backwards properly but the robot was moving really slow....
Anyway to fix this issue with pause at 20?
Try PULSOUT 1000 and 500 insstead of 850 and 650.
Great Q. Should be Vin.
That increased the speed of the robot, but it still does not go into the next counter for backwards.
It is plugged into the Vin. I am using the boe-bot kit 28832 (serial). Dont know the issue here.
tried doing that but still the same problem
If you are using the standard 28832 kit, that came standard with a standard BS2 chip.
In your first post you have the chip directive as:
Do you actually have a BS2SX installed?
If not, it should read:
As you can see in my first post, I used:
' {$STAMP BS2sx}
' {$PBASIC 2.5}
If i use the normal basic stamp 2, it won't allow me to run it. So BS2sx is installed and that only runs the program.
So you have a bad BS2?
Also what module is listed when you press F6 (identify)?
If you have a BS2SX module then the PULSOUT values should be larger which would explain why it moves so slowly.
The BS2 uses 2 us units but the BS2sx uses 0.8 us.
850 x 2 us = 1700 us
650 x 2 us = 1300 us
1700 us / 0.8 us = 2125
1300 us / 0.8 us = 1625 us
Try changing the 850s to 2125 and the 650s to 1625.
Also, for centering your servos:
750 x 2 us = 1500 us
1500 us / 0.8 us = 1875
Change 750 to 1875
Also, make it a habit to press F7 (Check Syntax) so the editor can check your program for mistakes.
I have the BS2sx version. As you can see from my code above, it is set to BS2sx and the program will run but not go into the second counter unless the speed of the motor is greatly reduced.
I will check this out soon...
It identifies it as BS2sx Rev G. All pins are secure, this kit was used before in perfect condition. The board i am using is Rev B.
Then I remembered a six year old thread by the amazing Andy:
http://forums.parallax.com/showthread.php/108242-Porting-PBASIC-Boe-Bot-code-from-BS2-to-BS2px
that explains it all.
Now if I can find my BS2SX, I can work out the timing for it.
For FREQOUT the BS2 uses units of 1 ms for the Duration while the BS2sx uses units of 0.4 ms, so all the Duration values need to be multiplied by 2.5 since 1/0.4 = 2.5.
For FREQOUT the BS2 uses units of 1 Hz for the Frequency while the BS2sx uses units of 2.5 Hz, so all the Frequency values need to be multiplied by 0.4 since 1/2.5 = 0.4.
For PULSOUT the BS2 uses units of 2 us each while the BS2sx uses units of 0.8 us, so the values all need to be multiplied by 2.5x since 2/0.8 = 2.5.
For RCTIME the BS2 returns units of 2 us each while the BS2sx returns units of 0.8 us, so expect values that are 2.5x bigger since 2/0.8 = 2.5.