Core Concepts
PWM and Pulse Control
Most actuators use PWM (Pulse Width Modulation) signals:- Frequency: Typically 50-60 Hz for RC servos
- Pulse Width: 1-2 milliseconds
- 1.0 ms = full reverse/left
- 1.5 ms = neutral/center
- 2.0 ms = full forward/right
- Duty Cycle: Pulse width / period (5-10% at 50Hz)
donkeycar/parts/actuator.py:55
PulseController
Modern, unified controller for PWM output. Location:donkeycar/parts/actuator.py:85
Steering Control
PWMSteering
Converts steering angles (-1 to 1) to PWM pulses. Location:donkeycar/parts/actuator.py:282
- Find center pulse:
controller.set_pulse(390)(adjust until wheels straight) - Find left pulse: Adjust until wheels full left
- Find right pulse: Adjust until wheels full right
- Update
myconfig.pywith these values
Throttle Control
PWMThrottle
Converts throttle values (-1 to 1) to PWM pulses for ESC (Electronic Speed Controller). Location:donkeycar/parts/actuator.py:331
Motor Controllers
PCA9685 (Legacy)
Popular I2C PWM controller board (legacy, use PulseController instead). Location:donkeycar/parts/actuator.py:128
VESC
For electric skateboard motors and high-power applications. Location:donkeycar/parts/actuator.py:184
Differential Drive
For two-wheeled robots and differential drive vehicles.L298N H-Bridge (3-pin mode)
Location:donkeycar/parts/actuator.py:756
- IN1 (Forward): GPIO pin to OutputPin
- IN2 (Backward): GPIO pin to OutputPin
- ENA (PWM): GPIO pin to PwmPin
- OUT1/OUT2: Connect to motor
L298N H-Bridge (2-pin mode)
For mini L298N boards and L9110S/HG7881 drivers. Location:donkeycar/parts/actuator.py:872
- IA/IB: Both to PWM-capable GPIO pins
- OA/OB: Connect to motor
TwoWheelSteeringThrottle
Mixes throttle and steering for differential drive. Location:donkeycar/parts/actuator.py:830
- Steering < 0 (left): Reduce left motor speed
- Steering > 0 (right): Reduce right motor speed
- Steering = 0: Both motors equal
Configuration
Inmyconfig.py:
Calibration Tools
Manual Calibration Script
Calibration Manager
Legacy Controllers
These are deprecated but still available:- RPi_GPIO_Servo - Direct GPIO PWM (use PulseController instead)
- ServoBlaster - User-space PWM via DMA (use PulseController instead)
- ArduinoFirmata - Arduino-based PWM (use PulseController instead)
- Teensy - Teensy microcontroller (undocumented)
- Maestro - Pololu Maestro (undocumented)
- JHat - Teensy-based PCA9685 emulator (undocumented)
Pin Providers
Seedonkeycar/parts/pins.py for pin implementations:
- PCA9685PwmPin - PCA9685 I2C PWM controller
- RPi_GPIO_PwmPin - Raspberry Pi GPIO PWM
- PiGPIO_PwmPin - Hardware PWM via pigpio daemon
- ServoBlasterPwmPin - ServoBlaster driver
Common Issues
Servo Jitter
- Check power supply (servos need 5-6V, 2A+)
- Add capacitor across servo power
- Reduce PWM frequency
- Check for loose connections
ESC Not Responding
- Verify ESC is calibrated
- Check battery voltage
- Ensure correct pulse range
- Try different PWM frequency
Motor Runs Backward
- Swap motor wires
- Or use
pwm_inverted=Truein PulseController - Or negate throttle in code
I2C Errors (PCA9685)
Next Steps
- Controllers - Add user input
- Sensors - Add odometry and feedback
- Custom Parts - Create custom drive trains
