Random guessing wastes time and breaks mechanisms. Use a structured process and live telemetry.
Set up to see what you are doing
Before touching gains, plot the setpoint and the measurement together on AdvantageScope, Glass, or Shuffleboard. You cannot tune what you cannot see. Make the gains editable live (e.g., via a tunable number) so you can adjust without redeploying.
A safe starting procedure
Start with all gains at zero, then:
- Tune kP first. Raise kP until the mechanism reaches the setpoint reasonably quickly. Keep increasing until you see sustained oscillation, then back off to roughly half that value.
- Add kD. Increase kD to damp the overshoot and oscillation from kP. kD makes the approach smoother but too much causes jitter (it amplifies sensor noise) or sluggishness.
- Add kI last, sparingly. Only if a persistent steady-state error remains that kP/feedforward cannot remove. Use a small value and consider
setIZone()so integral only acts when you are already close. For most velocity/position control, a good feedforward removes the need for kI entirely.
What good tuning looks like
You want a fast rise to the setpoint, little or no overshoot, and a quick, stable settle. A small overshoot that settles fast is usually better than a slow, creeping approach.
Practical cautions
- Tune under realistic load. A flywheel with no game piece behaves differently than one shooting; an elevator behaves differently with and without an arm extended.
- Mind units. If your error is in meters but you expected encoder ticks, your kP will be wildly off. Always convert sensor output to real units first.
- Re-tune after mechanical changes. New gear ratios, belts, or weight change the dynamics.
- Combine with feedforward. PID is best at correcting error, not predicting motion. The next lesson shows how feedforward does the heavy lifting so PID only handles the leftover error.
Keep notes of the gains that work — and the units they assume — in your code or build log so they survive the season.
Key takeaways
- Always plot setpoint vs. measurement and make gains live-editable before tuning.
- Tune kP first (to half the oscillation point), then kD to damp, then kI sparingly only for steady-state error.
- Tune under realistic load and correct units; re-tune after any mechanical change.
Keep going
Take the quiz · +10 XP with an accountMore in Closed-Loop Control: PID, Feedforward, and SysId
Sources & 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 — publicly, in the corrections log.
Sources and further reading
- WPILib: Tuning a Flywheel Velocity Controllerdocs.wpilib.org
- WPILib: Introduction to PIDdocs.wpilib.org
Read next
Articles on this, for competition day
The lesson covers how it works. These cover what to do when it breaks.
- 8 min read
How to Tune PID on an FRC Robot: A Practical Guide
A 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.
Read - 4 min read
PID Control in FRC, Explained Simply
A 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.
Read
Lesson quiz
RequiredAll 3 right completes the lesson. Miss one and only that question comes back — anything you already answered correctly stays banked.
0 of 3 answered
01.When tuning a PID controller methodically, which gain should you tune first, and how?
02.What is the primary purpose of increasing the derivative gain (kD) during tuning?
03.Why is integral gain (kI) generally used only sparingly on most FRC mechanisms?
Answer every question to submit.
All 51 lessons in Programming, Controls & Sensors
- Not started:Mini-Project: A Closed-Loop Elevator with Motion Magic
- Not started:Mini-Project: A Velocity-Controlled Shooter on REVLib
- Not started:Mini-Project: A Teleop Swerve Drive Subsystem
- Not started:Mini-Project: An Autonomous Routine with PathPlanner
- Not started:Mini-Project: Vision-Aligned Scoring with Limelight
- Not started:State-Space Control and Kalman Filtering
- Not started:Log Replay Architecture with AdvantageKit
- Not started:Advanced Pose Estimation: Multi-Tag Fusion and Standard Deviations
- Not started:Robot Coordination, Alerts, and Operator Feedback
- Not started:Case Study: Hardening Software Before an Event