Combined Brake and Reverse
This feature implements a common RC car braking system. When enabled (via drvopts bit 0), negative input first results in braking. To reverse, release the input (enter the center deadzone), then apply negative input again.
This feature is enabled by setting bit 0 of drvopts.
Setup
- Enable the feature by setting
drvoptsbit 0 - Map your control input symmetrically (either analog or servo PWM) by setting an appropriate center:
- Set
/pwm_input/centerto1500and/or/analog_input/centerto2500
- Set
- Configure driver modes for each operational state:
- Set
ctl_modefor forward drive (e.g.,2for current/torque mode) - Keep
ctl_brake_modeat8for braking - Set
ctl_reverse_modefor reverse (e.g.,3for voltage with freewheel)
- Set
State Machine
The combined brake and reverse logic uses a three-state sequence:
- State 0 — Forward or idle. Negative input transitions to State 1 (braking).
- State 1 — Braking. The driver uses
ctl_brake_mode. Releasing input (returning to zero) transitions to State 2. - State 2 — Reverse ready. Negative input now drives in reverse using
ctl_reverse_mode. Positive input returns to State 0.