Servo Driver with BBB PRUs

De Wiki LOGre
< Driver de Servos sur PRUs BBB
Révision de 20 juin 2016 à 12:29 par Fma38 (discuter | contributions) (Code)

(diff) ← Version précédente | Voir la version courante (diff) | Version suivante → (diff)
Aller à : navigation, rechercher
Language: Français  • English

Project done by fma38.

Work in progress.

Please, refer to the french page for more details.

Presentation

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.

Specifications

  • 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

Code

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 https://github.com/fma38/BeagleBone/blob/master/servos/python/servosPRU.py.