Let's Make Robots!

Arduino 20 Servos, 4 Pins, Variable Refresh Rate


Some time ago I posted a library for running ten servos from an Arduino using just 2 pins. I have extended it to 20 Servos from 4 pins.

The library has a variable refresh rate determined by the number of servos, servos can be split across two banks for higher refresh rates.

Original 10 Servo library with all the background here -

http://rcarduino.blogspot.com/2012/08/arduino-serial-servos.html

New version with support for split banks for higher refresh or just more servos here -

http://rcarduino.blogspot.com/2012/10/arduino-serial-servos-20-servos-4-pins.html

Duane B

http://rcarduino.blogspot.com

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
merser's picture

Thanks Duane for sharing this. I know I've seen a number of people discussing here making a servo controller from a micro and will find this information useful.
I don't think I've seen you mention it here about your gig over at microcontroller central but I've enjoyed reading your posts over there. Sorry for spoiling your anonymity if that was your intention.
But we are a bit micro centric here anyway.
Collected.

Hi, I had to look up microcontroller central and then search for a Duane. While I am Duane B, I am not Duane Benson.

Duane B

merser's picture

Sorry about the confusion there. I'm not sure how I came to that assumption now other than similar names I thought I'd seen Duane Benson talking about a project similar to what you'd been working on. An rc beetle I think it was. But I've got my wires crossed, please excuse me for the error.
It doesn't take away from the usefulness of what you've posted however.

I Guess I should be flattered to be taken for someone with a lot more background than I have.

Thanks

Duane

NilsB's picture

It's always great to learn more about the people behind their acronyms - especially if they have such a massive background like Duane.

OddBot's picture

I like what you've done but there is an existing device that you may want to look at before you re-invent the wheel any further.

The PCA9685 is an I2C controlled, programmable PWM generator with 12bit resolution that was originally designed for LED control. Adafruit have already turned it into a servo controller and have a library for it.

This allows your I2C port to control up to 992 servos with only 2 pins and very little processing power. With 12 bit resolution this is a nice solution.

Hi, If you can tolerate the usual micro controller ticks, the library here will get you 20 servos on a standard Arduino with just 2 additional 30 cent components.

The device you mentioned will ( I assume it does, bit pointless if it doesn't) get rid of these ticks for 16 servos at a cost of 15 dollars. I recon an ATMega168 based Arduino can be built for 5 dollars and will support 18 servos with the library I will release next week. Its not a massive saving and the library is just a faster servo library, I have not added any coms and I am in no rush to reinvent the wheel but if someone wants to build an Arduino servo controller its a cost effective option and the new library will get you on the right path quickly.

Duane B

rcarduino.blogspot.com

OddBot's picture

I'm not sure what "ticks" you are refering to. When I have had my Spider controller on a 100MHz digital oscciloscope there werre no glitches in the signal. It may depend what other code you are running as some libraries use timer interrupts.

Adafruit might charge $15 but you can buy the chip for far less.

Hi

I am generally running servos in the same projects that I am also reading RC Signals. The RC Signals generate around 700 interrupts per seconds, thats on top of the arduino time (micros/millis) interrupts and the servo library interrupts. When this lot all try to happen in the same instant you get ticks. Here is a link with more details and what I have done to overcome it -

http://rcarduino.blogspot.com/2012/11/how-to-read-rc-channels-rcarduinofastlib.html

Duane B

Bajdi's picture

Interesting stuff, looks ideal for a hexapod. To bad I already bought a 32 channel serial servo controller. This looks a lot cheaper. Thanks for making the library :)