A mechanism that overshoots, oscillates, or never quite reaches its setpoint is almost always a tuning problem with a known cause. WPILib documents the recurring ones.
Integral windup#
If kI is too large, the integral term accumulates error during a big setpoint change until it exceeds the maximum control effort -- the mechanism blows past the target and takes a long time to settle. Fixes, in order of preference (these methods live on WPILib's PIDController):
- Reduce kI, often to zero -- most FRC mechanisms need no integral term at all. Tune the feedforward model instead.
- Reset the integrator outside a tolerance band with
setIZone()-- when the position error exceeds IZone, the accumulated error resets to zero, disabling integral until you are close again. - Cap the integrator with
setIntegratorRange().
controller.setIZone(5.0); // only integrate within 5 units of target
controller.setIntegratorRange(-2, 2); // clamp accumulated effort
Voltage sag#
Drawing current drops bus voltage, so a controller tuned at 13V behaves differently at 11V -- the mechanism slows as the battery droops. Fix it by commanding voltage rather than duty-cycle percent so output is consistent regardless of bus voltage:
motor.setVoltage(feedforward.calculate(setpointVelocity));
Using setVoltage() (or the controller's voltage-compensation feature) makes your gains battery-independent.
Actuator saturation#
If gains are so aggressive that the mechanism demands more torque or acceleration than the motor can deliver, it saturates at maximum output and can become unstable -- you can't tune your way past physics. The fix is mechanical: change the gearing or move to a higher-power motor (e.g. NEO -> NEO Vortex, Falcon 500 -> Kraken X60) to gain control authority.
Missing or wrong feedforward#
The single most common 'bad PID' is actually missing feedforward. A flywheel or drivetrain is feedforward-dominated; an arm needs kG that varies with the cosine of its angle; an elevator needs a constant kG. If you try to do the whole job with kP, you get sluggish tracking and steady-state error. Get kS/kV/kA from a SysId characterization run, add kG for gravity-loaded mechanisms, and let P handle only the residual.
A disciplined process#
Start from zero gains. Add feedforward until the mechanism roughly follows commands open-loop. Then raise kP until tracking is crisp; add a little kD only if it overshoots; reach for kI last and rarely. Throughout, watch the measured-vs-setpoint plot in AdvantageScope -- oscillation means too much kP or noisy kD; lag means too little kP or missing FF; steady offset means missing kG or FF. Change one gain at a time and re-plot.
the part worth keeping
Key takeaways
- Integral windup comes from too-large kI; prefer kI=0 with good feedforward, or bound it with setIZone()/setIntegratorRange() on WPILib's PIDController.
- Command voltage with setVoltage() so gains stay consistent as battery voltage sags.
- Actuator saturation is a physics limit -- fix it with gearing or a higher-power motor, not more gain.
- Most 'bad PID' is missing feedforward; get kS/kV/kA from SysId, add kG for gravity, and diagnose with the AdvantageScope setpoint-vs-measured plot.
Programming, Controls & SensorsCommon Mistakes and Troubleshootinglesson 5 of 5
Keep going
Take the quiz+10 XP with an accountMore in Common Mistakes and Troubleshooting
where this came from
Sources and corrections
This lesson is AI-assisted: drafted from primary sources, then reviewed and edited by hand. Errors still get through. When one is reported we fix it and write down what changed, in public, in the corrections log.
sources and further reading
- docs.wpilib.orgWPILib: Common Control Loop Tuning Issues
- docs.wpilib.orgWPILib: Trajectory Troubleshooting
- docs.wpilib.orgWPILib: Controls Glossary
clipped to this lesson
Articles that go further on this
The lesson gets you through the topic. These go wider on it, and they read in one sitting.
- 8 min readHow to Tune PID on an FRC Robot: A Practical GuideA hands-on guide to tuning PID and feedforward on FRC mechanisms: a safe tuning order, fixing oscillation and steady-state error, and using WPILib SysId./blogread it
- 8 min readFRC CAN Bus Explained (and How to Fix Common Problems)How the FRC CAN bus works, the daisy-chain wiring with 120-ohm termination, avoiding device ID conflicts, and fixing the most common CAN failures./blogread it
- 4 min readPID Control in FRC, Explained SimplyA beginner-friendly guide to PID control in FRC: what kP, kI, and kD actually do, how to tune them, and why most teams skip the I term./blogread it
answer sheet
Lesson quiz
All 3 right completes the lesson. Miss one and only that question comes back, anything you already answered correctly stays banked.
0 of 3 answered
01If a mechanism using only proportional (P) control settles close to but never exactly reaches its setpoint, which gain is typically added to eliminate that steady-state error?
02What is integral windup in a PID controller?
03A robot's PID loop oscillates rapidly with jumpy output on a noisy sensor; which symptom points to the derivative (kD) term?
Answer every question to submit.
All 51 lessons in Programming, Controls & Sensorsopenclose
01 / prerequisites
02 / foundations-tools-and-first-program
03 / robot-program-and-command-based
04 / motors-and-control
05 / autonomous-trajectories-simulation
06 / sensing-fundamentals
07 / encoders
08 / gyros-imus-orientation
09 / closed-loop-control
10 / vision-pose-estimation
11 / worked-examples-mini-projects
- Not read yet:Mini-Project: A Closed-Loop Elevator with Motion Magic
- Not read yet:Mini-Project: A Velocity-Controlled Shooter on REVLib
- Not read yet:Mini-Project: A Teleop Swerve Drive Subsystem
- Not read yet:Mini-Project: An Autonomous Routine with PathPlanner
- Not read yet:Mini-Project: Vision-Aligned Scoring with Limelight
12 / common-mistakes-troubleshooting
13 / advanced-techniques-case-studies
- Not read yet:State-Space Control and Kalman Filtering
- Not read yet:Log Replay Architecture with AdvantageKit
- Not read yet:Advanced Pose Estimation: Multi-Tag Fusion and Standard Deviations
- Not read yet:Robot Coordination, Alerts, and Operator Feedback
- Not read yet:Case Study: Hardening Software Before an Event