The job
A control system makes something behave the way we want, on its own, with nobody watching. Our job: keep a room at 20 °C while it is 10 °C outside. The value we ask for is the goal, also called the setpoint.
The thing being controlled is called the plant; here it is the room. The quantity we care about, its temperature, is the output. Right now the room is 10 °C, as cold as outside.
We cannot set a temperature directly. We can only choose how hard the heater works, from 0 to 3 kW. The part that pushes on the plant is the actuator, and its setting is the plant's input.
Open loop
We work out once that 1.33 kW holds 20 °C on a 10 °C day and fix the heater there. The controller, the part that decides the heater power, never looks at the room. That is open-loop control. After three hours: 19.9 °C.
At three hours the outside drops to 4 °C. Nothing tells the controller, so the heater stays at 1.33 kW and the room slides down to 14.1 °C. A change nobody asked for, like this one, is a disturbance.
Closed loop
Start again, and this time add a thermometer, the sensor. It measures the room and sends the reading back to the controller. That path backwards, from the output to the controller, is feedback. It closes the loop.
The controller subtracts the reading from the goal. The difference is the error: 20 − 10 = +10 °C. A positive error means too cold, a negative one too warm, and zero means spot on.
Our rule: 5 kW of heat for every °C of error, kept between 0 and 3 kW. An error of 10 °C asks for 50 kW, more than the heater has, so it runs flat out at 3 kW.
Measure, compare, act, every six seconds. As the room warms, the error shrinks and the heater eases off. The room passes 19 °C after 21 minutes and settles at 19.7 °C, where 1.3 kW balances the heat lost.
The same cold snap hits at three hours. The error grows a little, so the heater turns itself up to 2.1 kW. The room settles at 19.6 °C. Open loop fell to 14.1 °C.
Feedback cost us a sensor and a rule, and it still leaves a small error (0.4 °C). In return it corrects for changes nobody predicted. Cruise control, autopilots and your body's temperature all work round this loop.
What is happening
# step 1/11 · goal # about: Goal 20 °C, Room (plant) goal (setpoint) 20 °C outside 10 °C room right now 10 °C A control system = something that keeps an output where we ask, without a person adjusting it by hand.
The room is a simple model with illustrative numbers: it heads towards the outside temperature plus 7.5 °C for every kW of heat, with a 40-minute time constant. Every curve and number in the figure is computed from that model. The Python on each step is plain Python 3 with the math module. It updates the controller every 0.1 minutes and moves the room forward with the exact solution of its equation between updates, just as the figure does.