Arduino with 12 servos

I am planning to use my Duemilanove with 12 servos (which should be possible?). I am a noob when it comes to Arduino and electronics but I have come to understand that in order to do so I must feed the servos with an external power source. Is this correct? If so then can I just connect them directly to a battery or do I need to build a power circuit (voltage regulator, capacitors etc.)? If so how do I do that most efficiently? Like what capacitors to use etc.? Perhaps a circuit diagram..? :slight_smile:

I also realized that the cables will get quite messy with the current pin setup on the board, so I wanna make a mini servo shield that turns my Duemilanove into a sort of RoboDuino.

www.curiousinventor.com/kits/roboduino

So (with the help of a class mate) I will make a PCB with pins on them, on one side to plug into Duemilanoves I/O's + Ground, and on the other side having tripple pins (signal, power, ground) for the servos.

Here is a quick and dirty drawing:

www.uploadgeek.com/share-3730_4A98A137.html

I understand that the external ground must be connected to the Arduino ground, right?

Is this a viable idea at all?

.......:.. Aniss

The servos are designed to run off batteries, so powering them from one will be fine, as long as you pick the right voltage (e.g., 4 or 5 NiMH cells in series).

Yes, you need to connect the grounds.

If you're going to have many servos moving simultaneously, make sure the power traces on that PCB are nice and fat, especially if they're "heavy duty" models: people are often surprised by how much current they can draw.

Make sure you research people's experience with running many servos at once, because you'll need to use the software-generated servo output library. I've only used a couple at a time, so I don't know whether there might be surprises for you running 12.

Ran

Thanks for the input :slight_smile:

And yes I am researching as much as I can about running a lot of servos from 1 Arduino. This guy seem to have done it without too many problems:

www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1192268788/0

About the "software-generated servo output library"..are you sure that is the case? Since the recent (2009.07.25) release of Arduino software version 0017 this should no longer be necesary:

arduino.cc/en/Main/ReleaseNotes

  • Replaced the Servo library with one (MegaServo) by Michael Margolis. Supports up to 12 servos on most Arduino boards and 48 on the Mega.

Or?.....

And yes I was planning to power it with 4 AA NimH batteries (1.2v each). But while building and programming it (the robot) I thought it would be prudent to power the servos with an ac/dc adapter like for example:

www.seeedstudio.com/depot/wall-adapter-power-supply-65vdc-2a-p-413.html

So it seems I have to make some kind of power circuit anyway. I've been researcing on that a bit and it seems I have to use a voltage regulator and 2-3 capacitors (sometimes more or less?). But the circuits I've seen are typically used to power homemade Arduino boards. Powering 12 servos is somewhat different.

So I wanna ask if anyone knows a good setup for powering 12 of these servos:

www.seeedstudio.com/depot/towerpro-airplane-9g-sg90-mini-servo-p-448.html

What kind of capacitors should I use? And how many? How should I build this circuit to get a good result?

Is it even necesary to build this circuit or is an ac/dc adapter stable enough to connect directly to the servos?

For that size servo you will need at least 500ma per servo for a peak load of 6A. I hooked a couple of mine up and ran them at full load @6V on a servo test board I have. :exclamation I would recommend using batteries for the servos unless you have a power supply capable of handling the necessary current plus some for safety.

Thanks for the input..

Using battery during the entire bulding/programming process is something I would VERY much like to avoid. So if I can buy an adapter that supplies the necesary current I will do that.

I just need to be sure WHAT to buy.

You say I need 500mA (=0.5A) for each servo? Therefore 0.5A x 12 = 6A (plus some for safety). So if I buy an adapter that suplies 8A - 12A (4.8v-6v) I should be good to go?

No voltage regulator or anything necesary?

For that size servo you will need at least 500ma per servo

Are you sure about that? That seems high for a 9g "sub-micro": it's more like what I've seen on standard-sized ones. But I haven't tried "stress-testing" them at absolute maximum loads, so maybe that's the difference.

Aniss: to properly pick your power supply, you really need to consider what your system will be doing with the servos in action. If you're only going to be moving one or two at a time, you can get away with a much lower current rating. If you're building something like a robotic arm, that will be doing complex motions while holding a load, you need to make sure you can power most/all of the servos simultaneously.

Since you're planning on a 4-cell NiMH pack, you should look for a 5V supply, so the system will work much the same way on the bench as it will in "real life".

You should get a regulated supply (and switching supplies are regulated), because unregulated supply outputs vary hugely depending on how much current you're drawing from them.

In your position, I'd go looking for a surplus 5V supply, either linear or switcher, that's rated for a lot more current than you expect to need. That will avoid unpleasant surprises (like smoke ;D), and leave you with something you can use to power future projects when this one is done.

Ran

I definately plan to avoid smoke and the likes :slight_smile:

About the TowerPro peak current draw:

I believe I've read that the peak current draw of a STANDARD sized servo is around 1A. I've also read that these small servos draws quite a lot of power relative to their size, so perhaps 500mA isn't so far off anyway?

However I haven't so far found anything precise about this particular servo's peak current draw. But I did read that a guy tested the pretty much identical servo HXT900 and measured a peak current draw of 750mA:

I read elsewhere that the AVERAGE current draw of that same servo is 550mA:

www.hobbycity.com/hobbycity/store/uh_viewItem.asp?idProduct=662

BUT...I also remember having read that it was only 250mA (don't remember where though)...

Anyway I'm a bit confused. I'll do more research later. All inputs are still highly appreciated :slight_smile:

And about the robot:

It's a walking/balancing robot and it would be nice if I could move (up to) all servos at once. It's gonna be VERY light. I plan to use plastic and tape whenever possible in it's construction. Still there will be SOME load due to the robot's body weight, but I don't intent to let it carry a lot.

Aniss

Ah here is where I read that the HXT900 peak current draw is 250mA:

...Just to add to the confusion. :S

And about the adapters:

I've been googling them quite a bit and it seems that it's hard to find much higher than 6mA like this one:

www.directron.com/ky05072.html

And even that's a bit expensive. I was hoping for a somewhat cheaper solution, since I live in Argentina and electronics are more expensive here. I actually paid 47 us$ for my Duemilanove board (for example). :frowning:

Anyway 6A may not even be nearly enough???

Ok here is a follow up on my research...

A french guy tested 164 servos thoroughly and made a windows application. Unfortunately it's in french. However he also tested the TowerPro SG90.

The program can be found here:

www.teaser.fr/~osegouin/aeromode/servos.phtml

Click the link saying: "Téléchargez le programme et la base de donnée V2.2 de Mai 2007" at the bottom of the page to download the program (if you're interested).

Here is a screendump of the program showing the data for the TowerPro SG90:

With my limited knowledge of servos and poor french I have deducted that the SG90 will draw max. 700 mA at 5V and 835mA at 6V.

However it also seems that the general performance of the servos increase a lot when running 6V?! Didn't know that either..learning a lot these days :slight_smile:

I looked up some of the words I didn't understand:

Couple = torque
Vitesse = speed

But I could not figure out what this means: "Tps de positionement (moy)"?!

However it has to do with speed/positioning and the performance running 6V is almost double than when running 5V (78% vs. 42%). Perhaps something I should consider too?!

Anyway I'll end up running 5/6V and 12A (or something).

So know I wanna ask:

  1. Is that at lot of current for a PCB (even with extra fat lines as Ran suggested earlier)?

  2. How will the Arduino board react to 12A (perhaps 6V) when I connect the two grounds?

  3. Could it damage the servos (if for example only one servos is connected will it be "overfed")?

  4. Other posible problems due to this setup?

  5. Should I choose 5V or 6V...pros and cons?

  6. Any good shopping suggestions for 5-6V 12A adapters (tried to look for a surplus one like Ran said but couldn't find anything suitable)?

700ma is with a torque of almost 500gm cm, at half that torque the current drops in half. You may want to factor in what the average load on all your servos will be.

  1. fat pcb traces should be ok for these servos

  2. The Servo current will not be flowing through the arduino board .

  3. no (as long as the power supply is regulated so the voltage never goes higher than 6 volts)

5 volts gives faster performance and more torque at the cost of shorter servo life

  1. I would guess that you won't actually need 12A for those servos. You could use a surplus computer power supply for testing and see how much actual current you need. A search on google should turn up a number of articles that explain how to turn on old computer supply into a high current 5v bench supply.

“Tps de positionement (moy)” is Average Positioning Time

Thanks a lot for the info, mem!! :smiley:

I am aware that the 12A is the THEORITICAL MAXIMUM plus quite a bit. And that's the point. I wanna be well on the safe side. It's impossible to predict the actual servo load in all situations, but I figure that there may be situations where the robot gets stuck and stalls on (up to) all servos. So 12A sounded like a safe bet.

But I'm intrigued by your suggestion to build my own power supply from a cheap computer power supply and I checked the net for examples. It doesn't look TOO hard even for a noob like me. And they are extremely cheap and some are even quite sexy:

And I found several articles about the subject. In particular these seem thorough:

http://web2.murraystate.edu/andy.batts/ps/powersupply.htm

But if I go through the trouble to build one of those it would be to have a permanent solution.

And perhaps it is just a bit too powerfull (seemingly minimum 145W), and therefore needs a fan. Perhaps I would be better of with a similar cheap'n'dirty solution: I could buy a "raw" supply like one of these with a max output closer to my actual needs and maybe avoid the fan?:

shop.iiic.hk.cn/index.php?main_page=product_info&products_id=3326&zenid=6hjjvodva2m66f6u44tpsmevv7

www.powersupplydepot.com/productview.asp?product=17432+PS

But perhaps I'm just supposed to add the fan myself? I'm not sure at which currents the fan becomes necesary. Though I did find this one on the net:

www.trademart.in/product-JLTA251_jlt017.html

...Which would kinda be the optimal solution. And it shows that it IS possible to run 5V/12A WITHOUT a fan involved. Only I haven't been able to find anyone who actually sells these things ....

Anyway thanks for all the input Ran, kmackaero and mem.... :slight_smile:

i probably missing something now, but the Duemilanove only have 6 PWM = controlling 6 servos.
but as i said, i probably missed something out ::slight_smile:

i probably missing something now, but the Duemilanove only have 6 PWM = controlling 6 servos.
but as i said, i probably missed something out

The Pulse Position Modulation (PPM) signals required for driving (up to 12) servos is produced using one of the Arduino hardware timers. Pulse Width Modulation (PWM) is not used in the latest Servo library code.

There is more detail on servo signals in this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232572239

Aniss, the 8 amp Metapo power supply for $14.95 from powersupplydepot.com is what I would go for. This is a switching supply so will not dissipate very much heat and I would think that you will not need a fan.

8 amps should be more than enough current. Servos draw current in pulses and the latest Servo library spreads these out so the average current will be much less (perhaps half for your servos) than the total theoretical peak. I would guess that if each of your servos does draw 700 ma peak, the actual current drain will be under 5 amps.

After looking at this page, I can see that my testing setup was not good for catching peak currents, so my estimates are low because I was seeing something closer to average values.

It appears (to be confirmed) that I had a misunderstanding of how RC servos work: I thought the motor would come on continuously until it reached the target position, but the waveforms on the above page suggest that that's not true.

If it's true that the motor is only being "pulsed" in sync with the servo signal, you could reduce the peak demand by changing the phasing of the servo pulses. E.g., by starting the servo pulses for the first six at the 0mS point in the cycle, and the other 6 at the 25mS point, you could cut the peak demand in half.

I did a little google research trying to confirm/disprove this, but didn't have any luck. I may have to build an improved test setup and check it out myself.

Ran

Just so you know: I've been buying surplus by mail order from MPJA (Power Supply Depot) for many years, and also dealt often with the Excess Solutions folks at the electronics swap meets back when I lived in Silicon Valley.

They're both good companies, and I wouldn't hesitate to buy from either.

Given the costs of shipping, though, I would definitely suggest you look for an old AT-style PC to scavenge a power supply from first. An AT is better than an ATX because you're more likely to find one for free, and its main output will be 5V, instead of 3.3V.

Ran

I was kinda getting hot on the idea of building a general purpose robotics lab bench supply out of this little fellow (or similar). This little 145W micro ATX supplies 5V-(up to)14A and goes for (down to) 11 us$. :slight_smile:

www.ez-mart.net/product_info.php?products_id=529

On the other hand I probably wont need the 14A or the other voltage outputs..and I definately don't need a fan :-/...so let's see..tomorrow I'll go check the local (Buenos Aires) marked and see what I can come up with ......

I will study mem's explanations more thoroughly later:
www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232572239
www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230479947

But they seem (after a short look) to correspond to my understandings. The servos are not controled by PWM but a simple digital signal of highs and lows where the distance (in ms) between the high-low shifts determines the servo position.

The PWM pins are digitally "simulated" analog i/o's used for controling the SPEED of continously rotating dc moters, or receive analog inputs.

Anyway that how I'd understood it...

And to mem:

Isn't it correct that since the newest arduino release one can use the STANDARD servo library (servo.h) to control up to 12 servos?

arduino.cc/en/Main/ReleaseNotes

  • Replaced the Servo library with one (MegaServo) by Michael Margolis. Supports up to 12 servos on most Arduino boards and 48 on the Mega.

Ran, I had a quick look at the current pulses on an HXT900 servo and got similar results to the trace in the link in your post. The motor current is a pulse of around 700ma for something like 40% of the time. This would imply an average current of around 350ma for a single servo when moving. Two servos moving present a complex waveform but my very quick tests indicate that the average current with 12 servos looks like it would be under 5 amps. When the servos are stationary but under load the pulses are only around 2ms long so the average total current in this case would probably drop down to under 1 amp.

The current Servo library is based on the MegaServo code and this does pulse each servo in succession so no two servos are pulsed at the same time.

I only have two of the servos HXt900 (aka TowerPro 90) servos so can't do a definitive test but I would guess that 5 amps power supply would probably be sufficient and an 8 amp supply would give extra headroom.

Isn't it correct that since the newest arduino release one can use the STANDARD servo library (servo.h) to control up to 12 servos?

That is correct (I wrote the Library)