0% found this document useful (0 votes)
25 views6 pages

Implementation of A Pid Control System of Temperature For Teaching Engineering

Uploaded by

Sandoval Daniel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views6 pages

Implementation of A Pid Control System of Temperature For Teaching Engineering

Uploaded by

Sandoval Daniel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

IMPLEMENTATION OF A PID CONTROL SYSTEM OF TEMPERATURE FOR

TEACHING ENGINEERING
M. en C. Jorge Fonseca Campos1, M. en C. Paola Nayeli Cortez Herrera 2
y M. en C. Leonardo Fonseca Ruiz 3

Abstract—The proportional integral derivative (PID) control mechanism is one of the most used in the industry. This controller
has been used with success to adjust several physical variables such as: speed, pressure, flux and temperature. The difference
between a reference value and its instantaneous value is measured by a feedback loop. According to the calculated difference
between both variables a control action is executed. One of the main problems from PID control is that it is difficult to tune. In
most cases it is done empirically. By this reason, it is important for the students to understand it from an analytical point of view,
but it is as well important to physical implement it. In this work, a PID control of temperature is built and tuned. This system is
comprised of following elements: an analog temperature sensor, a waterproof resistor, a DAQ and a C# program.

Palabras clave—PID, control, DAQ, temperatura, sensor, C# program, PID tuning.

Introduction

The proportional integral derivative (PID) control scheme has been widely used to control different processes.
Recently, Padhee controlled successfully a heat exchanger system (Padhee (2014)). This controller was implemented
by Reyes and Cid to control an electrical oven (Reyes and Cid (2015)). Khutoryan and coworkers stabilized the
gyrotron frequency by a PID feedback control applied to the acceleration voltage (Khutoryan et al (2015)). Salim
and colleagues reported a system that uses a PID controller to control a DC motor and temperature (Salim et al
(2013)).

In this work it is reported the control of temperature of a water container by employing a PID controller. The
system is composed by a data acquisition board (DAQ), an immersion heater, an analog temperature sensor, a solid-
state relay, an electronic circuit for control and signal conditioning and a C# program. This system was developed to
teach this controller in the course of virtual applied instrumentation of the undergraduate program of mechatronics
of UPIITA. The main goal of the system is to teach the students how to make the implementation the PID controller
and how to make its tuning.

Theory

PID controller

The mathematical equation of the output function of the PID controller 𝑢(𝑡), is given by (Ogata K. (1997), Reyes
and Cid (2015), Christiansen (2005))
𝑡
𝑢(𝑡) = 𝑘𝑝 𝑒(𝑡) + 𝑘𝑖 ∫0 𝑒(𝑡′)𝑑𝑡′ − 𝑘𝑑 𝑇̇(𝑡), (1)
where 𝑘𝑝 , 𝑘𝑖 , 𝑘𝑑 are the coefficients for the proportional, integral, and derivative terms, respectively. 𝑒(𝑡) = 𝑇𝑠𝑝 −
𝑇(𝑡) is the temperature error between the set point temperature the and the temperature at the time 𝑡 and 𝑇̇(𝑡) is the
first derivative of temperature with respect to the time.

The first term of the equation (1) is the most important. It represents the proportional term. A high proportional
gain results in a large change in the output for a given change in the error. If the proportional gain is too high, the
system can become unstable. In contrast, a small gain results in a small output response to a large input error,
making the controller less responsive. The integral term of the equation (1) is added to reduce error during the
steady-state response of the system. Also, it has an influence as well during the transient response of the system.

1
The M. en C. Jorge Fonseca Campos is professor of the Unidad Profesional Intersdiciplinaria en Ingeniería y Tecnologías
Avanzadas of the Instituto Politécnico Nacional. [email protected] (corresponding author)
2 The M. en C. Paola Nayeli Cortez Herrera is professor of the Unidad Profesional Intersdiciplinaria en Ingeniería y Tecnologías

Avanzadas of the Instituto Politécnico Nacional.


3 The M. en C. Leonardo Fonseca Ruiz is professor of the Unidad Profesional Intersdiciplinaria en Ingeniería y Tecnologías

Avanzadas of the Instituto Politécnico Nacional.


This term grows rapidly. By this reason the coefficient of this term must have a small value. This condition might be
guarantee by setting in the controller a large integral time value. The last term of the equation (1) is the derivative
term. It improves the output of the controller during the transient response of the system reducing its overshoot.
During the steady-state response of the system this term approaches to zero, because the temperature is almost
constant, i. e., 𝑇(𝑡) → 𝑇𝑠𝑝 .

