Pid Controller⚠ unverified
Aerospace / Controls · Compute the output of a simple PID controller
Parameters
| Input | Symbol | Unit | Default | Description |
|---|---|---|---|---|
| kp | kp | — | 1.0 | Proportional ga |
| ki | ki | — | 1.0 | Integral ga |
| kd | kd | — | 1.0 | Derivative ga |
| error | error | — | 1.0 | Current error signal, in the controlled variable's units |
| integral | integral | — | 1.0 | Accumulated integral of the error, in the controlled variable's units times seconds |
| derivative | derivative | — | 1.0 | Time derivative of the error, in the controlled variable's units per second |
| Output | Symbol | Unit | Description |
|---|---|---|---|
| result | u | — | Controller output, in the actuator's command units |
The science & history
Understanding the Parameters
- Past, present, future — the elegance of PID is that its three terms cover the error's history in time:
-
Proportional ($k_p e$) reacts to the error now — the bigger the error, the harder the correction. Alone it leaves a residual steady-state error (it needs some error to produce output).
-
Integral ($k_i\int e\,dt$) accumulates past error — it keeps pushing until the error is driven to exactly zero, eliminating steady-state offset (e.g. holding altitude precisely against a constant disturbance). Its cost is a tendency to overshoot and integrator windup.
-
Derivative ($k_d\,\dot e$) anticipates the future from the error's trend — it applies damping, braking the response before it overshoots. It smooths and stabilises but amplifies sensor noise.
-
Tuning is the art — the three gains are chosen to trade speed vs stability vs accuracy: raise $k_p$ for a faster response (but risk oscillation), add $k_i$ to kill steady-state error (but risk overshoot), add $k_d$ to damp (but risk noise sensitivity). Classic methods (Ziegler–Nichols) and modern optimisation set them; in aircraft they are often gain-scheduled with airspeed and altitude because the plant changes with flight condition.
-
This calculator sums pre-computed terms — it takes $e$, $\int e\,dt$, and $de/dt$ as given inputs and forms the weighted sum. A real controller computes the integral and derivative itself from the time history of the error; here that bookkeeping is assumed done, so the calculator is really "evaluate the PID law at this instant."
-
Where it flies — heading hold (Autopilot Heading Hold, a PI special case), altitude hold, airspeed hold, attitude hold, and the inner loops of every autopilot are PID (or PID-derived) laws. The same three terms also run yaw dampers, autothrottles, and engine controls.
Derivation (Approaching a Proof)
PID is a designed control law rather than a derived physical law, but each term has a clear rationale from feedback theory. Let the error be the difference between the desired setpoint $r$ and the measured output $y$:
$$e(t) = r(t) - y(t).$$
The goal is to choose the actuator command $u(t)$ so that $e \to 0$ with good transient behaviour. PID builds $u$ from three functionals of the error:
$$u(t) = \underbrace{k_p\,e(t)}_{\text{present}} + \underbrace{k_i\int_0^t e(\tau)\,d\tau}_{\text{past (removes offset)}} + \underbrace{k_d\,\frac{de(t)}{dt}}_{\text{future (adds damping)}}.$$
Why each term. In the Laplace domain the controller transfer function is $C(s) = k_p + k_i/s + k_d s$. The integrator's $1/s$ pole forces zero steady-state error for step commands (infinite DC gain), the derivative's $s$ zero adds phase lead (damping) to stabilise the loop, and the proportional term sets the overall loop gain and response speed. Placed in a feedback loop with the plant $G(s)$, the closed-loop response is shaped by tuning $k_p, k_i, k_d$ to place the poles for the desired damping and speed. The registry evaluates the time-domain sum at one instant:
$$u = k_p\,e + k_i\,I + k_d\,D, \qquad I = \int e\,dt,\; D = \frac{de}{dt}. \qquad\blacksquare$$
Dimensional check. Each term is a gain times an error functional; for the sum to be a consistent command, $k_p$ carries [command]/[error], $k_i$ carries [command]/([error]·s), and $k_d$ carries [command]·s/[error], so all three products share the command's units ✓. (The registry labels everything dimensionless, folding the units into the gains.)
History and Development
-
From ship steering to theory. The PID structure emerged empirically in early automatic ship-steering gear; Nicolas Minorsky analysed it mathematically in 1922 for the automatic steering of the USS New Mexico, articulating the three-term (proportional–integral–derivative) action from observing how a good helmsman steers.
-
Ziegler–Nichols (1942). John Ziegler and Nathaniel Nichols published practical tuning rules that made PID deployable across industry without a plant model — cementing PID as the default controller for process control and, later, flight control.
-
Ubiquity and endurance. Despite decades of advanced control theory (optimal, robust, adaptive, model- predictive), PID remains the most widely deployed control law in the world — in autopilots, engine controls, disk drives, thermostats, and quadcopters — because it is simple, robust, tunable without a model, and effective. Modern aircraft wrap PID inner loops inside more sophisticated outer architectures, but the three-term core endures.
Related Concepts: Pid Output, Autopilot Heading Hold, Damping Ratio, Peak Overshoot, Settling Time 2%, Phase Margin, Rise Time, Bode Magnitude
Notes: The three-term feedback law $u=k_p e+k_i\!\int e\,dt+k_d\dot e$ — present/past/future of the error (P sets speed but leaves offset; I removes steady-state error but can overshoot/wind up; D damps but is noise- sensitive). Near-duplicate of Pid Output (Physics/Controls). This calc sums pre-computed e, ∫e, de/dt (does not itself integrate/differentiate). Tuning trades speed vs stability vs accuracy; often gain-scheduled. Gains carry the units; defaults ⇒ $u=3$.