Author Topic: Curious servo current spike at powerup  (Read 4156 times)

0 Members and 1 Guest are viewing this topic.

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2141
  • Country: us
Curious servo current spike at powerup
« on: October 24, 2017, 11:52:24 pm »
I've never needed to use a servo before, so know little about them.  But now I'm involved in a project in which a servo is controlled by an Arduino Nano, and the servo is behaving badly.  It generates a large current spike when power is first applied to it, but not at any other time.  I'd like to find out if this is typical behaviour for servos, and in any case get an idea of how it is generating that spike - in terms of what must be happening with the H-bridge elements to produce it.

The servo is a generic - the label says it's an "Analog Servo".  I guess that's a genuine Analog Servo, and not some cheap imitation.  The label also says:

1.5/1.8 Kgf.cm

 21.0/25.2 oz.in

 0.12/0.1 s/60

From my reading, that's not a particularly powerful servo, and in fact when it is doing its thing per the Nano firmware, it draws about 75 ma when moving fairly slowly, which is all it's intended to do.  But when power is first applied, it generates a large current spike.  I know that because while an alkaline 9V battery regulated to 5V works fine, my wall wart switching 9V supply, rated at 650 ma, goes into shutdown, and the Nano goes into boot oscillation.

The 5V regulator is a "breadboard power supply" module.  When I boot using my wall wart, both the regulator's LED and the Nano's LED cycle on and off together, and a complete boot never takes place.  I've used the wall wart in a variety of situations, and have always found it to work well until now.  The breadboard power module is rated at 700 ma.

I've tried booting with the control line tied high and tied low, and I've let the Nano begin sending the proper PWM signals before connecting 5V to the servo power pin, but always get the same boot cycling using the wall wart when power is first applied to the servo.  And if I put the servo on a separate breadboard with just it and the power module,  the power module cycles the same way.  So this has nothing to do with the Nano.

I don't really have good test equipment, but when trying to read the powerup current draw, my digital meter flashes "425" briefly.  I don't really know if that's a good number, but I suspect it may be, and that more current than that may be flowing at some point.  The needle of my analog meter moves much too slowly to indicate what's going on.  The spike is apparently very brief.

I have found that placing a resistor of about 3 ohms in the 5V line going to the servo makes it work sometimes with the wall wart.  But it's very finicky, and too much resistance means it won't behave right later on.

So from my reading, it seems to me that for a very brief instant while the controller embedded in the servo initializes, some, or possibly all, of the h-bridge transistors which provide power to the motor windings, are fully on.  I don't know how you would draw half an amp through one of these little motors otherwise.  Does that sound right?  If so, why wouldn't a proper design prevent the spike from happening?  It seems that pullup or pulldown resistors on the gates would prevent any of those transistors from turning on until the controller tells them to.  Is that asking too much?

I have an HXT500 on the way from Ebay, and it will be interesting to see if it has the same spike.  If it does, then obviously I don't understand how the embedded controller and the H's work.

Well, I'm just trying to understand whether this is just a bad copy, or a bad generic design, or whether this behavior is typical and something I should provide for in future servo circuits.  And if it is typical, I need to understand why it needs to be typical.

Thanks for any comments.

And by the way, if I insert a one ohm resistor in the servo power line, and put the scope leads across the resistor, and trigger on a rising edge, it seems the voltage drop would let me calculate the maximum current flow (using the alkaline battery). Does that sound right, or is there a better way?
« Last Edit: October 25, 2017, 12:30:05 am by Peabody »
 

Offline Fludo

  • Regular Contributor
  • *
  • Posts: 55
  • Country: us
  • EE
Re: Curious servo current spike at powerup
« Reply #1 on: October 25, 2017, 10:53:31 am »
DC motors can have a large inrush current when voltage is applied to them. The current of the field will be high until the rotor comes up to speed and generates back EMF.  Adding a 1 ohm resistor into the field of the motor will decrease the maximum speed of the motor and generate excess heat,  it will not be very precise.  I would recommend a shunt resistor to measure the current.

There's ways to limit the starting current:
Ramp up voltage from zero to max using PWM
Wire in starting resistors of 2-3 ohms, then use a timer and relay to short them out after motor is spinning
Get a bigger power supply capable of providing the peak inrush current
Add a TVS across the wire of the motor using zener diode.  Try using a 12V diode when the supply is at 9V
 

Offline capt bullshot

  • Super Contributor
  • ***
  • Posts: 3033
  • Country: de
    • Mostly useless stuff, but nice to have: wunderkis.de
Re: Curious servo current spike at powerup
« Reply #2 on: October 25, 2017, 12:43:48 pm »
These servos are designed to run off a suitable rechargeable battery - typically 4 cells of AA size NiMH or NiCd. As these can deliver such an inrush current, nobody cared about that. If you have them in a typical application (e.g. a model aircraft, boat, car ...), you could hear and see them twitching at power on.
It's bad design, but these things are cheap and there wasn't a problem in the typical application. Even expensive and strong ones showed this behaviour, not all in the same way. Some don't twitch and don't have this inrush current if you leave the pulse input open while turning them on, then you apply the pulse  and look: there's the twitch and the inrush current again.
You may have some success by buying different models and brands and select for "good" behaviour.

The better way is just to provide a powerful enough supply.
Safety devices hinder evolution
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13073
Re: Curious servo current spike at powerup
« Reply #3 on: October 25, 2017, 01:19:11 pm »
I think you are running into problems with its stall current.   

