Name:
UNION COLLEGE
Electrical, Computer, and Biomedical Engineering Deptartment
ECE-366 Control Systems
Laboratory Experiment 2
Winter 2026
The Hysteresis (Bang-Bang) Controller
Objectives:
1. Tune your controller on a Simulink model of your system
2. Implement the controller in hardware and compare to your simulation
3. Fine tune your controller as needed
Equipment
• A computer with MATLAB/Simulink
• The Arduino heater
• Lab 3 Simulink files
Report:
There is no formal report for this lab. Turn in a short write-up that answers the questions
asked below and includes the requested figures.
1
1
Background
1.1
The Bang-Bang Controller
While a PI-controlled heating system is considered a “modern” solution, many heating systems still use what’s called the hysteresis controller, also known as the “bang-bang” controller. This nonlinear controller in its simplest form works like this:
• If the room temperature is too low, the heater is turned completely on (100% in our
case).
• If the room temperature is too high, the heater is turned completely o! (0% in our
case).
This can be tuned with the on-o! logic. For example, if the room temperature is 15→ C
and the set-point is 20→ C, the bang-bang controller turns the heater completely on until
the room reaches the set-point and goes slightly over, e.g. until temperature is 22→ C. Then
the heater turns completely o! until the temperature drops slightly below the set-point, e.g.
to 18→ C. Then the heater turns completely on again until we’re back to 22→ C and so on.
The room temperature “bangs” against upper and lower limits while keeping the average
temperature at 20→ C.
While this is a perfectly fine solution, it may be uncomfortable to have such temperature
swings. Or perhaps, this is an application that requires precise temperature control. Furthermore, the constant cycling between fully on and fully o! can be quite ine”cient compared
to the PI controller where the heater is always on, but not at full blast.
2
Procedure
2.1
Measure Ambient Temperature
1. Connect the Arduino Heater as you did last week. Make sure you are using the same
hardware as you did last week so that your model is a match.
2. Open the TemperatureMon.slx Simulink file from last week and run it. Write
down the ambient room temperature in Celsius.
3. STOP the TemperatureMon file before proceeding.
2
2.2
Simulation Tuning
Open the Hysteresis Simulator.slx file. Note the following blocks:
• Hysteresis Control: This block operates on the error between the desired temperature and the actual temperature. You can tune the switch-on and switch-o! points,
as well as the heater values during the on and o! states. The model starts with a
switch-on of 5 degrees to a value of 100, and switch-o! of -5 degrees to a value of 0.
This means that when the desired temperature is 5 degrees warmer than the actual
temperature, the heater is on full power until the desired temperature is 5 degrees
colder than actual, at which point the heater is o!. Then the process repeats.
• Delay: This models the delay in our system. Keep this as 0 seconds for now.
• First-Order TF: This is a first order transfer function with some default values typical
for these heaters. You should edit this to match your model from last week.
Once you’ve updated the First-Order TF block with your device’s gain and pole, run the
Simulink model and look at the plots. In Table 1 below, record the minimum, maximum,
and average temperatures. How do these compare with the desired temperature and the
hysteresis switch-on/switch-o! values? Also note the duty cycle. Repeat this with the
hysteresis set to ± 2→ and ± 0→ .
Table 1: Simulated Hysteresis Controller Performance (no delay)
Hysteresis: ± 5→
± 2→
± 0→
E
Max Temp. (→ C)
⑤
52
55
-58D Min Temp. (→ C)
5 O
48
a
4
→
18
Ave Temp. ( C)
s
π
Duty Cycle (%)
42 . 83 %
58 "
41 . 91 %
off zut
_
4
17 5
Now we examine how delay messes things up! In the Delay block, enter the time delay
value that you found last week for your device. Repeat the experiment and record your
results in Table 2.
Table 2: Simulated Hysteresis Controller Performance (with delay)
Hysteresis: ± 5→
± 2→
± 0→
Max Temp. (→ C)
6F℃
68
o
Min Temp. (→ C)
%
るFと
㉟
Ave Temp. (→ C)
52
52 5
52 3
Duty Cycle (%)
44 . 66
44 87144 6/
.
.
.
4
.
.
3
%
子
Describe how the delay changed things. In particular was the average temperature the same
as the desired temperature? Could you achieve a system with an output that had ± 0→ at
the output?
You can correct the bias (o!set) in the average temperature by adjusting the hysteresis
block
such that the switch-on and switch-o! points are not symmetric about zero. Experー
iment with this to see if you can find a situation where the average output temperature is
basically equal to the desired output temperature. Note the final values of the switch-on
and switch-o! points.
ー
Switch ON G
2.3
Real System
switch off
2
Open the Hysteresis Control Step.slx file. First, in the Digital Twin section, which runs
a model at the same time as the real system, update the delay and transfer function blocks
with your model’s values. Then in both the Digital Twin section and Arduino section,
update the Hysteresis Control blocks with the switch-on and switch-o! points that you just
ー
found.
Run the simulation and note the following in the Table 3. Also save your figures. Comment
on how the simulation di!ered from the real device. Do you feel that the First-Order with
Delay model is good enough? Why or why not?
_
_
_
Table 3: Simulation vs Real (Desired temp = 50→ C )
Hysteresis: Simulation
Real
→
Max Temp. ( C)
5α
㉜
Min Temp. (→ C)
&
ㄢ
Ave Temp. (→ C)
56
4
5
2FIo
Duty Cycle (%)
37.01 "
.
MORE ON THE NEXT PAGE
4
2.4
Cool O! the Arduino
Run TemperatureMon and wait until you are back to ambient temperature. If you have a
soldering fan handy, it will really accelerate this process! Be sure to hit Stop on the
simulation when you’re done.
2.5
How Robust is the System ?
Return to Hysteresis Control Step.slx and change the desired temperature from 50→ C
to 30→ C and run it. Record the results in Table 4. Comment on how this situation compares
to the previous.
Table 4: Simulation vs Real (Desired temp = 30→ C )
Hysteresis: Simulation
Real
→
Max Temp. ( C)
a
4
→
Min Temp. ( C)
24
Ave Temp. (→ C)
g
δ
Duty Cycle (%)
5 4210
㉘
.
error
crror
75 %
<5 %
100%
>
-
0 %
+
5