Control Systems: Introduction
A small aluminium block with a power resistor bolted to it has to sit at for a sensor calibration, whatever the room does. Switch on a fixed voltage and the block creeps towards some temperature over a quarter of an hour, overshoots nothing, and ends wherever the room and the airflow put it. Measure the temperature, compare it with and let the difference decide the heater power, and the block gets there in a couple of minutes and stays there when someone opens a window. That comparison, made continuously and automatically, is feedback control, and this course is about designing it so it is fast, accurate, robust and safe.
By the end you should reach the milestone of the roadmap stage this course follows: model, implement, tune and evaluate a closed-loop control system. The roadmap's practical projects run through the course as guided labs: model a DC motor, control its speed from a microcontroller, tune a PID controller and compare tuning methods, build a low-voltage temperature loop, and simulate a multivariable system.
Where this course starts
You need the Laplace transform and transfer functions from Circuit Theory and Signals and Systems, linear ODEs from Differential Equations, and for the state-space part matrices and eigenvalues from Linear Algebra. Sampling and the z-transform are in Signals and Systems; op-amp feedback and its stability are in Analog Electronics. This course links to those lessons instead of repeating them and spends its time on the control engineer's questions.
The course map
| Section | You will be able to | Labs and tools |
|---|---|---|
| Getting started | explain what feedback buys (and costs): sensitivity, disturbance rejection, noise | ee-pid-loop, python-control |
| Modelling dynamic systems | write ODE models of electrical, mechanical, electromechanical, thermal and fluid systems; linearise them | SciPy solve_ivp, ee-rc-rl-transient |
| Transfer functions and block diagrams | reduce block diagrams and signal-flow graphs to one transfer function | python-control feedback, series, SymPy |
| Time response | predict rise time, overshoot, settling time and steady-state error from poles and system type | ee-rlc-resonance, ee-pid-loop, step_info |
| Stability and root locus | test stability with Routh–Hurwitz; sketch and use the root locus | ee-pid-loop, root_locus_map |
| Frequency-response methods | read Bode and Nyquist plots of the loop, gain and phase margins, delay | ee-bode-plot, margin, nyquist_response |
| Compensator design | design lead, lag and lead-lag compensators to a specification | ee-bode-plot, python-control |
| PID control | choose a PID structure, tune it (Ziegler–Nichols, Cohen–Coon, IMC/lambda) and fix the practical problems | ee-pid-loop, NumPy loop simulations |
| State-space control | build state models, test controllability and observability, place poles, design observers and LQR | ss, ctrb, obsv, place, lqr |
| Digital control | discretise with a zero-order hold, write a discrete PID, design in the z-plane, choose the sample rate | c2d, NumPy |
| Nonlinearities and structures | handle saturation, dead zone and backlash; use cascade, feedforward and ratio control | NumPy simulations |
| Industrial automation | pick sensors and actuators, read PLC programs (ladder, structured text, function blocks) and reason about scan cycles, interlocks and SCADA | Python scan-cycle simulations |
Conventions used throughout
| Symbol | Meaning | Unit (typical) |
|---|---|---|
| , , | reference (setpoint), measured output, error | the process unit (K, rad/s, m) |
| controller output, actuator command | V, W, % | |
| , | load disturbance, measurement noise | as or |
| , | plant (process with actuator and sensor), controller | — |
| loop transfer function | — | |
| , | sensitivity and complementary sensitivity | — |
| , | natural frequency, damping ratio | rad/s, — |
| , , | PID gains in the parallel form | per , per , per |
| sample period of a digital controller | s |
Angular frequencies are in rad/s, as python-control and SciPy use them; divide by for hertz. Rise time is 10–90 %, settling time is to the band unless a lesson says otherwise. Negative feedback is assumed: .
python-control is imported as ct. Two functions are worth knowing from the start: ct.feedback(L, 1) closes a unity-feedback loop, and ct.margin(L) returns (gm, pm, w_pc, w_gc): the gain margin (as a ratio) and phase margin (degrees), then the phase-crossover frequency where the gain margin is measured and the gain-crossover frequency where the phase margin is measured. Two reference plants recur in the labs:
| Plant | Model | Numbers |
|---|---|---|
| Heater block | from heater power (W) to temperature rise (K), later with a sensor delay | , , heater on : |
| Small DC motor | armature , , constant , inertia , friction | , , , , , |
A first loop in Python
Given: the heater block, (K/W), a target rise of above a room.
Find: how long the block takes to settle with a fixed (open loop), and with a proportional controller , (closed loop); the steady-state error of each.
Solve:
- Open loop: final rise exactly, if the model is right. The 2 % settling time of a first-order system is , about 20 minutes.
- Closed loop: , . The loop is nine times faster (, settling ) but ends at : a steady-state error of .
- The heater must deliver at the first instant, more than its : the real loop saturates and is slower than the linear model says. This is the first lesson of control: the linear model is a start, actuator limits decide the rest (Anti-Windup).
Check: the program below computes the same numbers and also tries a PI controller, whose integral action removes the error.
import numpy as np
import control as ct
G = ct.tf([4], [300, 1]) # heater block: K per W
for name, C in (("P Kp=2", ct.tf([2], [1])),
("PI Kp=2, Ki=0.02", ct.tf([2, 0.02], [1, 0]))):
T = ct.feedback(C * G, 1)
info = ct.step_info(T, T=np.linspace(0, 1500, 15001), SettlingTimeThreshold=0.02)
print(f"{name:18s}: final {25 * ct.dcgain(T):5.2f} K for a 25 K step, "
f"settling {info['SettlingTime']:6.1f} s, overshoot {info['Overshoot']:4.1f} %")
info = ct.step_info(G, T=np.linspace(0, 3000, 30001), SettlingTimeThreshold=0.02)
print(f"open loop at 6.25 W : final {6.25 * ct.dcgain(G):5.2f} K, settling {info['SettlingTime']:6.1f} s")P Kp=2 : final 22.22 K for a 25 K step, settling 130.5 s, overshoot 0.0 %
PI Kp=2, Ki=0.02 : final 25.00 K for a 25 K step, settling 309.0 s, overshoot 9.8 %
open loop at 6.25 W : final 25.00 K, settling 1173.7 s
The PI loop reaches exactly , but with these gains it overshoots by and needs to settle: the slow integral action (its zero sits at ) has to trim the last few kelvin. Why integral action removes the error, and what it costs, is the subject of Steady-State Error and the PID section.
The PID lab
Most lessons use one lab: a unity-feedback loop with a PID controller around a first- or second-order plant. Its defaults (plant , , , ) give an overshoot of , a rise time of and a settling time of . Set and watch the steady-state error appear ( leaves ); raise and watch the overshoot grow.
The lab's derivative is ideal (no filter) and the actuator has no limits, so it shows linear behaviour only; Practical PID and Anti-Windup add what real controllers need.
Safety in this course
Hands-on labs here use a bench supply set to at most DC with its current limit set, small DC motors and fans, power resistors as heaters, and USB-powered microcontroller boards. Industrial machinery, mains motor starters, variable-frequency drives on mains, and safety PLCs are taught as concepts and simulations only. Two hazards are real even at low voltage: a heater resistor that reaches (burns, melted plastic: mount it on a metal block, add a thermal fuse or a software cut-off, never leave it unattended) and a motor shaft or propeller that starts unexpectedly (guard it, clamp the motor, keep fingers and hair away). Every guided lab repeats the hazards that apply to it.
Practice
- A loop has . Give the closed-loop DC gain and time constant with unity feedback, and the steady-state error to a unit step.
- In the heater example, which (P only) would bring the steady-state error to 2 %? What initial heater power would a step then ask for?
Answer
- : DC gain , , error .
- Error gives ; the first instant asks for , about 21 times the heater's . High proportional gain alone is not the answer.
Test yourself
What makes a control loop *closed*?
- the actuator is switched on
- the measured output is compared with the reference and the difference drives the actuator
- the plant is stable
- the controller has an integrator
With unity feedback and , the closed-loop time constant is
ct.margin(L) in python-control 0.10 returns
- (phase margin, gain margin)
- (gm, pm, phase-crossover frequency, gain-crossover frequency)
- (gm in dB, pm, bandwidth)
- the closed-loop poles
Why did the proportional heater loop with not behave like its linear model at the start of a step?
- the sensor was too slow
- it asked for from a heater, so the actuator saturated
- the model was unstable
- the integral term wound up