On/off control: the bang-bang thermostat
Your heating clicks on, then off, then on again all evening. Is it broken, or is that the plan?
About 25 min · 3 goals · Checked by automated tests; not yet reviewed by an educator
1.Why should I care?
The simplest feedback controller is a switch: full on or full off. Thermostats, fridges and ovens have used it for a century because it's cheap and robust. Understanding its wobble is the first step to designing something smoother.
- ◇ Describe how an on/off (bang-bang) controller works.
- ◇ Explain why its temperature wobbles around the target.
- ◇ Describe the trade-off set by the gap between switch-on and switch-off.
2.Predict
A heater switches ON when the room is below 17.9 °C and OFF above 18.1 °C. Compared with switching at 17.5 and 18.5 °C, what happens?
Guess first. Being wrong here is how the surprise works.
3.Discover
With 'On/off', try a gap of 0.2 °C, then 1 °C, then 4 °C. For each, note how much the temperature swings and how many times the heater switched.
Thermostat: on/off or in proportion?
A cold room (10 °C, 5 °C outside) and a heater. Compare a heater that is only ever fully on or off with one that heats in proportion to how cold it still is.
Blue line: room temperature (°C). Dashed lime: target. Orange bars: heater power. Bottom axis: minutes.
Last 30 minutes: average 18 °C, swinging 1.2 °C up and down. The heater switched 13 times in 2 hours. A smaller gap holds the temperature tighter but switches more often.
Can't use the interactive? Read a description instead
The thermostat plot can be replaced by these results from the same simulated room, target 18 °C. On/off with a 0.2 °C gap: swings about 0.5 °C, about 37 switches in 2 hours. 1 °C gap: swings about 1.2 °C, about 13 switches. 2 °C gap: swings about 2.4 °C, about 7 switches. In every case it takes about 34 minutes to warm up from 10 °C.
4.Watch
→ Watch for the trick old thermostats use to stop the heater switching too often.
Opens up classic thermostats to show the clever mechanical tricks behind simple on/off temperature control.
17 min 3 s · captions on YouTube · source
Nothing loads from YouTube until you press play.
5.Understand
Full on or full off
A bang-bang controller has only two actions. Below the target: heater fully on. Above it: heater fully off. It's a single IF–THEN–ELSE rule inside a forever loop.
Why it wobbles
The heater can't be 'a bit on', so the temperature overshoots while it's on and drops while it's off. It never settles exactly on the target; it oscillates in a band around it.
The gap (hysteresis)
Switching at exactly one temperature makes the heater chatter on and off. So thermostats use two thresholds, a switch-on and a higher switch-off. The space between is called hysteresis. A small gap gives steadier temperature but more switching; a big gap gives fewer switches but bigger swings.
Explain it another way
Steering a bike by only ever turning the handlebars fully left or fully right. You'd still go roughly straight, but you'd zig-zag the whole way.
Bang-bang control with hysteresis: u = 1 if y < r − h/2, u = 0 if y > r + h/2, otherwise keep the previous u. The output oscillates; the band width and switching rate depend on h and how fast the system heats and cools.
Fridges switch their compressor on and off with a few degrees of hysteresis. A fridge that switched every few seconds would wear out its compressor in months.
Worked example 1
A thermostat is set to 20 °C with a 2 °C gap. When does the heater switch on, and when off?
The gap is split evenly around the target: switch on below 19 °C, switch off above 21 °C. Between 19 and 21 °C it keeps doing whatever it was already doing.
Common mix-ups
- A thermostat that clicks on and off a lot is broken.
✓ Switching on and off is how bang-bang control works. Only very rapid switching suggests the gap is too small. - On/off control is too crude to be useful.
✓ It's cheap, robust and good enough for fridges, ovens and heating everywhere.
6.Practice
Practice, not a test. Wrong answers get a hint and another try.
Practice 1
Why does a bang-bang thermostat never hold the temperature exactly on target?
Practice 2
A thermostat targets 22 °C with a 3 °C gap split evenly. Below what temperature does the heater switch on, in °C?
Practice 3
An engineer shrinks the gap from 2 °C to 0.2 °C. What happens?
Practice 4
Gap set: on below 17 °C, off above 19 °C. The heater is ON and the room reaches 18 °C. What does it do?
7.Apply it
Design an on/off controller for a fish tank heater that keeps the water between 24 and 26 °C. Write the two thresholds and the rule. What would happen if a fish tank heater switched too often?
8.Reflect
Concepts: Open-loop and closed-loop control · Thresholding and simple classification