Drive up to 10 Servos with just 2 Arduino Pins



I've been building both AutoPilots, and QuadCopters, and I wanted to drive more servos and Speed Controllers with less jitter. So I used some ideas from the Paparazzi gang and developed a way to drive up to 10 servos with just 2 output pins from an Arduino or ATMega8.

The design uses just one chip, a Johnson style Decade Counter, and requires only two output pins from the Arduino. The Arduino uses one PWM pin (pin9), and one general IO pin (pin8). All the pulses are generated in sequence on the PWM pin, then spread out to the individual servos via the decade counter. The decade counter costs 63 cents.


Now I can build Hex-Copters without having to use I2C ESCs, and still have servo outputs available for camera controls.

Click here to download source code for Arudino
Click here to download source code for AVR and ATMega8 chip.

Another issue has been jitter and resolution. The QuadaCopter project is using AnalogWrite to control the Speed Controllers and has limited resolution. (about 120 steps of resolution) With my design, I have over 1000 steps of resolution, with no jitter, and, because I've moved all the servo interrupts to a second processor, the R/C Radio Input interrupts are more accurate as well. Smoother, less noisy input timing plus smoother output timing equals smoother flying.

I've built two versions of the servo driver: one connects directly to an Arduino or ATMega8 chip and uses interrupts within the chip to drive the servos. The other uses the SPI serial interface to completely separate the servo driver from the host CPU, to free up output ports, and remove the high speed interrupts from the host CPU.

For the QuadraCopter, I use a second Arduino Mini to drive the servos. It communicates with the master Arduino via SPI. I'm using a home built v1.7 shield (I just hand wired the sensors using an Arduino ProtoShield) Since the sensors use all the Analog input lines, I couldn't use I2C (I2C uses A4 and A5) so I chose SPI. Worked out great. Port D is used for radio input interrupts, Port B is used for SPI, and Port C is used for Analog inputs. Very clean. It simplified the code, and smoothed out all the interrupts.


Back to Pete's Robo-Page