AKS Anvil

PID theory

PID control theory

A compact companion to the interactive simulator: what a plant is, what each PID term does, how to read a step response, and how Bode-like margins relate to stability.

1. The feedback idea

A controller compares a desired value (reference r) with the measured output y, and produces an actuation command u that drives the plant so that y tracks r.

e = r − y          (error)
u = C{e}           (controller)
y = G{u}           (plant)

With unity feedback, the open-loop transfer function is L(s) = C(s) G(s), and the closed-loop map from reference to output is approximately T(s) = L / (1 + L) when sensor dynamics are neglected.

2. Plant models in the simulator

First order

G(s) = K / (τ s + 1)

Common for thermal systems, simple RC-like processes, and many “lag” plants. One energy storage element.

Second order

G(s) = ωₙ² / (s² + 2 ζ ωₙ s + ωₙ²)

Captures oscillation and damping. ζ < 1 underdamped (rings), ζ = 1 critically damped, ζ > 1 overdamped.

Integrating + lag

G(s) = K / [s (τ s + 1)]

Models level control, some motion/position chains, or type‑1 processes that keep integrating a constant input. Steady-state error to a step often needs integral action in the controller.

3. The PID controller

u(t) = Kp · e(t) + Ki · ∫ e(τ) dτ + Kd · de/dt

C(s) = Kp + Ki/s + Kd · s
     = (Kd s² + Kp s + Ki) / s
TermGainEffect (intuition)
Proportional Kp Immediate reaction to error. Higher Kp → faster, but can overshoot/oscillate.
Integral Ki Removes steady-state offset by accumulating past error. Too much → slow windup/oscillation.
Derivative Kd Damps change (anticipates). Helps reduce overshoot; sensitive to noise in real sensors.

4. Reading the step response

For a unit step reference, the simulator reports classical time-domain metrics:

A “good” loop is rarely the absolute fastest: it is fast enough, well damped, and robust to plant uncertainty.

5. Bode-like view and margins

The simulator plots the open-loop frequency response of L(jω) = C(jω) G(jω):

Approximate stability margins:

Margins here are numerical estimates on a frequency grid — excellent for teaching and tuning intuition, not a substitute for formal analysis of every industrial plant.

6. Practical tuning sketch

  1. Start with Ki = 0, Kd = 0, raise Kp until the response is reasonably fast with limited oscillation.
  2. Add Ki slowly to remove offset; watch overshoot and windup-like sluggish recovery.
  3. Add a little Kd to shave overshoot and settle faster (if the signal is clean).
  4. Check Bode margins: if PM collapses, reduce gains or rebalance Ki/Kd.

Classical recipes (Ziegler–Nichols, SIMC, lambda tuning, etc.) give starting points; the simulator is ideal for feeling how each gain moves the response.

7. What the simulator intentionally simplifies

Try it

Open the PID Controller Simulator, pick a second-order plant with low damping, and sweep Kp / Ki / Kd while watching overshoot and phase margin move together.