Skip to content
learnFRC.org
programmingreference

Software Safety Limits & Watchdogs

Implementing stator current limits, supply current limits, software travel limits, and watchdog timers to protect mechanical and electrical systems.

Modern brushless motors (Kraken X60, Falcon 500, NEO Vortex) produce high stall torque, often exceeding 7 Nm per motor. Without software safeguards, an elevator or arm can shear gear teeth, bend aluminum tubing, or snap cables in fractions of a second.

Every mechanism requires separate protection for internal motor coils and external battery wiring:

[ Battery (12V) ] ---> Supply Current (A) ---> [ Motor Controller ] ---> Stator Current (A) ---> [ Motor Coils ]
|
PWM / Voltage Step-down

1. Stator Current Limits (Torque and Thermal Protection)

Section titled “1. Stator Current Limits (Torque and Thermal Protection)”
  • What it does: Limits the current circulating through the motor’s copper windings.
  • Why it matters: Stator current directly generates motor torque and heat (P=I2RP = I^2 R).
  • Rule of Thumb:
    • Drivetrain (Kraken X60): 60A to 80A
    • Elevators / Arms: 40A to 50A
    • Intakes / Rollers: 30A to 40A
// Example: Phoenix 6 Current Limits Configuration
TalonFXConfiguration config = new TalonFXConfiguration();
config.CurrentLimits.StatorCurrentLimitEnable = true;
config.CurrentLimits.StatorCurrentLimit = 40.0; // 40 Amps stator

2. Supply Current Limits (Brownout & Breaker Protection)

Section titled “2. Supply Current Limits (Brownout & Breaker Protection)”
  • What it does: Limits current drawn from the battery through the PDP/PDH breaker.
  • Why it matters: Prevents the main 120A breaker from tripping and stops the roboRIO from browning out (dropping below 6.8V).

Always configure forward and reverse soft limits to prevent mechanisms from hitting hard stops at high velocity:

// Configure soft limits in motor rotations
config.SoftwareLimitSwitch.ForwardSoftLimitEnable = true;
config.SoftwareLimitSwitch.ForwardSoftLimitThreshold = 35.0; // rotations
config.SoftwareLimitSwitch.ReverseSoftLimitEnable = true;
config.SoftwareLimitSwitch.ReverseSoftLimitThreshold = 0.5; // rotations
Zero Offsets Before Soft Limits

Software limits are only as reliable as your zero reference. If the motor powers on in an un-zeroed state without an absolute encoder (CANcoder), soft limits will activate at the wrong physical locations.


WPILib commands automatically time out if a motor safety object is starved of updates:

  • Set default commands to stop motors or hold position.
  • Never write while(true) loops inside command execute() methods.
  • Always use .withTimeout(Seconds.of(2.0)) on mechanism movement commands in autonomous routines.

Verified Sources & Standards

Evergreen Standard Verified: Sep 24, 2026