Shop OBEX P1 Docs P2 Docs Learn Events
5 Servos with no Servo Controller — Parallax Forums

5 Servos with no Servo Controller

tsindostsindos Posts: 9
edited 2012-12-08 14:26 in Robotics
I have connected 5 servos directly on the BOE on various pins (no SC) which is powered by a 6V battery pack.

Am I damaging anything using this method? Everything seems to work fine and I cannot see any smoke or feel anything getting warmer. It's just that I could not find anyone on these forums that has done the same and I feel that I am doing something wrong. Everyone seems to be doing the right thing by using a Servo Controller. In "What's a Microcontroller", nothing gives me the indication that I am doing something wrong.

I just don't want to burn anything out.

Thanks

Comments

  • dandreaedandreae Posts: 1,375
    edited 2005-04-17 14:08
    Hello,

    5 servos is about the max that you would want to control without a servo controller.· You just want to·monitor the current consumption·of the I/O pins· with your circuitry, make sure that your circuit doesn't draw more than 50mA per 8 I/O pins (0 to 7 & 8 to 15).

    Dave



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Tech Support
    dandreae@parallax.com
    www.parallax.com

    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-17 14:30
    Aside from current comsuption (from the regulator) as Dave pointed out, your programming is going to have to be on its toes to manage that many servos. On the extreme end of things, you'll have five servos consuming 2 milliseconds (PULSOUT) -- that's 10 milliseconds, about half the typical refresh time for servos. What I'm suggesting is that you don't drop the PAUSE 20 instruction after the servo updates that you usually see in simple programs. Instead, to a bit of timing testing on the rest of your code and use it to create the delays between servo updates; so long as you update the servos every 15 to 35 milliseconds, you should be fine.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • tsindostsindos Posts: 9
    edited 2005-04-17 15:11
    Thank you for the replies.
    I am assuming that what you both said above is if some or all of the servos are used at the same time. Apart from 2 servos which move in sync with

    BottomArm:
    FOR counter = 0 TO 100
    PULSOUT 13, (Pulses * 15) + 250
    PULSOUT 12, ((Pulses * 15) + 250) + (Pulses + 5) 'Adjustment to move in sync with no straining one another...
    PAUSE 20
    NEXT
    RETURN

    all the other servos move one by one and never together with any other servo. They all have a "PAUSE 20" instruction at the end.

    Does this still pose a problem? Because I am thinking of actually putting a sixth servo (the last one needed).

    Am I correct to assume that when a servo has finished its motion, the PIN returns to LOW state?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-17 16:00
    You must update ALL of your servos every 20 milliseconds, not just two at a time.· The typical looping construct that we use in simple two-servo programs is just not going to cut it with five servos -- six is out of the question.· Honesly, a servo controller is the easiest solution, but if you don't want to go that route then you need to write code that synthesizes a timer and refreshes all the servos every 20 milliseconds.· If you don't do this, the servos that don't get refreshed could twitch, or make other unexpected movements (unless they're expensive digital servos that remember the last position value sent to them).

    In the end, you CAN do what you want to do, but you're going to spend a lot of time writing code to manage the servos correctly.· So ... is your time and trouble worth less money that a simple servo controller?· You decide.

    To give you an idea, I've attached a (non-trivial) sumo robot program that synthesizes a timer based on other running code (I had to manually time each subroutine) and the servos get refreshed when needed.· That way I don't have the ubiquitous PAUSE 20 during the combat portion of the code-- which does nothing but kill precious time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • tsindostsindos Posts: 9
    edited 2005-04-17 16:16
    Thank you Jon,
    (I admire you for writing so much here and having the time for us all)
    The best way is a Servo Controller but I need to finish this today. Where I come from (Cyprus), we do not have a Parallax distributor and I have to order everything online which not only is time consuming but very expensive. A $12 servo costs $70.86 when the $58.86 shipping is added.
    Parallax would be great if represented in Cyprus but the minimum orders required by Parallax are too high for anyone to be interested. Therefore I have to improvise when it comes to last minute projects.
    Thank you again for your helpful ideas. A couple of Servo Controllers is on my shopping list for my next purchase.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-04-17 17:59
    You could probably stagger the update of each servo so that you could control all of them, since each needs an update of 20ms and you have 5 servos, go in round robin fashion updating a servo each 4ms.
  • tsindostsindos Posts: 9
    edited 2005-04-17 18:03
    Thanks Paul. Good idea.
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-17 18:06
    I believe you need to allow about 100 to 200 mA when a servo is moving. I don't know what you are using for 6-volts. In theory you shouldn't have too many problems -- making sure you refresh servo's that need to hold their positions will be taking half your time -- but that still leaves you 10 to 20 mSec for other processing.

    I don't know what you are using for a power supply -- 1 amp at 6 volts can drain 4 AA batteries pretty quickly. Shouldn't break anything, though.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2005-05-13 15:22
    You can always buffer those output pins with a transistor if you really are worried that 5 servos is too much for the microcontroller.

    It is a good idea anyway as you never know when you might get an accident short to ground or +5. Things tend to shake loose on hobby projects and people tend to just plug them back in with powering down.

    You could use an ULN 2003 as a buffer or a 74HC240 [noparse][[/noparse]with inversion]. Both nicely clean up some noise problems as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    G. Herzog in Taiwan

    Post Edited (Kramer) : 5/16/2005 4:45:59 PM GMT
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-05-13 17:36
    One quick point -- the CONTROL current for a Servo is pretty trivial (that's the current going out of the BS2 pin to the Servo control pin -- 1 mA each? Less? I don't know the value, but small, anyway. And it does NOT depend on the Servo load, either). You certainly DO NOT need to buffer the CONTROL signal from the BS2 to the Servo -- that's one reason we use Servo's.

    The DRIVE current for a Servo is substantial -- 100 mA or more when moving. The BS2 does NOT supply the 'DRIVE' current, that comes from the Servo power connection -- hopefully directly to the battery if 6 volts or less, possibly connected to the Linear Regulator (7805 or 2840-5).

    Now, the amount of DRIVE current a Servo consumes while moving, or standing still, depends on the mechanical resistance it has on its 'arm'. I don't know what you are using your six servo's for -- if they 'stand still' when you are not refreshing them, they must have almost no load on them.

    The next problem is the timing, as Jon has correctly stated. The control signal for a Servo is a 1 mS to 2 mS pulse, repeated every 20 to 50 mSec. Refresing 6 servo's takes 12 mSec worst case. That doesn't give you a lot of time to decide what the next Servo Settings need to be, but it is do-able.

    The next problem is having enough memory to remember the settings for all those servos -- but I think that's it.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2005-05-16 16:52
    Thanks, I didn't have any idea that the servo control was only a 1ma draw [noparse][[/noparse]can't find and specs on that and it never occured to me to test it myself].

    Regarding the timing and memory limitations, these are really the reason to get a servo controller board. Parallax has a nice one with ramping. I don't think anyone else has that feature. It seems needed if you are going use all thosed servos to make something walk, rather than roll.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    G. Herzog in Taiwan
  • deeceethreedeeceethree Posts: 1
    edited 2012-12-06 19:04
    I have done something similar, that is, I have built a robot arm powered by five servos and controlled by potentiometers and operating levers. The program, in a loop, reads the value of each potentiometer, calculates the required pulse width, and pulses the corresponding servo.

    Now this works fine for all five servos if only one servo is connected. But when I connect two or more servos (without changing the program) the servos go berserk, jumping and twitching. Any suggestions?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-12-06 19:49
    Yes, use a separate servo controller. The problem is that there isn't enough time to do everything. As mentioned earlier, 5 servos may take as much as 10ms to 13ms or more just to generate all the control pulses. These have to be repeated about every 20ms which leaves 10ms or less to read the potentiometers. Even if you use an external ADC to read the pots, that's going to eat up your 7-10ms budgeted for that purpose. Calculating the required pulse widths will probably take close to 1ms per servo which leaves you with at best nothing left.

    When servos don't receive a control pulse in the required time window, they turn themselves off, shutting off power to the motor and some of the control circuitry. When a new pulse comes in, they turn themselves back on which causes the twitching. 3 servos is about all a Stamp can handle without help. Using a faster Stamp (like a BS2p) may help a little, but you're still working with a too small time budget set by the servo repeat pulse time.

    Do keep in mind that a servo which is heavily loaded mechanically can draw close to 1A. If, for some reason, all the servos are heavily loaded, that's around 5A total ... a lot of current. Make sure your power supply for the servos can handle this sort of peak load.
  • ercoerco Posts: 20,256
    edited 2012-12-08 12:46
    Mike Green wrote: »
    Calculating the required pulse widths will probably take close to 1ms per servo which leaves you with at best nothing left.

    @Mike: Which would be getting the maximum capability out of a Stamp. That's my quest in life... :)

    @DC3: Per Mike, that could be done with some extra hardware (ADCs) and a fair amount of fudging. But if all you want to do is read 5 pots and drive 5 servos, I'd save the $50 Stamp for something better suited and buy five $2 servo testers: http://www.ebay.com/itm/multi-Servo-tester-3CH-ECS-speed-controler-tester-Power-CHANNELS-CCPM-meter-/280929965473?pt=US_Character_Radio_Control_Toys&hash=item4168bb15a1

    http://www.youtube.com/watch?v=_lCjZrLUAP8
  • Mike GreenMike Green Posts: 23,101
    edited 2012-12-08 14:09
    @erco: If anyone could do this, you would be the one ... and in a handsome plywood box as well.

    Like erco, I like Stamps. I have a couple of BS1s around that occasionally get pressed into service ... usually something simple and slow ... and they work fine for that. I have a BS2 or two that are great for more complicated things or where more speed is necessary. I also like to use Propellers. They're fast, can do several things at once, can do even more complex stuff. It's a matter of picking a "right tool for the job". Controlling 5 servos is right on the edge of something that a Stamp can do well. A lot depends on what you're willing to do to offload some of the work from the Stamp. You can offload the work of generating regular servo control pulses. You can offload the ADC function. You can get a faster Stamp (like a BS2sx or BS2px). You've got choices.
  • ercoerco Posts: 20,256
    edited 2012-12-08 14:17
    @Mike: Now you've got me interested in trying this (when there's time over break) to see how many master pots and slave servos a vanilla BS2 could drive. Components can be chosen to minimize RCtime delay. If & when I ever get to this, I'll report back. I have a looooong "to do" list.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-12-08 14:26
    It would be helpful to get both a "can it be done in 20ms" and a "can it be done before one of the servos quits". I've not seen a maximum time available for the servos ... It's not a specified parameter. I've seen some discussion of 25ms and some of 35ms.
Sign In or Register to comment.