Skip to content
learnFRC.org
programmingreference

PID Control Theory & Anti-Windup

Intuitive and mathematical foundations of Proportional, Integral, and Derivative closed-loop feedback controllers.

A PID controller (Proportional, Integral, Derivative) is a fundamental feedback control algorithm in robotics. Given a desired setpoint r(t)r(t) and a measured physical process variable y(t)y(t), the controller computes an output u(t)u(t) that drives the tracking error e(t)=r(t)−y(t)e(t) = r(t) - y(t) to zero.

u(t) = kP · e(t) + kI · ∫ e(τ) dτ + kD · (de(t)/dt)
Interactive Simulator

Experiment with live controller feedback in our PID & Feedforward Simulator to visualize how each term alters the closed-loop transient response.


The proportional term applies corrective output in direct proportion to the current error: u_P(t) = kP · e(t)

  • Physical Analogy: Behaves like a mechanical spring attached to the setpoint. The further the mechanism is from the target, the harder the controller pulls.
  • Limitation: Proportional control alone cannot eliminate steady-state error in the presence of opposing forces like gravity or static friction (kSkS).

The derivative term applies corrective output in proportion to the rate of change of error: u_D(t) = kD · (de/dt) = -kD · (dy/dt)

  • Physical Analogy: Behaves like a shock absorber or viscous damper. It resists rapid movement and prevents excessive overshoot.
  • Limitation: Sensitive to sensor measurement noise. High-frequency encoder noise can be amplified by numerical differentiation.

The integral term sums historical error over time: u_I(t) = kI · ∫ e(τ) dτ

  • Purpose: Eliminates persistent steady-state offsets that kPkP cannot overcome alone.
  • Danger: Integral Windup: If a mechanism is stalled or moving toward a distant setpoint, the accumulated integral sum can grow excessively, causing overshoot and oscillation when arriving at the setpoint.
Do Not Increase kP to Overcome Gravity

If an elevator or arm stops short of its target, do not increase kPkP or rely on kIkI. Add a gravity feedforward term (kGkG) instead. Feedforward supplies continuous holding voltage, so kPkP only handles dynamic error correction.

Interactive Simulator

Experiment with step responses, steady-state droop, and integral windup in the Interactive PID & Feedforward Simulator.


When tuning mechanisms in Phoenix Tuner X or WPILib:

  1. Set Feedforward First: Tune kSkS (friction) and kVkV (velocity) or kGkG (gravity) with kP=0,kI=0,kD=0kP = 0, kI = 0, kD = 0.
  2. Increase kPkP: Increase kPkP until the mechanism rapidly tracks step changes without violent oscillation.
  3. Add kDkD: Increase kDkD to dampen any overshoot or ringing at the arrival point.
  4. Avoid kIkI unless strictly necessary: For most FRC mechanisms (arms, elevators, swerve steering, flywheels), a calibrated feedforward model eliminates the need for integral gain, keeping kI=0kI = 0 for stable behavior.

Verified Sources & Standards

Evergreen Standard Verified: Sep 24, 2026