On-off with hysteresis
A relay: full output below the setpoint, none above, with a hysteresis band so it doesn't chatter. The simplest controller there is, and still the right one for thermostats, sump pumps and many heaters.
Theory
An on-off loop never settles: it limit-cycles. Each time the output switches, the process carries on moving for about one dead time before it notices. The swing is therefore roughly the hysteresis band plus what the process covers in that time: .
The describing function of a relay, , predicts where the cycle settles: where .
When it works, and when it breaks
Slow processes with a lot of capacity, where a few percent of swing doesn't matter (room heating, tank top-up, sump pumps).
Actuators that only have two states: contactors, solenoid valves, single-speed pumps.
Anything that needs to hold a value closely: it always cycles.
Modulating valves and drives: switching between 0 and 100 % wears them out fast.
Processes with dead time: the swing grows with θ/τ.
How to tune it
There is only the hysteresis band, and it trades swing against switching rate. Widen it until the actuator's starts per hour are acceptable (motors and contactors have a rated number). For heaters, time-proportioning (PWM) turns the same relay into a proportional controller.
How to implement it
Compare against SP ± b/2 and keep the state: inside the band the output does not change. Add minimum on and off times for motors and compressors. Make the band large enough to cover the measurement noise, or noise alone will toggle the output.
Siemens and elsewhere
A few lines of SCL or LAD with a set/reset (SR) bistable. For heaters on an S7-1200/1500, PID_Compact's Output_PWM or CTRL_PWM gives time-proportioning from a PID output instead.
Every platform has a hysteresis/comparator block (CODESYS Util HYSTERESIS, for example). Building management systems run on-off with dead bands almost everywhere.
Interactive Controller Sandbox
Test and tune On-off with hysteresis live on a process, benchmark against baseline PI, and inspect the resulting code.
Closed-Loop Response: On-off vs Baseline PI
Simulating…// Loop Lab export: Liquid flow loop, FIC-101
// TIA Portal SCL (S7-1200 / S7-1500). Generated code: review before use on a real plant.
FUNCTION_BLOCK "LL_OnOff"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
VAR_INPUT
Setpoint : Real; // m³/h
Input : Real; // m³/h
END_VAR
VAR_OUTPUT
Output : Real; // %
END_VAR
VAR
Hysteresis : Real := 1.2; // m³/h, total band
OutOn : Real := 100.0;
OutOff : Real := 0.0;
IsOn : Bool;
END_VAR
BEGIN
IF #Input < #Setpoint - #Hysteresis / 2.0 THEN
#IsOn := TRUE;
ELSIF #Input > #Setpoint + #Hysteresis / 2.0 THEN
#IsOn := FALSE;
END_IF;
IF #IsOn THEN
#Output := #OutOn;
ELSE
#Output := #OutOff;
END_IF;
END_FUNCTION_BLOCK
// OB30 "Cyclic interrupt", cycle time 0.1 s (100 ms).
// "FT-101" is the scaled input (NORM_X/SCALE_X from the analog card), "FV-101" the output to scale back to 0-27648.
"FIC_101_DB"(Setpoint := "SP", Input := "FT-101");
"FV-101" := "FIC_101_DB".Output;