Servo Driver with BBB PRUs

De Wiki LOGre
Aller à : navigation, rechercher
Language: Français  • English

Project done by fma38.

Work in progress.

Please, refer to the french page for more details.


The idea is to control servos with the PRUs of the BBB, as does the Veyron Servo Driver from DFRobot or the SSC-32 from LynxMotion.


  • 32 servos
  • pulses :
    • range: 5 to 5000µs
    • résolution: 1µs
  • moving n servos during a given time (20ms to 20s)
  • communication with host via shared memory
  • endstops management:: 8 inputs, each one stopping a group of 4 servos


See github

PRU0 has 3 tasks:

  • generating fixes pulses widths
  • changing pulses widths of some servos in a sync way, so they start/stop at the same time
  • read inputs, and stop matching group of servos when activated

Communication with host is done through Data Memory. For 32 servos:

  • [0x00000000:0x0000007f]: current pulses widths
  • [0x00000080:0x000000ff]: increments
  • [0x00000100:0x00000103]: nb steps
  • [0x00000104:0x00000123]: inputs

Values are stored as words (4 bytes), in little endian order.

Pulses widths must be left shifted by 16bits. This is because we use 32bits for internal computation when incrementing, but only use the MSB 16bits for effective value. Increments are not shifted.

Changing current pulses widths values immediatly change servo position (no speed management).

Use value 0 to disable the servo.

To set new positions with speed management, set increments values for the given servos, and set nb steps (cf below for details). Setting nb steps starts move. While moving, nb steps is decremented by the PRU. Monitor it to know when the move ends (0), or wait for event.

nbSteps = delay / 20
inc = (((targetPulse) << 16) - currentPulse) / nbSteps + 1

Be carefull not to modify current pulses widths while moving!

Inputs act as servos endstops ; each input matches a group of 4 servos. When an input is activated, the increments of the matching group is set to zero. This is mainly used to act as multipod legs endstops.

The inputs values stored in memory can be read, but for now, are only refreshed during a move.

For more info, see