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).
Both the I2C bus handle and the OE GPIO live inside the wrapped device process, so
disarm/1 can only reach the hardware while the controller process is alive. If the
controller has crashed or is wedged, the disarm call fails and returns
{:error, reason}, driving the robot into the :error state rather than falsely
reporting success. For a hardware-independent kill that survives a dead controller,
wire an :oe_pin: a clean controller shutdown pulls it high via the device's
terminate/2.
Summary
Functions
Disable all servo outputs by pulling the OE pin high.
Functions
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. If the call cannot be delivered the
hardware cannot be made safe, so {:error, reason} is returned (driving the
robot into the :error state) rather than a false :ok.