Temperature controller

In the figure 1 the block diagram of the temperature controller is shown.

Figure 1. Block diagram of the temperature controller.

The set point temperature is the ones that wants to be reached. T(𝑡) is the instantaneous temperature. The
difference or error between both quantities is the input of the temperature controller. According to the calculated
value of 𝑢(𝑡) a PWM signal will be generated. This signal is conditioned to control a solid-state relay, which will
control the time that an immersion heater is energized. The heater is placed inside a water container. A waterproof
sensor of temperature is reading the temperature of the water, its signal is conditioned and it is used as a feedback to
the control system.

PID controller tuning

There are a few rules for tuning PID controllers, but the most well known is the Ziegler–Nichols method (Ogata
K. (1997)). However, it is possible to do this task empirically. This approach will be used in this work. Also, we will
base to some extent to do the tuning of the PID controller on the work realized by Reyes and Cid (Reyes and Cid
(2015)).

At first, a proportional band will be chosen. The upper limit of this band 𝛼 will be set to be five percent greater
than 𝑇𝑠𝑝 . The lower limit of this band 𝛽 will be set to be seventy percent of 𝑇𝑠𝑝 . The proportional coefficient 𝑘𝑝 will
be given in terms of both quantities as:
100
𝑘𝑝 = 𝛼−𝛽 . (2)

The coefficients 𝑘𝑖 and 𝑘𝑑 will be given in terms of 𝑘𝑝 and in terms of an integral time 𝑡𝑖 , and a derivate
time 𝑡𝑑 ; respectively. 𝑘𝑖 is given by
𝑘
𝑘𝑖 = 𝑡𝑝 , (3)
𝑖
and 𝑘𝑑 is given by
𝑘𝑑 = 𝑡𝑑 𝑘𝑝 . (4)

The integral time it is commonly set to be large to decrease the magnitude of 𝑘𝑖 as it can be seen from the
equation (3). Otherwise, the integral term of the equation (1) will become large enough to have a significant
influence during the transient response of the system. If 𝑡𝑑 has a small value, the derivative term of the equation (1)
will be very small, and the system will present an overshoot in the transient response. Therefore, a large value is
expected to produce an overdamped response in the system.
Substituting the equations (2), (3) and (4) in the equation (1) is obtained the following equation for the output
function PID controller:
1 𝑡
𝑢(𝑡) = 𝑘𝑝 (𝑒(𝑡) + 𝑡 ∫0 𝑒(𝑡′)𝑑𝑡′ − 𝑡𝑑 𝑇̇(𝑡)). (5)
𝑖
If the initial conditions 𝑇(𝑡 = 0) = 0 °C and 𝑇̇(𝑡 = 0) = 0 °C are considered. The upper limit that can have the
function 𝑢(𝑡) is
100
𝑢max = 𝛼−𝛽 𝑒(0), (6)
100
where 𝑒(0) = 𝑇𝑑 − 𝑇(0) = 𝑇𝑑 . Thus, 𝑢max = 𝛼−𝛽 𝑇𝑑 .

During the realization of the experiments, the calculation of 𝑢(𝑡) require as an input the times 𝑡𝑖 and 𝑡𝑑 . Both
quantities are given in seconds. In addition, the temperatures 𝑇𝑑 and 𝑇(𝑡) are given in °C.

Pulse width modulation (PWM)

The magnitude of the function 𝑢(𝑡) determines the time in which the control signal is on high state (ON). Of
course, this variable also defines the time in which the control signal is on the low state (OFF).

The duty cycle 𝐷 of a periodic signal is the quotient of the pulse width 𝑡𝐻 and the period of the signal 𝜏. For duty
cycles greater than 50 % the signal will stay more time in the high state, than in the low state during one cycle.
𝑡
𝐷 = 𝐻. (7)
𝜏

The pulse width in terms of the 𝑢(𝑡) is given by


𝑢(𝑡)
𝑡𝐻 = 𝜏 𝑢 . (8)
max
The time of the signal in the low state 𝑡𝐿 is given by
𝑡𝐿 = 𝜏(1 − 𝑡𝐻 ). (9)

The discrete version of the equation (8) is given by


