Control of several independent servos ?


Just a small question of principle relating to the control of several servos.

My project (Radio control application) is to read 9 pulses (8 + 1), separated by 22msec, on an input of the Picaxe and position "firmly" 8 servos according to the values read.
The ninth pulse (of a predefined and invariable length) causes a return to the beginning of the program to restart the sequence of the 8 successive positioning.

The question is simply to know if it is possible, with a Picaxe (and which one) to position 8 servos in this way and, above all, to keep the position "with force"; that is, if it is mechanically solicited, it will resist to stay in its position.
Or is it necessary to use and drive these servos with a driver circuit like PCA9685 (for example)?
Indeed, I imagine (maybe wrongly) that if the servo or servopos controls use a timer, it would be necessary to have a proper and independent one for each servo and I don't know if there is such a picaxe containing then these 8 timers.

Thank you, and I wish you a happy new year full of great Picaxe projects.


Senior Member
Pretty sure what you described is an ordinary R/C receiver, except your 22ms sync pulse is longer. Seperate servo signal are multiplexed sequentially, as you describe, and endlessly repeated after a sync signal. A Picaxe might be up to the task if nothing else is going on in the program, although waiting for and receiving the serial data string might interfere and cause servo jitter. Eight servos is the limit for using the simple SERVO command on a 20M2, but with more complex code you can use PULSOUTs. Many users go that route.

Many users report issues driving multiple servos smoothly using SERVO commands, but I had good results with six in my arm project below. I think power management is crucial for proper operation: a large battery that won't sag under load (forget alkalines) and beefy wiring. Worst case, use a seperate battery for the Picaxe to avoid interference.

Eight servos using SERVO commands:

16 servos on a similar processor, using PULSOUT commands. A 20M2 should do 15, since pin C.6 in input only.


Senior Member

AFAIK, a 20M2 can output 8 servo pulses with a repetition period of (only) 20 ms. An X2 is needed to set up a different "preload" period. The pulses are timed sequentially by a system interrupt set by an internal timer (T1 for the M2s). That interrupt is disabled by SERIN, SEROUT and SERTXD commands (which may produce very bad timing jitter), but the interrupts can over-ride PULSIN and PULSOUT commands, which may thus become corrupted (i.e. inaccurate).
My project (Radio control application) is to read 9 pulses (8 + 1), separated by 22msec, on an input of the Picaxe
But what is the nature of your "9 input pulses"? Are they 9 "narrow" pulses spaced by the required periods of the servo output pulses, all on the same input pin, or something else? Note that PULSIN is measured by a system software "counting" loop and requires a significant gap (at least 100 us) between the measured input pulses (on a single or on multiple pins). Similarly, all PULSOUT commands are created by a system software timing loop, so I don't believe that it is possible to use PULSIN and PULSOUT commands at the same time (even with M2's multitasking).

You might use the hardware PWM outputs, but there are (at most) only 4 separate PWM output channels, and also the PWM period cannot normally be set as long as 20 ms, even using PWMDIV64 (which is not available with some PICaxes). However, IMHO we really need an exact description of the full timing range of the "9 input pulses" to determine if what you want to do is possible with any single PICaxe.

Cheers, Alan.


Good evening Erco and AllyCAt.

Erco : Indeed, it is the decoding of what is called in radio control (that you seem to know well too) a Multi-Proportional module.
It is a module that replaces a potentiometer of the transmitter by 8 multiplexed potentiometers.
Each info relative to each of these "additional servos" is thus received, on the corresponding output of the receiver and interpreted by the decoder (here envisaged) every 9 x 22 msec.
( Note: My RC set has a longer period of 22msec as opposed to the standard 20msec).

AllyCAt : Here is the principle: (See attached diagram)
A sync pulse of 2msec allows to start again at the beginning of the program to assign the positions of the servos in order from the first to the eighth.
Then, every 22 msec, the pulses related to the positioning of the 8 servos follow.
They are from 1 msec to 1.8 msec. (to distinguish from the 2 msec sync top!)
No doubt that a quartz will help the accuracy of the measurements.

The idea is therefore to :
1_ First read the input pulse (Pulsin).
If Pulsin = 2 msec, we are back at the beginning of the program.

2_ Next: Pulsin of the pulse that determines the position of servo 1.
The next infomation of servo 1 will however only return in 9x22msec.
2bis_ Therefore, the position value of S1 must be renewed every 22 msec within this time.

3_Then do the same for the positioning pulses of servos S2 to S8... until the new Top Synchro and start the sequence again.

I see indeed that some use either servo / servos or Pulsout commands!?
What do you think is better in my case?

I agree that a separate filtered power supply is needed for the Picaxe.

So, finally, is a Picaxe capable of meeting my "specifications" here?
If so, which one?
Would you have any other practical recommendations.
Thanks in advance.



Senior Member

