Servo problems are one of the most frequently posted topics within the Arduino community. While problems may arise from programming, circuit design and faulty hardware, the vast majority or problems are a result of insufficient power or incorrectly connected power.
Control is nothing without power !
The Arduino itself is very good at controlling servos, the Servo library will allow a single Arduino to control upto 12 servos with no additional hardware.
What the Arduino cannot do is deliver power to 12 Servos, its questionable whether an Arduino can reliably deliver power to even a single servo.
Power - Not All Servos Are Created Equal
While building the circuit for the pictures in this post, I decided to measure the current drawn by each of the test servos with no load applied. Each of the servos is the standard size used in radio controlled cars, they are all low end servos available for between 10 and 15 dollars.
No Load Current Of Test Servos In mA
The Bluebird draws five times more current at no load than the Futaba, its also less smooth and the least expensive of the servos tested.
The current at no load is only relevant in a small number of applications, all of the servos drew more than the the maximum 250mA I was able to measure when subjected to a light load in the form of finger pressure.
I will be interested to follow up this test in a future post using a variety of repeatable loads to compare servo performance and current draw. The fact that the lowest cost servo draws five times more current than the Futaba servo suggest that this will be an important concern for larger autonomous projects which will need to operate both under their own power and under load.
Note that while controlling all four servos the Arduino drew only 10mA from its separate power source.
So How Can Successfully Drive Lots of Servos With An Arduino ?
The power problem is easily solved through the addition of a 'power circuit'. This is can be as simple as four disposable AA Batteries such as you might use in a camera or toy car.
4 Domestic AA Batteries in a holder
Rechargable AAs are an even better option, they store as much charge, deliver as much current and can be used again and again.
For large projects which need to operate under their own power the basic concept is the same however the choice of battery technology will be different. See the 'Performance Power' section in Part 2.
So why do we need two power circuits ?
The Arduino has a narrow operating voltage around 5 Volts (3.3 Volts in some) and is sensitive to variation in this voltage. The Arduino design is based on the assumption that a stable 5 Volt power source will be feeding the chip at the heart of the Arduino. In the case of the popular UNO, this regulated 5 Volt power is supplied by the USB Connection or through a regulator built into the board.
The onboard regulator is designed to provide power to the Arduino and supporting circuitry. It is not designed to power external devices and trying to do so is the single most common reason for failure with servo projects. This 'Not designed to power external devices' also applies to USB Connected projects.
The remainder of this post provides a walk through of setting up an Arduino servo example which will drive four servos from the Arduino using a separate power pack to meet the power requirements of the servos.
Arduino Servo Walkthrough -
1) Power The Arduino
The Arduino has been loaded with my Multi Sweep example sketch, a link is provided at the end.
While running the servos, the Arduino was drawing only 10mA. A good PP3 could power the Arduino for days, after all, they power smoke alarms for months.
See the note below for more on the PP3 and why its not a good battery for use elsewhere in your projects.
Note - The PP3 is a poor battery choice for most applications, it has a small charge capacity (run time) and cannot deliver the higher currents required to drive servos or motors, however the 9 volts it provides is great for powering an Arduino through the onboard regulator. As the Arduino makes so little demand on a battery the PP3 is a common and practical choice to power the Arduino - just not any shields, motors, servos, transmitters etc.
The PP3's small charge capacity and limited ability to deliver current make it an unsuitable choice for providing the power circuit in our projects, the common AA battery is a far better alternative. In the case of servos the 9 Volts supplied by an unregulated PP3 is over the 4.8 to 6 volt recommended operating range and will result in immediate damage to the servo. Again AA Batteries are a better choice as four will provide a usable 6 Volts for our servo power circuit and a better run time.
This wont work for me, I need USB for Serial Output -
This is no problem at all, you can simply connect the USB Cable to the Arduino as you normally would. This will provide power to the Arduino so you do not need to use the 9V PP3 Battery.
You should still use the separate servo power and this will work provided that the ground from the battery pack is connected to the Arduino.
2) Power For The Servos
Each AA Battery provides 1.5 volts for a total of 6 volts (4*1.5).
Most servos are designed to operate with 4.8 to 6 volts. Powering them with more voltage can result in instant damage. The four AA Batteries give us a usable 6 volts.
I have connected the AA Batteries to the power (red) and ground (black) rails on my bread board.
Notice the black jumper running from the bread board to the Arduino ?
This is the next most common mistake in servo projects, when people introduce the servo power pack, they forget to connect a common ground.
You must connect the ground wire between the power circuit and the Arduino (control circuit) without this connection your circuit will not work. This applies whether you are powering your Arduino from a wall socket, USB port or a battery.
In the picture you can see where I have simply connected the two circuits through the black jumper wire running from the black ground rail of the bread board to the ground (GND) pin on the Arduino next to pin 13.
All of the ground pins on the Arduino are connected so use which GND pin is most convenient.
These two circuits now share a common ground allowing us to add some servos.
2) Connecting Individual Servo Power
Next to this you can see that I have added a green jumper from the battery pack ground rail to pin1 of the header, this is the shared ground between the Arduino, battery pack and servo.
Next I have added a yellow jumper from the power rail - 6 Volts from the AA Battery pack - to the center pin of the header. This will provide power to our servo directly from the AA Battery pack, not from the Arduino or its 9 Volt PP3 Battery.
The final pin is the signal pin, this is the pin which the Arduino will use to tell the servo which position to hold.
Remember - Without the common ground between the Arduino and the Servo AA battery pack, your project will not work. In the picture, this common ground is provided by the black wire linking the ground rail of the breadboard with the GND pin next to pin 13 of the Arduino.
3) Adding a servo
All we need to do now is connect our first servo -
You can also see that I have added headers for three more servos following the same convention of yellow for 6Volt power from the AA Battery pack and green for the shared Arduino/AA Battery pack ground.
The servo is receiving its position signals from the Arduino through the white jumper wire connected to pin 13. Remember - Without the common ground (black wire) connecting the Arduino GND Pin to the ground (-) fo the battery pack through the black ground rail of the breadboard, this will not work !
If you have uploaded the multi sweep example sketch linked at the end of this post, you should see your servo sweeping back and forth.
4) Adding more servos
Once you have one servo up and running, you can add more by following the same convention - connect the servo plug to the header so that the end with the black wire attaches to the header pin with the green wire. You can then add a connection from the signal pin to any of the Arduino digital pins 2-13 and you should see your additional servos follow the same sweeping pattern as the first servo -
For the 'Multi Sweep' example sketch used in this video see the post - Can I control more than X Servos with an Arduino ?
The Arduino can control large numbers of servos without additional hardware provided a separate power source is dedicated to the servos.
Four AA disposable or rechargeable batteries are a good choice for providing this power in smaller projects.
Large projects will require hobby batteries or fixed power supplies, part 2 will look at some of these options and the power demands of the test servos under a variety of loads.
Servo models used and current drawn at no load -
Servo Current mA