𝑢(𝑡 )
(𝑡𝑘 )𝐻 = 𝜏 𝑘 , (10)
𝑢 max
where 𝑡𝑘 is the 𝑘-th time. The equation (10) is implemented in the C# program. It is worth noting that several
DAQ´s just can work with and integer time in milliseconds. This situation must be considered when the program is
written, because in the calculation of 𝑢(𝑡) the times used are given in seconds and the proper units conversion must
be done. In the C# program the following conditions for the PWM signal were considered. If 𝑢(𝑡𝑘 ) ≥ 0 and 𝑢(𝑡𝑘 ) ≤
𝑢max , the time that the signal is in high state is given by (𝑡𝑘 )𝐻 . If 𝑢(𝑡𝑘 ) < 0 the time that the signal is in the high
state is 0 s. Also, if 𝑢(𝑡𝑘 ) > 𝑢max , the time that the signal is in the high state is 𝜏.

System description

A photograph of the implemented system is shown in the figure 2a. In the figure 2b the screen of the C# program
is shown.

Figure 2. Implemented PID controller a) Photograph and b) program screen.


The main elements of the system are shown in the figure 3. The LM35 analog sensor of temperature is employed
to measure it. Some modifications to this sensor were made to make it waterproof. But this procedure has the
drawback that read temperature is around 3 °C lower than the real temperature, due to gradients of temperature in
the cover of the sensor. This is always a systematic error. The operational amplifier LM358 is used to make the
conditioning of the signal coming from the LM35. This is configured as a voltage follower. The signal of
temperature is input in the analog input pin AI0+ of a NI DAQ USB 6008. Due to the fact that the measures are
made in the differential mode, in the analog pin AI0− of the DAQ the ground coming from the DC voltage source is
connected. This voltage source provides a constant voltage of 5V. The DAQ sends the read temperature to the
personal computer (PC). With the above signal, 𝑢(𝑡) is calculated and the corresponding 𝑡𝐻 is generated to activate
for a certain time the solid-state relay (SSR). During this time the AC circuit of the immersion heater is closed. This
process is repeated up to a set point of time is reached. It is worth mentioning that the water container that was used
in these experiments was a coffee maker, which has walls of aluminum. This surface dissipates a lot of heat and the
results of the experiments might improve by using an isolated recipient.

Figure 3. Main elements of the PID controller of temperature.

Results

In the figure 4 are shown the results of one of the experiments. The conditions that were used for this experiment
are the following: 𝑇𝑠𝑝 = 40 °C, 𝜏 = 0.020 s, 𝑡𝑖 = 900 s, 𝑡𝑑 = 0.008 s, 𝛼 = 42 °C and 𝛽 = 28 °C.

Figure 4. Results of one experiment: a) 𝑇 versus 𝑡, b) 𝑢(𝑡) versus 𝑡 and c) 𝑡𝐻 versus 𝑡.

Due to fact that the signal is noisy, the moving average with a window of 500 points of the data of the
experiment shown in the figure 4 was made. The results of the data processing are shown in the figure 5.
Figure 5. Smoothed curves of the data that it is shown in the figure 4: a) 𝑇 versus 𝑡, b) 𝑢(𝑡) versus 𝑡 and c) 𝑡𝐻 versus 𝑡.

In the figure 6 the results of three experiments with different initial conditions are shown. The conditions that
were kept equal during these experiments were 𝜏 = 0.04 s, 𝑇𝑠𝑝 = 40 °C and 𝛼 = 42 °C and 𝛽 = 28 °C. The
parameters that were varied in these experiments were 𝑡𝑖 and 𝑡𝑑 . All the curves shown in this figure were smoothed.

Figure 6. Smoothed results of three experiments with 𝜏 = 0.4 s and 𝑇𝑠𝑝 = 40 ° C: a) 𝑇 versus 𝑡 and b) 𝑢(𝑡) versus 𝑡.

The experimental conditions for 𝑡𝑖 and 𝑡𝑑 of the three experiments are shown in the table 1.

Table 1. Experimental values for the integral and the derivative times.
1st Test 2nd Test 3rd Test
𝑡𝑖 (s) 300 1500 1600
𝑡𝑑 (s) 0.004 0.002 0.04

Results discussion

