7.4. Bang-Bang Control#
Bang-bang control is the simplest form of closed-loop control. The actuator is either fully ON or fully OFF, depending on whether the measured value is above or below the target.
This makes bang-bang control easy to design and inexpensive to implement. However, it usually results in some oscillation around the target value, because the system overshoots and then corrects repeatedly.
Examples:
Fridge - the compressor switches on when the inside warms above a threshold, and off when it cools enough.
Electric kettle - turns the heating element on until the water boils, then shuts off completely.
7.4.1. Programming Bang-Bang Control#
To implement bang-bang control we need to define the setpoint, read the sensor measuring the process variable and switch the actuator on or off accordingly.
setpoint = TARGET_VALUE # the goal we want to reach
while True:
measured_value = read_sensor() # current value of process variable
if measured_value < setpoint:
actuator_on() # fully ON
else:
actuator_off() # fully OFF
7.4.2. Oscillation#
In bang-bang control the actuator switches on as soon as the measurement drops below the setpoint, and off as soon as it crosses above. Under this control system we often find that the process variable bounces around the setpoint, which is called oscillation.
This is due to either or both of the following:
Switching delay - if the system takes infrequent measures or if the actuator is slow then there is a delay introduced
Actuator inertia - if the actuator continues to act, even after being switched off then the process variable will continue to increase.
Consider the example of a kettle, the heating element will still produce heat after being switched off as the metal is still hot.
7.4.3. Suitability of Bang-Bang Control#
Bang-bang control is ideal when:
The system can tolerate some fluctuation around the target.
The actuator is naturally on/off (heater, pump, valve).
Simplicity and low cost are more important than precision.
7.4.4. Double-Setpoint Control#
An extension of bang-bang control is double-setpoint control. Instead of switching a single actuator on and off around one threshold, the controller defines two setpoints: a lower limit and an upper limit. This is useful in systems where the actuator can work in both directions, or where there are two opposing actuators (one to increase and one to decrease the measured value).
For example, consider an air conditioner with both heating and cooling functions. We want to keep a room close to 22 °C, but the system has two possible actions:
Heating when it gets too cold.
Cooling when it gets too hot.
In double-setpoint control we might set:
Lower limit = 21.5 °C → heater ON when below this value.
Upper limit = 22.5 °C → cooler ON when above this value.
Between 21.5 °C and 22.5 °C → do nothing.
This creates a deadband where the system is idle, avoiding constant toggling of heaters or fans when the temperature is already “good enough.”
Question 1
Why does a bang-bang controller often cause the process variable (e.g. temperature) to oscillate above and below the setpoint?
Solution
Because the controller only reacts after the setpoint is crossed. By the time the actuator is switched off, the system still has inertia (thermal, mechanical, etc.), which carries it past the setpoint. When the actuator is off, the system drifts back the other way until the lower threshold is crossed again, creating continuous oscillation.
Question 2
An oven uses bang-bang control to maintain 180 °C. Describe what happens if the oven has a large thermal mass compared to if it has a small thermal mass.
Solution
Solution is locked
Question 3
A water tank is kept between 30% and 80% full using double-setpoint control of a pump. Why are two thresholds used instead of a single setpoint?
Solution
Solution is locked