BB.Servo.PCA9685.Controller (bb_servo_pca9685 v0.5.0)

View Source

A controller that manages a PCA9685 PWM device.

This controller wraps a PCA9685.Device process and provides an interface for actuators to set servo pulse widths. Multiple actuators can share a single controller, with each actuator controlling a different channel (0-15).

Configuration

The controller is typically defined in the robot DSL:

controller :pca9685, {BB.Servo.PCA9685.Controller,
  bus: "i2c-1",
  address: 0x40,
  pwm_freq: 50
}

Options

  • :bus - (required) The I2C bus name, e.g., "i2c-1"
  • :address - (required) The I2C address of the PCA9685, e.g., 0x40
  • :pwm_freq - PWM frequency in Hz (default: 50, suitable for servos)
  • :oe_pin - Optional GPIO pin for output enable control

Safety

This controller implements the BB.Controller behaviour. When the robot is disarmed or crashes, the OE pin is pulled high to disable all servo outputs. If no OE pin is configured, the disarm callback returns :ok (individual actuators handle their own channel disarm).

Summary

Functions

Disable all servo outputs by pulling the OE pin high.

Functions

disarm(opts)

Disable all servo outputs by pulling the OE pin high.

Called by BB.Safety.Controller when the robot is disarmed or crashes. If no OE pin is configured, returns :ok (individual actuators handle their channels).

Note: This callback calls through the Controller GenServer, so it only works if the Controller process is still alive. For crash scenarios, individual Actuator disarm callbacks provide per-channel safety.