Servo Driver (Standard, Continuous, High-Speed)

Here is a driver for up to 64 servos. Does not support feedback servos. 50 Hz controls. Uses mode 4 smart pins.

The demo builds a table of pin numbers, one for each servo. It then calls start(NumberServos, @Table), which starts a PASM2 cog. This is the actual driver. It computes the period allocated to each servo (20 Millisec / NumberServos). It then fetches the pin numbers, builds an internal list, and defaults the pulse width to 1500 microseconds. The pulse width occupies the same table that was used to pass the pin numbers; the user program can vary the pulse width for any given servo by simply writing to the table. The PASM driver cycles through the list every 20 milliseconds, using the pulse width values supplied by the user program.
The screen shots show pulses supplied to 6 servos. SixServos shows the case when a total of six servos are driven; the pulses are distributed over the 20 millisecond period. FiftyTwo servos shows the case where 52 servos are being driven; the six (adjacent) servos are grouped together and overlap a lot.

Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
Sign In or Register to comment.