The latest version of the Arduino software allows you to use more than two servos at a time. Curious Inventor has posted a demo showing how to run 4 servos from a keyboard input. The code should also work just fine on Arduino clones, like the Roboduino pictured above. They point out that if you are running version 12 of the software, some manual additions will be necessary.
17 thoughts on “4 Or More Servos On An Arduino”
I didn’t know I was limited to 2. Here I went and made things that use up to 6 servos.
Doesn’t the Atmega168 have 6 PWM outputs?
er… ive never used less than 4 servos already…whats new?
The Propeller from Parallax has objects (read: “drivers”) freely available that can run up to 32 servos from just one of it’s 8 ALU’s (nicknamed cogs).
Full Discloser: I have no formal association with Parallax… But I am a huge fan.
i ordered my first arduino last week to start experimenting with it and to eventually use it in a project for class. I knew it was designed for only 2 servos (that’s what the spec said), but I just figured I’d multiplex myself out of that situation.
thanks for the vid and the parallax recommendation!
I prefer to run one million servos on my arduino…that’s just how I roll.
On a similar note, I have AVR 8535 code around somewhere that reads pre-USB computer joystick / pedal / button inputs and converts them into a pulse train for the Futaba buddy box protocol.. lets you take a cheapo 4-channel TX and use all the available outputs (7, generally) on the receiver. Only mod I made to the TX was to replace the spring-loaded buddy-box switch with a throw switch. The main issue I had was that the range on standard R/C gear is only about half a mile.
Also, you don’t need individual hardware PWM for servo outputs.. use a single timer interrupt and a few bytes of RAM, toggle the output lines in the ISR. 1-2 ms pulses leave you gobs of time.
I’ve been using the Lynxmotion SSC-32 for a little while with one of their robot arms, and i’m still trying to figure out how they’re doing it with an atmega 168 what seems to be 4 shift registers.
Can anyone explain how you update 32 servos independently and still have time for serial IO? I get the whole isr w/timer interrupt, but how do you accurately vary the pulse widths in shift registers? I looked at the source, but the answer alluded me.
here’s some links:
product page: http://www.lynxmotion.com/Product.aspx?productID=395&CategoryID=52
source code: http://www.lynxmotion.com/images/html/proj078.htm
The default arduino libraries are rather conservative, it their efforts not to turn an arduino in something that does lots of servos but not much else. I don’t see any reason why an AVR can’t support, say, 8 servos (sequentially, just as if they were at the end of a radio link) associated with EACH timer. I didn’t look at the lynxmotion firmware, but… You shift a 1 into your shift register, and it appears on output 0 connected to servo 0. Wait the desired pulse width (set the timer to interrupt, if you want.) Shift the existing 1 to the next output/servo, and wait the time associated with it. And so on. You might have minor glitches if servos on two separate shift registers happened to have their pulses expired at exactly the same time, but those would be on other order of microseconds long out of a millisecond pulse (and you could probably avoid them with clever code…)
Thanks, that cleared it up. pretty damn clever.
Um huh? I’ve used 6-12 servos at a time with arduino.
Who in the world though you could only use 2???
in older versions of the arduino ide, you were limited to two servos controlled via hardware PWM – one on pin 9 and one on pin 10. there’s been a software-servo library around for awhile that’s allowed you to control up to 20. since v. 0012(?) of the ide, software-servo has been integrated into the ide.
Oh noes. Arduniusers are gaining on us.
I wonder how well it works together with eeprom writes.
The cool thing about the Roboduino board is that it has male headers and neighboring power busses, so you can literally just plug in servos and sensors and play.
Experience : Have a roboduino
> you can literally just plug in servos
Watch the power consumption though. It’s still only got that 500mA (max) regulator…
>It’s still only got that 500mA (max) regulator…
if you look at the schematic it uses vin not the 5v from 7805
Here is how you can control multiple servos without PWM library or PWM pin
Please be kind and respectful to help make the comments section excellent. (Comment Policy)