Ah, so you are only transmitting one pulse in each frame of 22 ms. Therefore the program loop for each frame can probably be one PULSIN followed by 8 PULSOUTs , but each channel pulse will be updated only 5 times each second. However, the additional execution (or decoding) time of each instruction is significant, so I think you will need to use a clock frequency of at least 16 MHz, which I'll assume here. This means that all pulse widths need to use Word variables.

Note that a maximum of 1.8ms is unusually short for a servo pulse, normally it is assumed to be 2.25ms (but then it would be difficult to fit 9 into a 22 ms frame). PULSOUT can be used on almost any pin so a 14M2 might be possible, but probably better to plan for a 20M2, which could be replaced by a 20X2 if necessary.

A PULSIN (or PULSOUT) for 1.8 ms actually takes almost 2.0 ms (@16MHz) to execute, so 9 alone could take up to 18 ms. Then you have only 4 ms for "housekeeping". Untested, but the following might work:
#PICAXE 20m2
  PULSIN c.0 , 0 , w0
LOOP UNTIL w0 > 760     ; 1.9 ms @ 16 MHz
  bptr = 2            ; Low byte of w1
  PULSIN c.0 , 0 , w0
  w0 = w0 MAX 800     ; Safety trap
  w10 = 800 - w0      ;) Maybe unnecessary as the "22ms" output periods will be affected by width of previous pulses anyway
  PAUSEUS w10         ;) Constant delay after sync
  @bptrinc = b0       ; Copy pulsin to the correct channel word from w0 (i.e. b0 : b1)
  @bptrinc = b1
  PULSOUT b.0 , w1
  PULSOUT b.1 , w2
  PULSOUT b.2 , w3 
  PULSOUT b.3 , w4
  PULSOUT b.4 , w5
  PULSOUT b.5 , w6
  PULSOUT b.6 , w7
  PULSOUT b.7 , w8
  IF w0 > 760 then GOTO sync         ; Re-synchronise if necessary (optional)
LOOP UNTIL bptr > 19                 ; bptr = 18 and 19 (w9) should be the sync pulse width
  GOTO sync                          ;  Next pulse should be the sync
At power-up, w1 - w8 are set to zero, so no pulse should be output until a value is written from w0. However, there may well be "glitches" if the synchroniation fails for any reason.

Cheers, Alan.
Last edited:


Thank you Alycat for your very interesting thoughts.

Indeed 1.8 msec is unusually short for a conventional servo but as the "full range" of possible pulses delivered by the transmitter ranges from 1 to 2 msec, one has to choose one of the ends well to differentiate the 2msec top synchro.
I think you could even go to 1.9 msec (for the extreme servo position) if the Picaxe is very accurate in its measurements.

It might also be possible to apply a small processing calculation to restore a full range for the servo. I'll think about it in the second period of my tests but I think it would slow down the processing speed of the loop too much.

Yes, that's understood: (nothing better than a little diagram) the idea is to read each pulse every 22 msec and, while waiting for the next one, send 8 "maintenance" pulsesout until they start again, as soon as the Top Synchro is received.

The refreshment of a real new position will only be effective after 9x22msec = 198 msec. (1/5 sec)
This will result in a slight delay in relation to the control movement of the potentiometer on the transmitter.
This is unavoidable but not very restrictive for a modeller who, thanks to this additional system, has the possibility to increase the number of servos controlled in proportional mode.

I had already started to think and conclude that it was obviously necessary to use an "indexed variable" (servo n, n+1, ...) which is possible here with the Picaxe by using the Scratchpad.

The use of Pulsout also seems more appropriate than the "servo" command.
(So what is the purpose of this servo command?)

I'll test your Code by the week.

Do you think it would be necessary to use a quartz to stabilize the frequency and thus allow a reliable reading of the top synchro which is here very close to the maximum position of the servo?

Thanks again for your usual responsiveness!


Senior Member
Do you think it would be necessary to use a quartz to stabilize the frequency and thus allow a reliable reading of the top synchro which is here very close to the maximum position of the servo?
The maximum pulse width that the servos will accept is not the most useful thing to know to write this PICAXE program.

A more important thing to know is the maximum servo pulse width that will be output by the Multi-Proportional module that you are using.

Do you have a link to the manual for the Multi-Proportional module so that we can see if it specifies the maximum servo pulse width?


Technical Support
Staff member
The use of Pulsout also seems more appropriate than the "servo" command.
(So what is the purpose of this servo command?)
The servo command is useful for those who do not want to get into the complexity of handling pulse out loops and framing timing.

Do you think it would be necessary to use a quartz to stabilize the frequency and thus allow a reliable reading of the top synchro which is here very close to the maximum position of the servo?
I would not have thought so. There is 200us between 1.8ms and 2ms so, with 10us resolution for PULSIN one should be able to determine the difference even with an internal clock.


Indeed, it should be accurate enough with the internal oscillator.
The maximum servo pulse length is 1.8msec (could even be increased to 1.9msec) and the top sync is 2msec.
And as the program was written specifying a frequency of 16Mhz (Setfreq m16) the pulsin/pulsout resolution is actually 2.5us (not 10us). Right?
Let's try it all.
Last edited: