Control systems
Enter a plant as a transfer function — polynomials or poles, zeros and gain, continuous or sampled — or pick a DC motor, mass–spring–damper, inverted pendulum, thermal or dead-time preset, add a P, PI, PID or lead/lag controller, and see the step and impulse responses with rise, overshoot, settling and steady-state error, the Bode plot with gain and phase margins, the Nyquist plot, a root locus you drag the gain along, and the closed-loop pole–zero map, with Ziegler–Nichols, IMC and SIMC tuning.
Added
How to use it
A feedback loop on one page: a plant G, a controller C and unity negative feedback. Change anything and all six plots and the figures above them follow. It is the frequency-domain and root-locus side of control; for a PID in the time domain with output limits, anti-windup, a load disturbance and C code, use the PID loop simulator.
How to use it
-
Plant G. Pick a preset or type your own. In Polynomials, write the numerator and denominator as expressions —
(s+1)^3,2s(s+3),s^2 + 0.5s + 4— or as coefficient lists, highest power first:1 3 3 1. In Poles / zeros, list them withjorifor the imaginary part and±for a pair:-1, -2±3j; a lone complex value gets its conjugate added. Switching between the two converts what is there. Presets have their physical parameters as fields (the motor’s inertia and winding resistance, the pendulum’s length…); changing one rebuilds the polynomials. -
Dead time (seconds) multiplies the plant by e^−sθ. It is exact in the Bode and Nyquist plots and in the time responses (simulated with a delay line); the root locus and pole–zero map need a rational function, so they use the Padé approximant whose order you choose under Options.
-
Sampled control. Tick Sampled controller and give a sample time T: the plant is discretised with a zero-order hold (exactly, through the matrix exponential), dead time becomes whole samples of z^−1, and the controller is turned into z with the Tustin (bilinear) transform. Or choose Plant in z and type a discrete plant directly. Discrete plots show samples, the unit circle and frequencies up to π/T.
-
Controller C. P, PI, PD, PID (parallel gains, with the derivative filtered: Kd·s/(Tfs + 1), Tf = (Kd/Kp)/N) or a lead/lag K(s + z)/(s + p) — a lead when the zero is nearer the origin than the pole. The Gain slider scales all the gains together.
-
Root locus. The branches show where the closed-loop poles go as the loop gain grows from 0 (× marks, the open-loop poles) towards the zeros (○) or off along the asymptotes. The filled dots are the closed-loop poles at the gains you have now. Drag along a branch to put a pole where you want it; the gains, every plot and the figures follow. Small squares mark break-away points.
-
Tuning helpers. The ultimate gain Ku and period Pu come from the plant’s gain margin, and give the Ziegler–Nichols rules (and a no-overshoot variant). A first-order-plus-dead-time model fitted to the plant’s step response gives IMC PI/PID and Skogestad’s SIMC PI, with λ (or τc) defaulting to the dead time. Use copies the gains into the controller.
Reading the figures
-
Rise time is 10 % to 90 % of the final value; overshoot is the peak above it; settling is the last time the response leaves the ±2 % band; steady-state error is 1 − T(0) for a unit step. They are only shown for a stable closed loop.
-
Gain margin is how many times (in dB) the gain can grow before the loop goes unstable, read where the phase crosses −180°. Phase margin is how much extra lag it can take, read where |L| = 1. For an unstable plant such as the pendulum the gain margin can be negative: the gain must stay above that.
-
On the Nyquist plot, the loop is stable when the curve circles −1 anticlockwise once for every unstable open-loop pole (none for most plants).
-
The pole–zero map draws rays for damping ratio 0.5 and 0.707 in the s-plane. Poles on the wrong side of the axis (or outside the unit circle) are red.
The presets
-
Three lags 1/(s+1)³ — the textbook case: Ku = 8 at ω = √3, tuned here with Ziegler–Nichols.
-
DC motor (speed / position) — voltage to shaft speed Kt/((Js + b)(Ls + R) + Kt²), and its integral.
-
Mass–spring–damper — 1/(ms² + cs + k).
-
Inverted pendulum (linearised) — angle per unit force near upright, (1/Ml)/(s² − (M + m)g/(Ml)), with the sign chosen so positive gains stabilise it. One open-loop pole is in the right half plane; watch the Nyquist plot circle −1.
-
Thermal (two lags), First order + dead time, First order and the Type-1 servo 1/(s(s+1)).
How it works
Roots come from Aberth–Ehrlich iteration (Newton’s method on all roots at once, each pushed away from the others) polished with Newton steps on the original polynomial. The step response is exact at its samples: the closed loop is put in controllable canonical state-space form and discretised with the matrix exponential of ·Δt. With dead time the loop has no rational transfer function, so the controller and plant are discretised separately and joined through a delay line. The Bode phase is unwrapped factor by factor — each pole and zero contributes its own continuous angle — so it runs past −180° without jumping. The root locus steps the gain geometrically and shortens the step wherever a root would jump. Everything is checked in tests against textbook values: the 1/(s+1)³ ultimate gain, second-order overshoot e^(−ζπ/√(1−ζ²)), the ZOH equivalent of 1/(s(s+1)), and break-away points.
Related: the ODE solver for the nonlinear pendulum behind the linear model, analog design and the active filter designer for Bode plots of real circuits, and Fourier series for where frequency response comes from.
Feedback is a gift. Something to improve, a feature to add, or a bug? Tell me.
Runs entirely in your browser; nothing you type leaves this page.