The maximum value of temperature that was read in the experiment shown in the figure 4a was 42.3 °C. This
means that it deviated 0.3 °C from the upper limit temperature that was set to 𝛼 = 42 °C. The error of 0.3 °C in the
temperature is small. Even though the system wasn’t thermally isolated. The water volume used in all the carried
experiments were ~6270 cm3: The results might improve further by using thermal isolation.

In the figure 4b it is shown how the value of the 𝑢(𝑡) function is decreasing monotonically from 10 to ~200 s.
After the latter time the signals oscillates around the zero value. Taking in occasions negative values. The exhibited
behavior of the 𝑢(𝑡) function is correlated with the temporal evolution of 𝑡𝐻 . Because, after the first 200 s the time
at which the signal is in high state is always 1 ms corresponding to small positive values of 𝑢(𝑡) or 0 ms
corresponding to small negative values of 𝑢(𝑡). This experimental data corresponds to a PWM period of 𝜏 = 0.02 s.

The curve smoothing helped to distinguish with greater detail the small oscillations that were present during the
transient response of the system, as it is shown in the 5a. In the same figure, it is observed that under those
experimental conditions the system didn’t present any significant overdamping, i. e., it didn’t show an oscillation of
large duration in the transition between the transient and the steady state of the system. Maybe a better tuning in the
integral time is necessary to decrease the small oscillations presented during the steady state response of the system.
As expected, there is a great correlation between the 𝑢(𝑡) and 𝑡𝐻 as it is shown between the figures 5b and 5c. Also,
for times greater than 200 s 𝑡𝐻 → 0 s, meaning that the system converges around 𝑇𝑠𝑝 as it is shown in the figure 5c.

The initial conditions of the PID system are very important to reach successful results. As it is shown in the
figure 6a and in the table I. In the first test the integral time contributed quite a lot in the transient response of the
system. It created a clear overshoot of the system. Of course, in this test 𝑡𝑖 had a small value. When this time was
increased as it was in the case of the second and third tests, the overshoot was significantly decreased as it is shown
in the figure 6a. The results of the second and the third tests were very similar, but a slight increase of 𝑡𝑖 and 𝑡𝑑 in
the third test with respect to the second produced better results, because the curve was smoother during the transient
and the steady state response of the system as it is shown in the same figure. The anomalous behavior exhibited for
𝑢(𝑡) in the case of the first test was correlated with the great overshoot that exhibited the system as it is shown in the
figures 6a and 6b. As expected, when the PDI controller was better tuned the results for the evolution of the
temperature in terms of time were better as it is shown in the figures 6a and 6b.

Conclusions

A PDI control system for temperature was implemented by using a DAQ, a temperature sensor, signal
conditioning electronic circuits and a C# program.

The temperature was larger for 0.3 °C than the upper limit temperature of the system that was 𝛼 = 42 °C. By this
reason, the tuning of the PDI controller gave good results. The results might be improved by isolating the water
container.

To apply the moving average of the experimental data significnalty reduces the noise in the temperature
measurement. Fruthermore, it helps to reveale some details of the signal that not are clearly visible in the original
signal.

A set of three experiments that were carried on helped to understand the influence in the initial selection of the
integral and derivative times.

Acknowledgments

The authors want to thank to the Instituto Politécnico Nacional (IPN) and the Comisión de Operación y Fomento
de Actividades Académicas (COFAA-IPN) for the financial support provided to do this work.

References
Padhee S., “Controller design for temperature control of heat exchanger system: simulation studies,” WSEAS Transactions on Systems and
Control, Vol. 9, 2014.

Reyes, F., Cid A., “Arduino: aplicaciones en robótica mecatrónica e ingenierías”, 1° Ed., Alfaomega, 2015.

Khutoryan, E.M., Idehara, T., Kuleshov, A.N., Tatematsu1, Y., Yamaguchi, Y., Matsuki, Y. Fujiwara, T., “Stabilization of gyrotron frequency by
PID feedback control on the acceleration voltage,” J. Infrared Milli Terahz Waves, Vol. 36, 2015.

Salim, Kumar, S. Ohri, J. “LabVIEW based DC motor and temperature control using PID controller,” Int. J. of Advanced Research in Computer
Science and Software Engineering, Vol. 3, No. 5, 2013.

Ogata K., “Modern Control Engineering”, 3rd ed., Prentice- Hall, 1997.

Christiansen, D., Alexander, Ch.K., Jurgen, R.K., “The Electronics Engineers' Handbook”, 5th Ed., McGraw-Hill, 2005.

You might also like