17 years ago
I've been doing lots of tests with controlling R/C servos lately, some good
experiences and some bad experiences. I even wrote an introduction paper on
how to interface the PC with R/C servos using the serial port and a PIC
The strategy I present in that paper is very basic, and although it works
fine, it is kind of jittery and does not support too many servos. Now I'm
working on a improved version of my servo controller that will theoretically
get rid of the flicker and support unlimited servos (in theory).
I am a firm believer that the best way to learn something is to teach it.
Therefore I will try to make another paper exposing this new method (of
course, if it works). Before doing that, I need to know if someone else
already did such tutorial paper, and if yes, if it is similar to my
Here's an outline of my strategy, please express yourself if you find a flaw
in it as I'm going to test it tonight.
1-Assume there is an array of servos controlled by the uP
and this array has the following fields:
servo_idx, pulse_width_uS, servo_no
Whenever the array is updated (through serial commands), it is
sorted in by pulse_width_uS
2-Drive all servo lines high, set TMR0 with the time interval
of the first servo of the array
3-When TMR0 triggers, set the respective servo low.
Also set low all the subsequent servos from that list that
have the same pulse_width_uS. Set new TMR0 interval
as the difference between next servo pulse width and current
4-Repeat this operation for all servos until there are no
more servos to drive low. At that point, set TMR0 with
20ms - current pulse_width_uS
And that goes forever. There are a couple more quirks to it, but that's the
overall outline. If you are controlling 4 servos, TMR0 should trigger 5
times in the worst case, 1 time for driving all servo lines up and 4 times
(less if some of them share the same time interval) to drive them low.
That gives me lots of time in between pulses to do whatever I want (receive
USART bytes for example) without interfering too much with the PWM timing
Do you think it is a good approach to try? If yes, do you think it would be
worthy to write a short paper on that?