Skip to content
Lab
control engineering workbench sampled PID · loop shaping · anti-windup · relay tuning

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.

Presets
t 0.00 s READY
Plant view A B setpoint
setpoint r—
y A—
y B—
e A / B—
u A / B—
aux—
Telemetry vs. time A B r u limits P I D
Run summary not started
MetricABA 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.

Loop analysis · L(z) = C(z) GZOH(z) z−nd A B Ms circle open-loop pole
phase margin——
gain margin——
crossover ωc——
peak sensitivity Ms——
delay margin——
dominant ζ · ωn——
closed loop——
Gain map · IAE over Kp × Ki queued

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.

Plant model · DC motor

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.

Discrete PID (ISA form, 2-DOF)

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.

Analysis & tuning

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.

What is modelled

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.

integrator
RK4 · ZOH
controller
ISA 2-DOF PID
analysis
exact L(z)
gain map
22 × 22 runs
Scope & limits

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.