Control Lab
Two discrete PID controllers, A and B, run at once on identical plants with identical sensor noise. The plants are nonlinear models integrated with RK4; the controllers behave like real implementations, with sampling, saturation, anti-windup and a filtered derivative. Move a gain and the step and disturbance metrics update together with the Bode, Nyquist and closed-loop pole plots of the sampled loop. Use the presets to reproduce windup, derivative kick, sensor delay and the gap between tuning rules, then look for the lowest IAE on the gain map.
| Metric | A | B | A vs B |
|---|---|---|---|
| Rise time 10–90 % tr | — | — | — |
| Overshoot Mp | — | — | — |
| Settling time ts | — | — | — |
| IAE · step ∫|e|dt | — | — | — |
| ITAE · step ∫t|e|dt | — | — | — |
| Disturbance peak |e|max | — | — | — |
| Disturbance recovery trec | — | — | — |
| IAE · disturbance ∫|e|dt | — | — | — |
| Control RMS urms | — | — | — |
| Control activity Σ|Δu|/T | — | — | — |
| Saturated samples share | — | — | — |
Metrics use the true output, not the noisy measurement.
Full nonlinear runs of this scenario, with the edited controller's Kd, N, b and anti-windup. Click a cell to load its gains. Hatched: the run failed.
L di/dt = V − R i − Ke ω
J dω/dt = Kt i − b ω − τc tanh(ω/ωs) − τL
R = 1 Ω, L = 1.5 mH, Kt = Ke = 0.06, J = Jm(1 + JL/Jm), Jm = 10−4 kg·m², Coulomb friction 8 mN·m, |V| ≤ 24 V. Electrical (τe = L/R) and mechanical poles both appear in the loop.
m v̇ = min(F, Pmax/v) − ½ρCdA v² − Crr m g − m g sin θg
τ Ḟ = Fcmd − F
½ρCdA = 0.39 kg/m, Crr = 0.012, Pmax = 110 kW, powertrain lag τ = 0.5 s, −8 kN ≤ Fcmd ≤ 5 kN. Aerodynamic drag makes the linear model depend on the operating speed.
(M+m) ẍ − m l cos θ θ̈ + m l sin θ θ̇² = F − b ẋ
(I + m l²) θ̈ − m l cos θ ẍ − m g l sin θ = −c θ̇ + τd
M = 0.6 kg, m = 0.25 kg uniform rod (I = m l²/3), belt drive lag 20 ms, |F| ≤ 15 N. One open-loop pole sits in the right half plane. The loop sees only θ, so cart position is left free; it shows up as a slow drift mode.
m z̈ = kT ω² − m g − c1 ż − c2 ż|ż| − Fd
τm ω̇ = √(Tcmd/kT) − ω
Four rotors lumped, τm = 60 ms, 0 ≤ Tcmd ≤ 24 N, hover feedforward m0g with m0 = 1.2 kg: any other take-off mass is a load the integrator has to find. Ground contact; landing faster than 2.2 m/s is a crash.
vk = uff + Kp(b rk − yk) + Ik + Dk, uk = sat(vk)
Dk = [Tf Dk−1 + Kd Δ(c r − y)k] / (Tf + Ts), c ∈ {0, 1}
Ik+1 = Ik + KiTsek + (Ts/Tt)(uk − vk)
The back-calculation term is shown; Clamp instead stops integrating while the error drives further into saturation. The measurement is y(tk − ndTs) + σνk, with the same noise sequence for A and B. The input is held between samples (ZOH) while RK4 integrates the plant.
GZOH(z) = C(zI − Φ)−1Γ, Φ = eATs
Ms = maxω |1 / (1 + L(ejωTs))|
Ku ≈ 4d / (π√(a² − ε²))
(A, B, C) is the numerical Jacobian of the nonlinear plant at the operating point. Margins are read on the unit circle up to the Nyquist frequency π/Ts; poles are the roots of zndDcDg + NcNg, drawn as s = ln z / Ts. The relay test runs on the nonlinear plant, so its describing-function estimate can differ from the model's ultimate point.
Simulation and analysis see the same loop
The DC motor has both its electrical and mechanical poles plus Coulomb friction. The car has aerodynamic and rolling drag, a 110 kW power cap and powertrain lag. The cart-pole uses the full nonlinear equations of motion and a belt-drive lag. The quadrotor has thrust quadratic in rotor speed, motor lag and ground contact. The analysis panel linearises each nonlinear model numerically at its operating point, discretises it exactly with a zero-order hold (matrix exponential), and multiplies by the same discrete PID transfer function and delay line the simulation runs. The delay at which the phase margin runs out is the delay at which the simulation starts to oscillate.
What is simplified
Margins and poles come from the linear model at the operating point, so they don't account for saturation, large amplitudes or noise, and they don't show inter-sample behaviour (aliasing). The cart-pole loop feeds back only the angle, so it can't hold cart position; the cart's motion appears as a separate slow drift mode. Balancing on a real rail needs state feedback or a cascade loop. The relay test estimates Ku on the nonlinear plant with a describing-function approximation, so it can differ from the model's value; both are shown. Parameters are realistic component-level values, not an identification of any particular product.