Unit 8 · Lesson 5

PID Control: Conceptual Overview

Feedforward predicts. PID corrects. You've spent four lessons learning to predict the right voltage using physics models. This lesson introduces the complementary skill: using a sensor to measure what the mechanism is actually doing and feeding that information back into the controller to eliminate error. No code yet — just the concepts, the loop, the three terms, and the four shapes a response can take.

By the end of this lesson, you will:

  • Define a closed feedback loop and explain what makes it different from open-loop and feedforward control
  • Define "error" precisely and explain why it is the central variable in all feedback control
  • Describe the role of P, I, and D terms in plain language without any formulas
  • Recognize the four response curve shapes — underdamped, overdamped, critically damped, and steady-state error — and name one gain change that would move from one to another
  • Explain why PID alone is often insufficient and why feedforward + PID is the standard for FRC mechanisms

Closing the Loop

Every control system has a plant — the physical thing being controlled — and a controller — the software doing the commanding. In an open-loop system, the controller sends a command and never learns whether the plant responded correctly. The loop is open: information flows one way only, from controller to plant.

A closed-loop (or feedback) control system adds a return path: the plant's actual output is measured by a sensor and fed back to the controller. The controller compares the measurement to the setpoint, computes the difference — the error — and adjusts its output to drive that error toward zero. The loop is closed.

Setpoint "go to 90°" Σ error PID Controller kP·e + kI·∫e + kD·ė voltage Mechanism (arm, elevator…) Sensor (encoder, gyro…) measured output fed back to subtract from setpoint

The sum junction (Σ) is where the feedback enters. It computes: error = setpoint − measurement. This error is the only input the PID controller needs. Everything the controller does is based on this single number — what it is right now (P), what it has been (I), and how fast it's changing (D).

The Three-Step Progression to PID

The path from open-loop to PID is a progression of increasingly intelligent control. Each step solves a specific failure mode of the step before it.

ApproachWhat it doesFailure mode it solvesRemaining problem
Bang-bang Full power until at setpoint, then stop. Nothing — this is the baseline. Gets to setpoint eventually. Overshoot wildly. Oscillates forever. Damages hardware.
P only Apply force proportional to error. Far away = more power. Close = less power. Eliminates wild overshoot. Approaches target smoothly. Steady-state error: stalls 2° short because P output = friction. Never quite reaches setpoint.
PD P drives toward target; D brakes as error shrinks fast. Prevents overshoot on fast approach. Settles faster than P alone. Still has steady-state error. D adds noise sensitivity.
PID P drives; I accumulates past error to overcome friction; D brakes. Eliminates steady-state error (I winds up until friction is overcome). Integral windup if not managed. Requires careful tuning of all three gains.
FF + PID Feedforward predicts; PID corrects the small remaining error. Feedforward eliminates most error before it appears. PID only cleans up residual. Requires accurate characterization (SysId). The 2910 standard for any controlled mechanism.

The Three Terms — The Present, The Past, The Future

Each PID term looks at a different aspect of the error signal. Together they form a complete picture of what the error is, where it came from, and where it's going.

P Proportional — The Present
What it sees: The current error right now.
What it does: Applies force proportional to how far away the mechanism is. Big error → big push. Small error → small push. The farther from the target, the harder the motor drives toward it.
🚗 Parking a car: you press the gas harder when you're far from the spot. As you get close, you ease off naturally.
I Integral — The Past
What it sees: The accumulated sum of all past errors.
What it does: If the mechanism is stuck slightly short of the target, error accumulates over time. The I term grows slowly, adding more and more force until friction is finally overcome. It eliminates the "droop" that P alone can't fix.
📦 Pushing a stubborn heavy box: you lean harder and harder over time until it finally budges.
D Derivative — The Future
What it sees: How fast the error is changing right now.
What it does: If the mechanism is approaching the target quickly (error shrinking fast), D applies a braking force to prevent overshoot. The faster it's closing the gap, the harder D brakes.
🚗 Braking before you reach the parking spot: you don't wait until you're at the line — you slow down in anticipation.

The PID formula

output = kP·error + kI·(∑error·dt) + kD·(Δerror/Δt)
kP·error Proportional term. Scales with current error. Zero error → zero P contribution. The primary driving force of the controller.
kI·(∑error·dt) Integral term. Accumulates error over time. Grows until it's large enough to overcome steady-state friction. Risk: windup if the mechanism is held away from setpoint for too long.
kD·(Δerror/Δt) Derivative term. Proportional to how fast error is changing. Brakes when error is decreasing quickly. Risk: amplifies sensor noise, since noise looks like rapid small changes in error.
💡 This lesson has no code on purpose

Lesson 6 isolates each term individually with code examples showing what each gain does in practice. Lesson 7 covers the WPILib PIDController class with the full API. This lesson is for building the mental model first — understand the concepts before writing the code, and the code will make much more sense.

The Four Response Shapes

Every PID-controlled mechanism has a characteristic response curve: position (or velocity) over time after a step change in setpoint. Learning to recognize these four shapes is how you diagnose a controller in the field — by watching the mechanism, even without SmartDashboard.

Step response — position vs. time after a setpoint change
Underdamped
Overdamped
Critically Damped
Steady-State Error
time → position setpoint 0 start
Select a response type above
Each shape has a distinct appearance and a distinct set of gain changes that move you toward or away from it.

Moving Between Response Shapes

Every gain change shifts the response curve. Memorize these relationships — they are the core of manual PID tuning, covered in detail in Lesson 9.

