Skip to content

A Methodical PID Tuning Process

learnfrc.com
learnfrc.comAuthor
Veer Bajaj
Veer BajajMaintainer

Random guessing wastes time and breaks mechanisms. Use a structured process and live telemetry.

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.

Start with all gains at zero, then:

  1. 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.
  2. 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.
  3. 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.

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.

  • 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.

  • 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.

This lesson was adapted from learnfrc.com.