At powerup, an analog servo's position feedback circuit will not have fully stabilised, nor will its command circuit have either detected the pulse width or detected there is no pulse present to gate the H-bridge off, as the standard Futaba servo control frame is 20ms, so it cant stabilise faster than that.   It therefore determines its significantly out of position and goes to full drive for a moment to attempt to correct that, resulting in a power-on twitch and a brief high current draw

A digital servo might well be smarter and incude power-up soft start.

However both will draw a spike of close to their stall current if given a large step change in commanded position, and a 1A draw is not unusual for a regular size servo.

https://www.pololu.com/blog/16/electrical-characteristics-of-servos-and-introduction-to-the-servo-control-interface
Quote from: pololu.com
Since servo currents usually are not specified and we might not want to bother measuring each servo we use, it’s good to keep a few estimates in mind. A standard servo will have a stall current around one amp, a micro servo will need a few hundred milliamps, and a giant servo can draw ten amps or more. Since servos run at basically the same voltages, the only ways servos can offer more torque is to have higher gear ratios or to use more current. If two servos have similar speeds at the same voltage but one has five times the stall torque, it will likely draw five times the stall current.

Things *NOT* to do include running a servo from the same current limited 5V rail as the MCU (unless it can provide *FAR* more current than the MCU's draw + servo stall current), or running one from a supply that's so grossly inadequate that the servo cant even power up successfully.

Possible solutions: 
  • get a smaller, weaker servo e.g go down from a standard one to a miniature one.
  • get a beefier PSU (and possibly a beefier regulator)
  • Add enough bulk capacitance upstream of the regulator (probably a pair of supercaps in series, or a very large electrolytic) to supply the stall current for long enough, + circuits to limit their initial charging current and delay turn-on of power to the servo.

For (3), if the PSU can power up feeding a large capacitance, that could be as simple as a >1A P-MOSFET controlled by the Arduino.  However if it has difficulty starting into a heavy load, you'll probably need to have a MOSFET before the capacitors as well and either control its gate drive slew rate to limit the current, or have a 10R charging resistor in parallel with it.  The Arduino would sequence the turn-on of the MOSFETs to avoid exceeding the max PSU output current.

(2) is probably the best option - either get a beefier 9V PSU (and feed the Arduino from its Vin pin) or consider a 2A 5V USB PSU, which are dirt cheap and you can ditch the regulator, although you'll probably need something like a Schottky diode to isolate the servo power rail from the Arduino 5V and 1000uF of reservoir capacitance on the Arduino side to keep it from browning out and resetting at the start of commanded movements.  N.B. the presence of such a large capacitor on the Arduino 5V rail violates the USB inrush current spec so the Arduino *MUST* be externally powered whenever a USB cable is first connected or its host PC powered on.
« Last Edit: October 25, 2017, 04:44:12 pm by Ian.M »
 

Offline xani

  • Frequent Contributor
  • **
  • Posts: 400
Re: Curious servo current spike at powerup
« Reply #4 on: October 25, 2017, 04:04:31 pm »
4. current limit actual servo

Either by active current limit (even just LM317), or if OP is sure that happens only on first start, resistor that is then shorted by mosfet after "boot" to not burn extra current
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2141
  • Country: us
Re: Curious servo current spike at powerup
« Reply #5 on: October 25, 2017, 04:31:11 pm »
Thanks very much for everyone's comments.  This particular project is a one-off thing, and its permanent home will be on a breadboard.  And since it does work ok with a 9V battery, we will just use that and not worry about making it perfect.

More important is my understanding of how servos actually work.  Obviously I assumed too much, and in the future will know that I have to provide for this behavior in the design in ways you have outlined here.  Thanks very much for doing that.  And if I understand correctly, the bottom line is that you have to provide for the stall current, even if actual usage would never see that happen.

What's still a bit odd about this particular servo is that despite the current spike, it doesn't move when that happens.  And I wonder if its design might be so bad that for an instant both the upper and lower H transistors are turned on at the same time, thereby producing a dead short from V+ to GND that doesn't even go through the motor winding.  That would be one explanation for what I'm seeing.  On the other hand, it could just be that the current does go through the motor, but is so brief that the motor and gearing inertia isn't overcome and it never actually turns.

Well, I'll see if the HXT500 behaves differently when it arrives, and will post the result here.  But it sounds like nobody here would be particularly surprised if it behaved the same way.
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2141
  • Country: us
Re: Curious servo current spike at powerup
« Reply #6 on: October 25, 2017, 09:33:14 pm »
The HXT500 servo arrived today, and it works fine with the wall wart supply.  So then I set up my scope to capture the voltage drop across a 1 ohm resistor inserted into the V+ line to the servo.  Actually it measures 1.1 ohms.  The attached pictures show that both servos have the powerup current spike.  The HXT500 actually goes a little higher than the generic, but only very briefly, and then is lower, and shorter, than the generic.  So the area under the curve appears to be about half of the generic's.  Whatever the difference, it's enough to allow the wall wart supply to function without shutting down.

 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13971
  • Country: gb
    • Mike's Electric Stuff
Re: Curious servo current spike at powerup
« Reply #7 on: October 25, 2017, 09:52:34 pm »
A 1000uf cap across the supply, close to the servo may help.
It may also be the case that startup current may depend on the state of the control line at powerup, when the MCU's output pin is floating - try putting a pulldown resistor on it.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf