Lite / Building Machines That Respond / Week 26
Proportional control: push harder when further away
On/off heaters are either flat out or off. What if the heater could push gently when you are nearly there?
Why should I care?
Proportional control is the first step towards the PID controllers inside drones, cruise control and 3D printers. With PWM from last week, a heater or motor can deliver any fraction of full power, and the simplest good rule is to make that fraction proportional to the error.
- Apply the proportional rule effort = gain × error, with limits on the effort.
- Predict where a proportional heater settles and the leftover (steady-state) error.
- Explain how raising the gain changes the leftover error and the risk of instability.
Predict
A proportional heater has reached a steady temperature on a cold night. Is it exactly at the setpoint?
- Yes, exactly
- No, a little below: it needs some error to keep the heater on at all
- It keeps oscillating forever
Guess first, then reveal
Effort = gain × error. To replace the heat leaking out, the heater must be on, which needs a positive error. So it settles a little **below** the setpoint: the **steady-state error**. A bigger gain shrinks it but never removes it.
Discover
Choose Proportional. With the setpoint at 18 °C and outside at 5 °C, try a gain of 400 W per °C and read where it settles. Raise the gain to 1,500 and 3,000. Then switch to On/off and compare the energy and switching.
What the interactive shows (text version)
The thermostat diagram plots 300 minutes of greenhouse temperature from a 12 °C start, with the setpoint, a ±1 °C band and the heater power underneath. In proportional mode the power is gain × error, limited to 0–3,000 W; the temperature settles below the setpoint at (100 × outside + gain × setpoint) ÷ (100 + gain), and the readout states that value. In on/off mode the heater is full on below the band and off above it, and the readout counts switchings.
Understand
The proportional rule
effort = Kp × error. Big error, big effort; small error, small effort; no error, no effort. With PWM, 'effort' can be a duty cycle. Two practical limits: a heater cannot cool, so negative effort is clipped to 0, and it cannot exceed full power, so large efforts are clipped to 100%. When clipped, the controller is saturated and behaves like on/off.
The leftover error
On a cold night the heater must keep supplying heat. A proportional controller only supplies heat when there is an error, so it settles where the error is just big enough: the steady-state error. More gain means less error is needed, so it settles closer. Removing the error completely needs another idea, integral action, which you meet in Level 3.
Too much gain
Real systems have delays: the heater warms up, air takes time to mix, the sensor responds slowly, and firmware samples at intervals. With a very high gain, the controller overreacts to each change and can overshoot or oscillate. Engineers raise the gain until the error is small enough and stop well before the response turns twitchy.
Explain it another way
Intuitive
Braking for a red light: far away, you brake gently; close, you brake harder. Your effort follows how far you still have to go.
Technical
P-only control of a first-order plant with gain K gives steady-state error r/(1 + Kp·K) for a step (the Playground's formula). With delay or second-order dynamics, high Kp reduces stability margins.
Mathematical
u = clamp(Kp·e, 0, u_max); steady state T* = (UA·T_out + Kp·r)/(UA + Kp); error r − T* = UA(r − T_out)/(UA + Kp).
Applied
Smart Greenhouse Level 4 uses the same settling formula with its own greenhouse numbers: P control at Kp = 400 W/°C settles at 14.6 °C at 03:00 against an 18 °C setpoint, which is why PI control is needed to pass.
Derivation: Where a proportional heater settles
Controller: heater power P = Kp × (r − T), limited to 0–3,000 W. (r = setpoint, T = temperature, Kp in W per °C.)
Greenhouse: heat leaks out at UA × (T − T_out) watts, with UA = 100 W per °C in the model.
Steady means heat in = heat out: Kp × (r − T) = UA × (T − T_out).
Expand and collect the T terms: Kp·r + UA·T_out = (UA + Kp) × T.
So T = (UA·T_out + Kp·r) ÷ (UA + Kp). With UA = 100, T_out = 5 °C, Kp = 400, r = 18 °C: T = (500 + 7,200) ÷ 500 = 15.4 °C, 2.6 °C short.
Kp = 1,500 gives (500 + 27,000) ÷ 1,600 ≈ 17.2 °C: closer. The error shrinks as Kp grows but only reaches zero if Kp were infinite.
Worked example 1
Kp = 25% per °C, setpoint 20 °C. Efforts at 19 °C, 16 °C and 21 °C?
19 °C: 25 × 1 = 25%. 16 °C: 25 × 4 = 100%, the limit: 100% (saturated). 21 °C: 25 × (−1) = −25% → clipped to 0%.
Common mix-ups
A proportional controller reaches the setpoint exactly, given time.
✓ Against a steady heat loss it settles short of the setpoint. That offset is built into the rule.Turn the gain up as high as possible.
✓ Delays in real systems make very high gains overshoot or oscillate.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
In the thermostat diagram, find the smallest gain that keeps the greenhouse within 1 °C of an 18 °C setpoint at 300 minutes with 5 °C outside. Check it against the settling formula, then compare its energy with an on/off thermostat with a 1.5 °C band.
Reflect
Proportional or on/off for the term project's greenhouse? Give one reason for each and decide.
Write your answer on paper or in your own notes. Lite never stores what you write.