I've just started playing around with two servos using the softservo library but I've come across a couple of issues, although I expect they are related. The first is that sometimes the angle I am setting is being ignored, and the servo remains motionless. The second is that I am often getting warnings on my laptop that the usb device is taking too much power.
I suspect that the power issue is the real problem behind the stationary servos, but how should I go about providing power to the servos? At the moment, I'm just hooking up the red wire from both servos directly to the 5v pin on my Arduino. The arduino is powered from USB.
Do I need an external power supply? Should I have a resistor somewhere between the arduino and the servos?
What sort of power supply should I be looking at, then? Will powering the arduino through the wall adapter be sufficient, or do I need something completely separate?
If I need something separate, what sort of things should I be looking at?
It depends on the servos you have and the load on them.
5 volts at 1 amp should be plenty for many hobby servos.
Connect the power supply +5v to the servos center wire (usually red)
Connect the power supply ground to the servo ground (usually black) and to arduino Gnd
Powering the servos through the Arduino is generally not a good idea. You can probably get away with it if you're using "micro" sized servos and not working them hard, but standard-sized servos (even 1, if it's heavily loaded), are likely to overtax the Arduino's regulator. If the servo sucks too much current, it could overload the power supply to the point where it drops out of regulation, or shuts itself down due to overheating.
Plus, a servo is a motor, and most DC motors will spit noise into their power supply. Sometimes enough to make the system unreliable.
What I did was take one of the 99-cent-or-so single-IC PCBs from Radio Schlock, and put some header pins on it in sets of three. I connect only the ground and PWM pins to the Arduino, and connect the ground and +5 from a wall wart to the ground and + pins of the servos. I used a standard power jack, so I can easily switch to a 6V wall wart when I find one.
You have to make sure that both grounds (Arduino and wall wart) are connected to servo ground for this to work.
Do you have some pictures? I understand most of this electronics stuff but the issue of power supply is something totally new to me, so... this could take a while
From the sounds of it, what I need to do is power my servos from something like this, correct?
But then, if I also want to power the arduino from the wall, that means that I will need two power supplies... this doesn't seem right. How is this usually done?
Yes, something like that will do nicely, although at only 300mA, it's not really powerful enough for driving many servos. Do you have a multimeter, one that can measure the current drawn when the servo is operating at full torque?
As for powering the Arduino as well, we do sometimes have to use two power supplies. Some radio-controlled vehicles use a large NiCad battery for the motor(s) and another battery pack for the radio receiver. Other types use a single battery and a separate regulator. With an Arduino, there's an on-board regulator for the chip itself. It's possible to power the Arduino with, say, 9V and then use an external 5V regulator rated at much higher current (a few Amps) to drive heavier loads (with the same Ground).
Done a bit of digging, and I think I might have found the answer to my last question... but, unsurprisingly, it only brings more.
If I am powering the arduino from an external power supply, I can tap into that on the VIN pin. The arduino site recommends between 7-12v when using an external supply, though, which means that the VIN pin would be giving out 7-12v. So, how do I get from this higher voltage down to the 5v that my servos want?
Power the arduino from a 9v wall adapter, then go from the arduino's VIN pin into this, then from this into my servos?
It's a 2A voltage regulator, but my apparently the max current my servos might draw is around 550mA. If I have 4 servos, what are the chances they will all draw 550mA at once and go over the 2A? If this happens, will things start exploding?
Agree with all that Mike has said, plus: bolt the 2A voltage regulators to a bit of metal to act as a heatsink. You can use a scrap of aluminium or you may find a good ready-made heatsink inside some scrap electronics such as a PC power supply.
I just set everything up, got a 9v power supply going into the arduino, then out of the VIN pin into my voltage regulator (outputs 5v, max 2A), which I was then using to power 2 servos. The servos are rated at 5v, max current 550mA, but after about 30 seconds of being on, the voltage regulators had got pretty hot and had (I assume - the spec sheet says they will do this) shut themselves off.
Question 1: Why? Surely the max current drain would be 1.1A, and the voltage regulator can supply 2A - what's the problem?
Neither the AVR CPU nor the servos are especially fussy about supply voltage. Both will happily run off a 4-cell NiMH pack without a regulato9r (as long as you're not hooking some external circuitry to the Arduino that needs one). Powering the servos through a linear 5V regulator is going to mean dissipating a lot of heat.
So, unless Teddy needs to run for long periods of time, stuff him with a couple of rechargeable battery packs, and use an Arduino board like the DuinoStamp or RBBB without a voltage regulator.
If he deos need staying power, spring for a regulated 5V wall wart for the servos, and a separate supply (regulated or not, depending on which Arduino you use) for the electronics. You'll be happier, and Teddy will stay cool and reliable.
Thanks for the reply! Looks like I'll be taking a look at rechargeable batteries, then.
When you mention the alternate Arduino boards without a voltage regulator, what do you mean, and why? What sort of ampage/voltage will the 4 cell pack you suggest put out, and why is it important that the arduino board doesn't have a voltage regulator?
Also, how long is a long period of time? Are we talking minutes or hours of arduino + 4 servos?
Again, thanks for the help, and sorry I still have so many questions...
Question 1: Why? Surely the max current drain would be 1.1A, and the voltage regulator can supply 2A - what's the problem?
Yes, you're OK on maximum current, but the regulator must dissipate the power (Volts * Amps) as heat. So in this case we have 1.1A and a few volts (battery voltage minus output voltage), so we get maybe a few watts. That's got to come out as heat!
Question 2: How do I fix it?
Either reduce the battery voltage (if you can) or use a more efficient (more complicated) voltage regulator. Or, add a heatsink to the regulator you've got. Of course, if this is inside an insulating soft toy, you may be in trouble.
Question 3: Is this likely to fry stuff?
Yes, sooner or later. Heat is generally bad for electroincs.