Lite / Textbooks / Feedback and Control / Chapter 2
2. On/off control and hysteresis
Introduction
The simplest controller has two moves: full on or full off. A thermostat switches the heater on when the room is cold and off when it is warm. With one threshold, noise near the setpoint makes the relay chatter; with two thresholds, a hysteresis band, the controller keeps its last decision inside the band. A wider band means fewer switches and bigger swings; choosing it is a trade-off, not a fix.
Figure 2.1. Two thresholds stop the chatter (described in words)
A hysteresis loop for a heater: on below 19 °C and off above 21 °C. Between them lies a band 2 °C wide, shaded, in which the heater keeps whatever state it was last in.
Explanation
Built from 2 School lessons. Each part is the lesson's own explanation.
2.1 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?
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.
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.
Open the Lite lesson: On/off control: the bang-bang thermostat
2.2 On/off control and hysteresis
A heater with a single switch-point clicks on and off dozens of times a minute when the temperature hovers near it. How do real thermostats stop that?
Bang-bang control
On/off control has two outputs: full power or none. If too cold, heater on; if warm enough, heater off. The temperature therefore rises and falls around the setpoint in a sawtooth. It is cheap and robust, and the swing is often acceptable for rooms, fridges and greenhouses.
Two thresholds, not one
Hysteresis uses separate thresholds: switch on below the lower one and off above the upper one; between them, keep doing whatever you were doing. In code:
if temp < ON_BELOW:
heater = True
elif temp > OFF_ABOVE:
heater = False
# otherwise: no changeNotice it is a two-state machine: the heater's current state decides what happens in the band.
Choosing the band
A wider band means fewer switchings (less wear on relays and compressors) but a bigger temperature swing. A narrower band holds the temperature tighter but chatters with noise. A good rule: make the band clearly wider than the sensor noise, and place it so the swing stays inside the comfort range, remembering the temperature overshoots a little after each switch.
Common mix-ups
Hysteresis makes the controller less accurate, so avoid it.
✓ It deliberately allows a small swing to stop chattering. Without it, noise wears out relays and can cause rapid cycling.The temperature stays inside the band.
✓ Thermal lag makes it overshoot both thresholds a little. Leave room for that.
Open the Lite lesson: On/off control and hysteresis
Worked examples
On/off control: the bang-bang thermostat: example 1
A thermostat is set to 20 °C with a 2 °C gap. When does the heater switch on, and when off?
Solution
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.
On/off control and hysteresis: example 1
Seedlings must stay between 16 and 24 °C. The thermometer jitters by about ±0.3 °C, and the air overshoots by about 0.5 °C after each switch. Suggest thresholds.
Solution
Keep the lowest dip (on-threshold minus overshoot minus noise) above 16 °C: on below about 16.8 °C. Off above about 18.5 °C gives a 1.7 °C band, much wider than the 0.6 °C noise, and stays far below 24 °C. Then test in the simulator, because the overshoot estimate is a guess.
Interactive figures, in words
Figure 2.2 from On/off control: the bang-bang thermostat
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.
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.
Laboratory
These run in a browser on the full site (they need a faster connection). Simulations are simplified educational models.
- Simulation OS: Greenhouse through a cold night (Simulation OS experiment)
Keep the seedlings between 16 and 24 °C with an on/off heater and count how often it switches.
Open on the full site - BUILD: Smart greenhouse, level 3 (BUILD level)
Choose a hysteresis band that survives the open vent without the heater chattering.
Open on the full site
Practice
Each question links to its Lite lesson, where your answer is checked on our server and a wrong answer gets a hint. Answers are never sent to your device.
- Why does a bang-bang thermostat never hold the temperature exactly on target?
Answer it in “On/off control: the bang-bang thermostat” - An engineer shrinks the gap from 2 °C to 0.2 °C. What happens?
Answer it in “On/off control: the bang-bang thermostat” - Gap set: on below 17 °C, off above 19 °C. The heater is ON and the room reaches 18 °C. What does it do?
Answer it in “On/off control: the bang-bang thermostat” - A thermostat uses a setpoint of 20 °C and a total hysteresis band of 3 °C, centred on the setpoint. Below what temperature does the heater switch on, in °C?
Answer it in “On/off control and hysteresis” - With 'on below 17, off above 19', the heater is ON and the temperature is 18.2 °C. What does the controller do?
Answer it in “On/off control and hysteresis” - What do you trade when you widen the hysteresis band?
Answer it in “On/off control and hysteresis” - Your thermometer jitters by ±0.4 °C. Which band is most likely to chatter?
Answer it in “On/off control and hysteresis”
Engineering applications
Fridges and boilers
Fridges, kettles and many boilers are on/off controllers with hysteresis. The band is chosen so the compressor or burner is not switched too often, which would wear it out and waste energy.
Schmitt triggers
Digital inputs often include hysteresis in hardware, a Schmitt trigger, so a slowly changing or noisy voltage produces one clean transition instead of a burst of false edges.
Watch (optional)
Streaming video uses a lot of data. Everything you need is in the text.
- “Thermostats: Cooler than you think!” by Technology Connections
- “Cheese, Catastrophes, & Process Control: Crash Course Engineering #25” by CrashCourse
Summary
- On/off control applies full effort or none, so the output always oscillates around the setpoint.
- A single threshold chatters when noise crosses it repeatedly.
- Hysteresis uses separate on and off thresholds; inside the band the last state is kept.
- A wider band means fewer switches but larger swings.
Glossary
- On–off control with hysteresis
- On–off control switches the actuator fully on or off; hysteresis uses two thresholds, one to switch on and a different one to switch off, so the output does not chatter around a single value. Field Guide
- Setpoint and error
- The setpoint (or reference) is the value you want; the error is the setpoint minus the measured value. Controllers act on the error. Field Guide
- Closed-loop (feedback) control
- Closed-loop control measures the output, compares it with the target and adjusts the command to shrink the difference, over and over. Field Guide
Project: Design a thermostat band
A heater warms a small room by 1 °C per minute and the room cools by 0.5 °C per minute when it is off. For bands of 0.5, 1 and 2 °C around 20 °C, estimate the switching period and the temperature swing, and recommend a band for comfort and for relay life.
Deliverables
- Switching period and swing for each band
- A sketch of temperature against time for one band
- A recommendation with its trade-off
Write it up on paper or in your own notes. Lite never stores what you write.
References
- Karl Johan Åström and Richard M. Murray (2008). Feedback Systems: An Introduction for Scientists and Engineers. Princeton University Press.
- Gene F. Franklin et al. (2015). Feedback Control of Dynamic Systems, 7th edition. Pearson.