Shop OBEX P1 Docs P2 Docs Learn Events
Boe-Bot is stuck in a loop, HELP!!! — Parallax Forums

Boe-Bot is stuck in a loop, HELP!!!

adaniel10adaniel10 Posts: 10
edited 2014-11-22 12:00 in BASIC Stamp
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.

Comments

  • PublisonPublison Posts: 12,366
    edited 2014-11-14 10:38
    This usually indicates the lack of battery voltage.

    Try a fresh set of batteries and report back.
  • ercoerco Posts: 20,256
    edited 2014-11-15 19:46
    Also try a pause 1000 in between your forward and backward routines. That gives your batteries (and servo gears) a break between directions.
  • adaniel10adaniel10 Posts: 10
    edited 2014-11-17 03:53
    Publison wrote: »
    This usually indicates the lack of battery voltage.

    Try a fresh set of batteries and report back.

    Tried using fresh batteries but still no effect :/
  • adaniel10adaniel10 Posts: 10
    edited 2014-11-17 03:54
    erco wrote: »
    Also try a pause 1000 in between your forward and backward routines. That gives your batteries (and servo gears) a break between directions.

    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?
  • ElectrodudeElectrodude Posts: 1,646
    edited 2014-11-17 06:12
    Leave the PAUSE 20 but add a PAUSE 500 after the first FOR loop but before the second one.
  • ercoerco Posts: 20,256
    edited 2014-11-17 07:10
    adaniel10 wrote: »
    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.
  • GenetixGenetix Posts: 1,749
    edited 2014-11-17 07:11
    Is the servo port jumper on Vdd or Vin?
  • ercoerco Posts: 20,256
    edited 2014-11-17 07:14
    Genetix wrote: »
    Is the servo port jumper on Vdd or Vin?

    Great Q. Should be Vin.
  • adaniel10adaniel10 Posts: 10
    edited 2014-11-17 07:25
    erco wrote: »
    Try PULSOUT 1000 and 500 insstead of 850 and 650.

    That increased the speed of the robot, but it still does not go into the next counter for backwards.
  • adaniel10adaniel10 Posts: 10
    edited 2014-11-17 07:27
    Genetix wrote: »
    Is the servo port jumper on Vdd or Vin?

    It is plugged into the Vin. I am using the boe-bot kit 28832 (serial). Dont know the issue here.
  • adaniel10adaniel10 Posts: 10
    edited 2014-11-17 07:30
    Leave the PAUSE 20 but add a PAUSE 500 after the first FOR loop but before the second one.

    tried doing that but still the same problem
  • PublisonPublison Posts: 12,366
    edited 2014-11-17 07:39
    adaniel10 wrote: »
    It is plugged into the Vin. I am using the boe-bot kit 28832 (serial). Dont know the issue here.

    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:
    ' {$STAMP BS2sx}
    ' {$PBASIC 2.5}


    Do you actually have a BS2SX installed?

    If not, it should read:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
  • adaniel10adaniel10 Posts: 10
    edited 2014-11-17 07:49
    Publison wrote: »
    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.
  • PublisonPublison Posts: 12,366
    edited 2014-11-17 07:59
    OK, just checking as the program on page 79 of the book, (Ver 2.2), used a BS2.

    So you have a bad BS2?
  • ElectrodudeElectrodude Posts: 1,646
    edited 2014-11-17 14:14
    What if you try only running one motor at a time by commenting out the PULSEOUTs for one and then the other? Does the problem only happen for one of the motors, or does it only happen when you run both, or does it not matter which motors are running, or what?
  • GenetixGenetix Posts: 1,749
    edited 2014-11-17 14:59
    What name, color, and revision letter is listed on your BS2 module?
    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.
  • adaniel10adaniel10 Posts: 10
    edited 2014-11-17 15:10
    Publison wrote: »
    OK, just checking as the program on page 79 of the book, (Ver 2.2), used a BS2.

    So you have a bad BS2?

    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.
  • adaniel10adaniel10 Posts: 10
    edited 2014-11-17 15:11
    What if you try only running one motor at a time by commenting out the PULSEOUTs for one and then the other? Does the problem only happen for one of the motors, or does it only happen when you run both, or does it not matter which motors are running, or what?

    I will check this out soon...
  • adaniel10adaniel10 Posts: 10
    edited 2014-11-17 15:13
    Genetix wrote: »
    Check your BS2 for bent pins and make sure it is firmly seated in the socket.
    What happens when you press F7 (Identify) while the Basic Stamp Editor is open?
    Look at your BS2 module and see if it says BS2 or BS2sx on it. Also what color and Revision letter do you see?

    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.
  • GenetixGenetix Posts: 1,749
    edited 2014-11-17 15:40
    The Robotics with the Boe-Bot text was written for a standard BS2 so you will need to change the values of not only PULSOUT values but many other commands.
  • PublisonPublison Posts: 12,366
    edited 2014-11-17 16:10
    Just hooked up my Boe-Bot with a BS2 and tried the sample code with the sample code set for BS2. Worked fine. I cant find my BS2SX, (must have given it away), so I put in my BS2PX and set the directive to BS2PX. I just got counter rotating servos.

    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.
  • PublisonPublison Posts: 12,366
    edited 2014-11-17 16:12
    Missed the post by Genetix while I was researching. He is correct on changing certain values when changing BS2 families.
  • GenetixGenetix Posts: 1,749
    edited 2014-11-22 12:00
    The values of these commands need to be adjusted since the BS2sx is 2.5x faster than the BS2.

    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.
Sign In or Register to comment.