Lesson 38: CAN Motor Controllers

Many modern FRC motor controllers communicate over CAN instead of PWM. CAN lets the roboRIO send commands and receive information over a shared bus. It can also let smart motor controllers handle configuration, current limits, and sensor feedback.

CAN IDs

Every CAN device needs a unique ID. If two devices have the same ID, the robot may behave unpredictably. Keep CAN IDs in your wiring constants just like PWM ports.

public class Wiring {
    public static final int LEFT_LEADER_CAN_ID = 1;
    public static final int RIGHT_LEADER_CAN_ID = 2;
    public static final int INTAKE_CAN_ID = 9;
}

Configure Deliberately

CAN controllers often remember settings. That is useful, but it can also surprise you if a controller was used on a different robot. Set important configuration in code or through a documented team setup process.

Current Limits

Current limits protect motors, wiring, and breakers. They are also a tuning tool: a mechanism that stalls briefly may need a different limit than a drive motor.

Read Status Information

Smart controllers can often report temperature, current, voltage, position, velocity, and faults. Put the useful values on your dashboard or in your logs while testing.

Practice

Create a CAN ID table for your robot. Include device name, CAN ID, motor direction, current limit, and whether it should brake or coast when stopped.