Closed-Loop Temperature Control Using MATLAB@Simulink, Real-Time Toolbox and PIC18F452 Microcontroller
Closed-Loop Temperature Control Using MATLAB@Simulink, Real-Time Toolbox and PIC18F452 Microcontroller
Closed-Loop Temperature Control Using MATLAB@Simulink, Real-Time Toolbox and PIC18F452 Microcontroller
Abstract Today’s way of life is closely linked with technology and it would be
impossible without a microcontrollers. They are represented in all spheres of life: in
the automotive industry, robotics, computer systems, home appliances, etc. Also,
today’s life is unthinkable without computers. The combination of computer and
microcontroller provides a very great possibilities, which uses the good features of
both. This chapter describes the use of a computer in combination with
MATLAB@Simulink, Real-time Toolbox and PIC18F452 microcontroller for
closed-loop temperature control. Control and settings for temperature are in
MATLAB@Simulink and they can be very easily adjusted. Also, all the infor-
mation: the refrence temperature, information from controller and the measured
temperature are available at any time in MATLAB@Simulink and can be processed
and stored. For real-time operation is used Real-time Toolbox. The information is
sent from computer over serial port to PIC18F452 microcontroller. The PIC18F452
microcontroller receives information and processes them. Information from
PIC18F452 microcontroller is amplified using a transistor that works as the switch
and the thyristor which is used to turn on the heater. Turning off thyristor is
automatically passing supply voltage through zero. Temperature measurement is
performed using the temperature sensor LM335. Output signal from the sensor is
amplified by using operational amplifier LM324 and after that sent in PIC18F452
microcontroller. The microcontroller processes information and after that send it
over serial port to computer. In this way the loop of temperature control is closed
using a computer and PIC18F452 microcontroller.
1 Introduction
Temperature is one of the most important and the most common measurement size
in the technique. People are constantly related with temperature: air temperature,
daily temperature changes, seasonal temperature changes, temperature of human
body, temperature coolant in the car, etc. Temperature is a physical value which is
used for expressing the thermal state of a substance. It depends on how much of
internal energy has a certain object with certain weight and pressure. For precise
temperature control is used closed-loop system. It is shown in Fig. 1.
Temperature reference value, desired temperature, is compared with measured
temperature value. Deviation between reference and measured temperature value is
sent in controller. Based on error, controller affects on executive element in order to
reduce this error to zero. Executive element effects on heater, which heats the
object. Temperature is measured with temperature sensor. This size is very small
and need additional amplifier, which is then compared to reference value. Two most
used types of temperature controllers are:
• The controller with direct ON/OFF temperature control
• Proportional controller with width modulated temperature control
proportional band), the output on/off ratio is 1:1 [9]. If temperature is below set-
point, output will be “on” longer. If the temperature is too high, output will be “off”
longer. One of the advantages of proportional control is simplicity of operation. It
may require an operator to make a small adjustment (manual reset) to bring the
temperature to setpoint on initial startup, or if process conditions change signifi-
cantly. This proportional controller varies the ratio of “on” to “off” to control
temperature in closed-loop.
10 mV when temperature change for 1 K. It is small signal and for that reason it
must be amplified using the operational ampfier LM324. That amplified signal is
sent in the PIC18F452 microcontroller, i.e. pin RA1. From pin RA1 analog signal is
forwarded in A/D convertor.
In A/D convertor analog voltage value is converted to digital. Digital informa-
tion of measured temperature value, using serial port, is forwarded to computer.
In Fig. 5 is shown appearance of the finished system for closed-loop temperature
control using MATLAB@Simulink, Real-time Toolbox and PIC18F452
microcontroller.
In the black box is located heater and temperature sensor, and it is environment
in which temperature is controled. As the box is made of metal, there are also a
large heat loss, which requires more frequent involvement of the heater.
For communication (sending and receiving data) with the PIC18F452 micro-
controller are used the simulink blocks “Packet Input” and “Packet Output” which
are previously set for the serial communication. That is shown in Fig. 6.
Of course, the same set is in the PIC18F452 microcontroller. In Fig. 7 is shown
simulink scheme that is used for temperature control using the PIC18F452
microcontroller. Using Real-time Toolbox is allowed to work in real time. For that
is used Real-Time Windows Target rtwin.tlc. Measured temperature is processed in
PIC18F452 microcontroller and than over serial port is forwarded to block “Packet
Input”. After that, receiving, measured temperature is sent to block “Processing the
measured temperature”. In this block information of temperature is processed and
adjusted for the range in which there is reference temperature value. However, for
room temperature output value from this block is zero and with increasing
Fig. 6 Block “Packet Input” for receiving data using serial port
308 E. Mujčić et al.
Fig. 7 Simulink scheme for closed-loop temperature control using MATLAB@Simulink and
real-time toolbox
Fig. 8 Experimental results obtained using closed-loop temperature control for designed system
Closed-Loop Temperature Control Using MATLAB@Simulink … 309
temperature at the same time that value is also increasing. Than, processed value of
measured temperature in adder is compared with the reference temperature value.
Using, in this case, ON/OFF temperature controller, this value is processed and
sent to block “Packet Output”, and than over serial port is forwarded to PIC18F452
microcontroller and power amplifiers on heater.
4 Experimental Results
In this section of paper are presented experimental results for closed-loop tem-
perature control using MATLAB@Simulink, Real-time Toolbox and the
PIC18F452 microcontroller. It is used ON/OFF temperature controller. Because of
great features of simulink, we can quickly and easily replace ON/OFF temperature
controller with another temperature controller, e.g. the PID controller. Values of
reference temperature is in relative units for easy and precise results presentation.
After experiment analysis we got experimental results as shown in Fig. 8. Based on
Fig. 8, we can conclude that closed-loop temperature control is working properly.
When temperature exceeds set limit heater is turning off, and inversely. Maximum
and minimum temperature value is adjusted within ON/OFF temperature controller.
Error that occur when reading measured temperature occur because of to 8-bit
resolution A/D converter. Taking average temperature value is obtained nearly ideal
value of measured temperature. Temperature reference value can be optionally
seted during work by simply entering another value in block “Reference value of
temperature”. To show temperature value we can use different temperature scales.
5 Conclusion
Based on the experimental result, we can conclude that designed system is working
properly and that can be used to measure temperature in closed loop. If generalize,
we can conclude that combination of MATLAB@Simulink, Real-time Toolbox and
microcontroller can be used on different systems. In this way are used good features
of MATLAB@Simulink for easy adjustment parameters of system as well as good
features of PIC18F microcontroller series. All-important information’s can be
stored and displayed using wide spectrum of tools for graphical processing
information.
References