You observeWhat to changeWhy it helps
Oscillates / overshoots badly (underdamped) Decrease kP, increase kD Less proportional drive → less overshoot momentum. More damping → harder braking on approach.
Slow to reach setpoint, no overshoot (overdamped) Increase kP, decrease kD if excessive More proportional drive → faster approach to setpoint. Less damping → less braking that was slowing it down.
Stops just short of setpoint, never quite arrives (steady-state error) Increase kI, or increase kP More integral → accumulating error eventually overcomes friction. More proportional → P output still significant at small error.
Oscillates with high frequency, seems noisy Decrease kD, add a low-pass filter to encoder Derivative amplifies sensor noise. High-frequency oscillation is often D responding to noise, not to actual mechanism motion.
Takes too long to settle, small oscillations Increase kD slightly, check kI for windup More damping helps final settling. Integral windup (over-accumulated error) can cause small oscillations late in settling.

Why PID Alone Isn't Enough for FRC

PID is reactive — it can only act after error has developed. For a mechanism that needs to move quickly, PID-only control means the motor idles at zero output until the error signal builds up enough to command meaningful power. The mechanism starts slowly and overshoots. To compensate, you raise kP — now it starts fast but overshoots more. You raise kD to brake — now it's oscillatory.

This is the fundamental limitation of reactive control: any error requires waiting for the error to be large before applying corrective force. The solution is feedforward: apply the predicted voltage first (based on the physics model), so the mechanism is already moving at roughly the right speed before error accumulates, and PID only needs to correct the small model inaccuracies.

In practice: the feedforward term provides approximately 90–95% of the required output at any given moment. PID provides the remaining 5–10%. This means PID gains can be modest (kP much smaller, kI=0 in many cases, kD gentle), which makes the system more robust and less prone to oscillation.

🔍 LRI Perspective: "PID with no feedforward means you're asking PID to do two jobs"

When I watch a robot arm swing wildly to a position — oscillating around the setpoint, kD pumped to prevent explosion — I know the team is using high-gain PID without feedforward. PID with no feedforward has to provide all the force to move the mechanism AND resist gravity (on an arm) AND overcome friction AND compensate for battery voltage. You end up with aggressive gains that cause oscillation, and the fix keeps getting worse. The correct design: feedforward handles the physics, PID handles the residual error. The resulting gains are smaller, more stable, and easier to tune.

⚠️ Integral windup — the danger of the I term

If a mechanism is held away from its setpoint for an extended time — pressed against a hard stop, waiting for a game piece, commanded to a position it can't reach — the integral term accumulates without limit. This is called integral windup. When the mechanism is finally free to move, the wound-up integral commands a large output spike, causing rapid overshoot. WPILib's PIDController has an setIZone() method that limits integration to a zone around the setpoint, and a setIntegratorRange() method that caps the integral output. Both are covered in Lesson 7. For now: know that kI > 0 requires active windup management.

Knowledge Check

1. An arm is commanded to 90°. It reaches 88° and stops there permanently. The error is a constant +2°. Which term is responsible for eventually eliminating this error, and why?

  • A D — it detects the constant error and applies a correction force.
  • B P — the proportional term will continue growing until friction is overcome.
  • C I — the integral term accumulates the +2° error every loop cycle. As time passes, the accumulated sum grows until the integral output is large enough to overcome the friction holding the arm at 88°. P alone stops growing once error is constant; I keeps growing until the error is zero.
  • D None — steady-state error can only be fixed by increasing kP or by using feedforward.

2. A mechanism's response curve shows it reaching the setpoint quickly but oscillating around it for several seconds before settling. Which gain should be increased to damp these oscillations?

  • A kI — the integral term will counteract the oscillations by accumulating error.
  • B kP — more proportional gain will push the mechanism to the setpoint faster.
  • C kD — the derivative term brakes the mechanism as it approaches the setpoint. Increasing kD applies more damping force as the mechanism oscillates, reducing both the amplitude and duration of the oscillations.
  • D None — oscillation after reaching the setpoint is a mechanical problem, not a control problem.

3. The closed-loop diagram shows a subtraction (−) at the sum junction. Why is the feedback path subtracted rather than added?

  • A To prevent the controller from ever commanding more than the setpoint.
  • B To compute error = setpoint − measurement. The error must be positive when the mechanism is below the target and negative when above it. Subtracting the measurement from the setpoint gives this signed error, which the controller uses to determine both the direction and magnitude of its output. Adding instead would give setpoint + measurement, which has no physical meaning as an error signal.
  • C To prevent the integral term from winding up when the mechanism reaches the setpoint.
  • D Because the sensor measures backward relative to the motor direction.
💪 Practice Prompt

Observe the Four Response Shapes in Person

  1. Choose any mechanism on your robot with a position sensor (arm, elevator, or drivetrain turn-to-angle). Write the simplest possible P-only controller: multiply current error by a small kP (start at 0.01) and set the motor to that voltage. Enable and observe. This is your baseline response — likely underdamped (oscillates) or overdamped (sluggish) depending on kP.
  2. Deliberately create each of the four response shapes by adjusting kP and kD. For overdamped: very small kP, no kD. For underdamped: large kP, no kD. For critically damped: increase kP to oscillation, then add kD until oscillation just stops. For steady-state error: reduce kP to the point where the mechanism stalls slightly short. Observe each on SmartDashboard and compare to the visualizer in this lesson.
  3. Add a small kI to the steady-state error configuration. Watch the mechanism slowly creep to the setpoint as the integral winds up. Then command the mechanism away from its target for 10 seconds (simulate integral windup). Re-command the setpoint and observe the overshoot spike from the wound-up integral. This directly demonstrates why windup management is important.
  4. Stretch goal: Research WPILib's PIDController.setIZone(double). Add it to your experiment. Set the I-zone to half the maximum error range. Observe: the I term only accumulates when the mechanism is close to the setpoint. Repeat the windup test — the overshoot should be significantly smaller or eliminated. You've just implemented the simplest form of anti-windup.