Page 1 of 1

Multi RC (Futaba) servo control by CCP

PostPosted: Mon Oct 14, 2019 4:39 pm
by Ian.M
First, a quick primer on RC servos (not to be confused with DC servomotors) for the uninitiated:
TLDR: one needs to generate a 5V high going pulse of between 1 ms and 2 ms repeated every 20ms. The pulse width controls the servo position.

Back in 2014, over on the Microchip forums, I posted code to run a single RC servo from a midrange PIC (E)CCP module, with jitter-free, cycle accurate edge timing. I've just extended it to control eight servos independently with only a single 74HC238 3 to 8 line active high decoder to deMUX the signal on the single CCP pin to feed separate servos. C Code to run on a PIC16F88 at:, #16 in the topic. It should be reasonably simple to port to any other PIC with a 'classic' (10 bit PWM) ECCP or CCP module.

Wiring: CCP1 (RB0) to '238 E pin, both '238 /E pins grounded and RB1-RB3 to '238 A0-A2 respectively. Connect servos to '238 Y0 -Y7 outputs starting from Y0.

I also have an idea for nine servos using only a CCP output and ONE extra I/O pin, using a CD4017 decoded decade counter, but haven't done any code development yet.

N.B Servos require *LOTS* of current when they move, so if you use the same supply for the PIC it will probably brown out and reset if you command a rapid change of position.