Shop OBEX P1 Docs P2 Docs Learn Events
Problem with bs2p and servos — Parallax Forums

Problem with bs2p and servos

marco_94marco_94 Posts: 5
edited 2011-12-12 08:17 in BASIC Stamp
Hello, I just received my new BS2p microcontroller and I can't get it to work well with my servos. (boe bot)The servos work well when I just let the boe bot just drive forward/ left/right/backwards and so on.. but when I want them to first drive forward and then an other direction the boe bot is acting strange.

here the code:
' {$STAMP BS2p}
' {$PBASIC 2.5}

counter VAR Byte

DEBUG "Program Running!" ,CR
DEBUG "1",CR
FOR counter = 1 TO 120
 PULSOUT 13, 2125
PULSOUT 12, 2125
PAUSE 20
NEXT

DEBUG "2",CR
FOR counter = 1 TO 124
 PULSOUT 13, 1625
 PULSOUT 12, 1625
 PAUSE 20
NEXT

DEBUG "3",CR
FOR counter = 1 TO 122
PULSOUT 13, 2125
 PULSOUT 12, 1625
PAUSE 20
NEXT

DEBUG "4", CR
FOR counter = 1 TO 122
 PULSOUT 13, 1625
 PULSOUT 12, 2125
PAUSE 20
NEXT

DEBUG "5",CR
END
here the debug console when executed with powerswitch on 1 (no servos)
Program Running!
1
2
3
4
5
here the debug console when executed with powerswitch on 2 (with servos)
Program Running!
1
Program Running!
1
Program Running!
1
Program Running!
1
Program Running!
1
Program Running!
1
...
and this goes on and on like an infinite loop
I don't know what I'm doing wrong
the script is a standard script from this site but then with the different servo speeds
the servos are calibrated at 1825 en so the speeds are adjusted to that value

can anybody help me?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-10 07:06
    The problem is that your batteries are weak. As soon as your program tries to move the servos, the power drain becomes large enough so that the battery voltage drops to where the Stamp resets and the program starts over again. Try some fresh alkaline batteries.
  • marco_94marco_94 Posts: 5
    edited 2011-12-10 07:22
    Thnx for your reply.. But the problem isn't solved yet.. I replaced the batteries but it still hangs.. But now it gets to the second stage as I can see in the debug console
    Program Running!1
    2
    Program Running!
    1
    Program Running!
    1
    2
    Program Running!
    1
    Program Running!
    1
    2
    Program Running!
    1
    Program Running!
    1
    

    But I have already ordered an additional battery pack get some extra power.. see if this works..
    But I just think it's a little strange that it can't handle 2 servo's with the 4 AA 1,5V batteries

    I will let you know if the extra battery pack works
  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-10 08:10
    Common servos can draw as much as 1A each when started under load. Make sure the wheels are not binding / rubbing against the chassis. Make sure that you don't have a partially broken wire in the battery holder or cable. There's nothing in your program that would cause this.

    There's a jumper located between the servo connector sockets that selects between Vdd and Vin for the servo supply voltage. Make sure it's set to use Vin. Do not use an AC adapter that supplies more than 7.5V while the jumper is set that way. A 6V adapter is best, one that can supply at least 1A, preferably 2A.

    Another good trick is to split the PAUSE 20 into two PAUSE 10 and alternate these with the PULSOUTs like this:

    FOR counter = 1 TO 124
    PULSOUT 13, 1625
    PAUSE 10
    PULSOUT 12, 1625
    PAUSE 10
    NEXT

    This ensures that both servos will not try to start moving at exactly the same time and will reduce the peak currents drawn. That may be enough to keep your Stamp from resetting.
  • ercoerco Posts: 20,256
    edited 2011-12-10 08:54
    Does your same setup work properly with a BS2?
  • PublisonPublison Posts: 12,366
    edited 2011-12-10 10:44
    Classic case of Brown Out. Curious to see if Mike's solution works.
  • marco_94marco_94 Posts: 5
    edited 2011-12-11 07:08
    The problem isn't solved with the 2x PAUSE 10

    I don't have a BS2 to test it. But I securely overlooked everything and the circuits look alright to me and the script is just the script I took from the stamp in class mini project, but with adjusted speeds

    Tomorrow I will buy and try a 9v battery and see if this solves the problem.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-11 07:21
    If, by 9v battery, you mean one of those little rectangular batteries, don't waste your money. They're intended for uses where the current drain is on the order of tens of milliAmps. They can't power a servo motor. They're fine for powering a Stamp by itself, maybe with a sensor or two or an LED or two.
  • marco_94marco_94 Posts: 5
    edited 2011-12-11 12:00
    Yes I meant that one.
    What other solutions are there to use the BS2p with 2 servos? Or was the BS2p never intended to be used with 2 servos? And should I just get a BS2.
    Will the boost of an extra battery work? (I will try this as soon as I get the battery pack.)
  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-11 12:20
    All of the Stamps work fine with 2 or 3 servos. Normally you would use a 6V AA-size alkaline or 7.2V AA-size or larger NiMH battery pack both of which can supply the peak currents needed. I have a BoeBot with its normal 4 x AA battery holder plus an additional single AA holder wired in series. I put 5 NiMH cells in it and it works great. There are some good AA-size 2300 mAh to 2500 mAh cells on the market.
  • marco_94marco_94 Posts: 5
    edited 2011-12-12 07:39
    I just put in a 9v rectangle battery block (from a smoke detector :innocent:) and it works!!
    Now I wait for the battery pack to arrive and see if it works to put that one in serie with the standard one. Otherwise I will be using the 9v one.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-12 08:17
    Do be careful that the servo power jumper is set to Vdd if you're using a 9V battery or any other power source for Vin that's greater than 7.2V. Running a servo motor from a power source greater than about 7.2V will cause increased arcing in the motor brushes and will shorten their life.

    Don't be surprised if the 9V battery quickly becomes exhausted. It's not designed for this sort of usage.
Sign In or Register to comment.