4 or more servos on an Arduino

roboduino

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.

Comments

  1. nathan says:

    I didn’t know I was limited to 2. Here I went and made things that use up to 6 servos.

  2. thethirdmoose says:

    Doesn’t the Atmega168 have 6 PWM outputs?

  3. Rivetgeek says:

    er… ive never used less than 4 servos already…whats new?

  4. jastreich says:

    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.

  5. clinton says:

    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!

  6. macegr says:

    I prefer to run one million servos on my arduino…that’s just how I roll.

  7. grythumn says:

    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.

  8. Dan Fekete says:

    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
    manual: http://www.lynxmotion.com/images/html/build136.htm
    source code: http://www.lynxmotion.com/images/html/proj078.htm

  9. WestfW says:

    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…)

  10. Dan Fekete says:

    @WestfW

    Thanks, that cleared it up. pretty damn clever.

  11. fartface says:

    Um huh? I’ve used 6-12 servos at a time with arduino.

    Who in the world though you could only use 2???

  12. itdaniher says:

    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.

  13. DarkFader says:

    Oh noes. Arduniusers are gaining on us.
    I wonder how well it works together with eeprom writes.

  14. Eric says:

    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

  15. WestfW says:

    > you can literally just plug in servos
    Watch the power consumption though. It’s still only got that 500mA (max) regulator…

  16. biojae says:

    >WestfW
    >It’s still only got that 500mA (max) regulator…
    if you look at the schematic it uses vin not the 5v from 7805

  17. Linux Circle says:

    Here is how you can control multiple servos without PWM library or PWM pin

    http://www.linuxcircle.com/?p=640

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 96,725 other followers