Temperature Control Using Labview

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Temperature Control Using LabView

Sam McCandlish
Physics Department, Brandeis University, Waltham, MA, 02454
(Dated: 5/10/12)
We present a study of control theory applied to a thermal control problem. We use a thermoelectric cooler, controlled by LabView, to heat and cool a metal stand. We describe the theory and
implementation of a basic PID control program in LabView, and we show how to tune the controller
using the Ziegler-Nichols method. Results of various tuning parameters suggested by this method
are shown.
I.

INTRODUCTION

Control theory provides a theoretical prescription for


how to control some output of a system given some limited input ability. Control problems are ubiquitous in
both natural and human-made systems. For instance,
when a person stands on a balance beam, the human
brain causes muscle movements in order to control the
bodys position. An additional example is the cruisecontrol system of a car, where the driving computer
controls the land speed of the car by adjusting the input of the motor.
The case of the human on a balance beam, where
multiple inputs, outputs, and measurements must be
accounted for, is far more difficult than the case of cruise
control, where there is only one input and output. The
latter type of problem will be the focus of this report.
In particular, we wish to control the temperature of a
metal object using a TEC heat pump.

II.

EXPERIMENTAL SETUP

Our objective is to heat or cool a metal base to a desired temperature. We do this using a thermo-electric
cooling device. This device makes use of the Peltier

effect, in which a current flows through a junction of


metals causes heat to flow from one side of the junction
to the other. This has the effect of pumping heat from
one side of the device to the other. A series of n-type
and p-type semiconductors are placed in series to maximize the surface area, and hence maximize this effect
[2]. One side of the TEC device is in contact with the
metal stand, while the other side is in contact with a
liquid cooling device used as a heat sink. We can use
the TEC device to either heat or cool the metal stand
by adjusting the sign of the current running through the
device.
An H-Bridge amplifier provides this current while allowing us to switch the direction of the current and
modulate its intensity using a pulse width modulator
(PWM). Rather than just varying the size of the current, we use pulse width modulation, which provides
current in pulses at a constant value, in order to maximize the efficiency of the TEC. A thermal switch in
series with the TEC prevents the TEC from running if
the temperature increases above 70 C.
The amplifier is controlled by a LabView on a computer using an EMANT data acquisition device, which
has both analog and digital inputs and outputs. This
allows us to control the duty cycle, the percent of time
the PWM spends in the on state, as well as the direction of the current. The EMANT also allows us to
run a constant current through and measure the voltage
across a thermistor inserted into the stand. The voltage
across the thermistor varies according to the following
equation:

T =

Figure 1: A typical TEC device using the Peltier effect.


Many pieces of metal are laid in series to yield the highest surface area and hence the most efficient heating and
cooling. Because n-type and p-type semiconductors behave oppositely under this effect, the type of semiconductor used is alternated so that one side of the TEC
device is heated and the other side is cooled. Image:
http://en.wikipedia.org/wiki/Thermoelectric_cooling

1
1
+ ln
T0
B

R
R0

1

where B, T0 , R0 are constants given by the provider of


the thermistor, R is the variable resistance of the thermistor, and T is the measured temperature. This allows
us to measure the temperature in the stand.
In summary, we are able to measure and control
the temperature of our stand by measuring the voltage across a thermistor and tuning the duty cycle of
the pulse width modulator as well as setting the sign of
the current through the TEC. The EMANT interface
allows us to take these measurements and control these
elements using LabView.

0.5

1
0.5
0
0

20

10

0
2
0

10

20

2
0
2
0

Time t

0.5

10

20

10

10

20

2
0

kd

2
0

20

Time t

(a) Proportional control

kd

ki

Input u

0
0

20

kp

Input u

10

1.5

ki
Output y

0
0

Input u

1.5

kp

Output y

Output y

1.5

Time t

(b) PI control

(c) PID control

Figure 10.2: Responses to step changes in the reference value for a system with a proportional
controller (a), PI controller (b) and PID controller (c). The process has the transfer function
Figure
2: Effect of tuning various parameters. Image: [1]
P(s) = 1/(s+1)3 , the proportional controller has parameters k p = 1, 2 and 5, the PI controller
has parameters k p = 1, ki = 0, 0.2, 0.5 and 1, and the PID controller has parameters k p = 2.5,
ki = 1.540
and kd = 0, 1, 2 and 4.

Temperature HCL

value. If we choose u ff = r/P(0) = kr r , then the output will be exactly equal


30
to the reference
value, as it was in the state space case, provided that there are
no disturbances. However, this requires exact knowledge of the process dynamics,
which is usually not available. The parameter u ff , called reset in the PID literature,
must therefore
20 be adjusted manually.
As we saw in Section 6.4, integral action guarantees that the process output
agrees with the reference in steady state and provides an alternative to the feedforward term.
10 Since this result is so important, we will provide a general proof.
Consider the controller given by equation (10.1). Assume that there exists a steady
state with u = u 0 and e = e0 . It then follows from equation (10.1) that
u 0 = k p e0 + ki e0 t,

80

100

120

140

160

which is a contradiction unless e0 or ki is zero. We can thus conclude that with


Time HsL
integral action the error will be zero if it reaches a steady state. Notice that we have
not made any assumptions about the linearity of the process or the disturbances. We
Figure
3: The
temperature
for aexists.
purely
proportional
have,
however
assumed
that an equilibrium
Using
integral action control
to achieve
zero
steady-state
much better
thanThe
usingtarget
feedforward,
requires
never
reacheserror
theistarget
value.
valuewhich
is shown
in a
precise
knowledge
process parameters.
red, while
theoftemperature
as a function of time is shown in
The effect of integral action can also be understood from frequency domain
blue.
analysis. The transfer function of the PID controller is
ki
+ kd s.
(10.4)
s
III. THEORY
The controller has infinite gain at zero frequency (C(0) = ), and it then follows
from equation (10.2) that G yr (0) = 1, which implies that there is no steady-state
C(s) = k p +

We must now determine how to bring the stand to a


desired temperature. However, we do not know everything about the dynamics of the stand; perhaps someone is affecting its rate of cooling by putting their finger
on it, for example. We also do not know exactly the efficiency of the TEC. So, we cannot use a feedforward
mechanism where we know exactly how to bring our
system to the desired temperature. Hence, we use a
loop feedback approach, where we continually measure the temperature of the system and use this data to
determine how much power to provide to the TEC.
A.

295

10.1. BASIC CONTROL FUNCTIONS

Proportional Control

A reasonable first attempt would be proportional control, where our power output is set to be proportional to
the difference between the measured temperature and
the desired temperature:
u (t) = KP e (t)
where u (t) denotes the signed duty cycle of the PWM,
with positive u indicating heating and negative u indicating cooling, and where e (t) = Twant T (t) is the er-

ror, the difference between the desired and measured


temperature. The constant KP is positive, because if
e (t) > 0 we want to heat the system.
This model has a major flaw: it fails to ever reach the
desired temperature. This can be seen by noticing that
if e (t) = 0, there will be no power output. However,
if the system is constantly losing heat to its environment, it requires a constant power output to maintain a
steady temperature. For example, if the system obeys
Newtons law of cooling with the addition of a term
koutput u (t) for the TEC
dT
= kcool (Tenv T (t)) + koutput u (t)
dt
then our proportional control yields the following steady
state temperature:
T (t) =

kcool Tenv + koutput KP Twant


6= Twant
kcool + koutput KP

This steady state value is not the desired temperature


(unless Twant = Tenv , in which case we dont really need
to control the system). This is known as droop.
We can correct this error by adding an additional
term C (Twant ) dependent on the desired temperature
to account for the constant power required at steady
state, so that u (t) = KP e (t) + C (Twant ). However, this
requires exact good of the systems dynamics, which we
do not have. So, we must pursue a different solution.

B.

Integral Control

To dynamically determine C (Twant ), we can add an


integral term to our feedback design:
t
u (t) = KP e (t) + KI
e (t0 ) dt0
0

If a steady state exists, we have


u = KP e + KI (et + const.)
which can only be valid if e (t) = 0. So, if a steady state
exists, it must be at the desired temperature. However,
it is not clear that such a steady state exists. For instance, if there is a time delay between the input of heat
and the measurement of a temperature change, the temperature can overshoot the desired value and oscillate
rapidly.

C.

Derivative Control

In order to account for such a time delay and avoid


overshoot, we introduce a derivative term:


t
de (t)
u (t) = KP e (t) + TD
+ KI
e (t0 ) dt0
dt
0

3
Rule Name

KP

Ziegler-Nichols
Pessen Integral Rule
Some Overshoot
No Overshoot

0.6Kc
0.7Kc
0.33Kc
0.2Kc

TI =

KP
KI

0.5Tc
0.4Tc
0.5Tc
0.5Tc

TD
0.125Tc
0.15Tc
0.33Tc
0.33Tc

Table I: Various rules of thumb for PID tuning using the Ziegler-Nichols method.
Source:
http://www.mstarlabs.com/control/znrule.html

This derivative term is the first term in a series expansion e (t + TD ) e (t) + TD de(t)
dt . Hence, we can interpret TD as the time delay between powering the TEC
and measuring a temperature change. This has the effect of anticipating overshoot and damping the power
output when the temperature approaches the desired
temperature. This use of proportional, integral, and
derivative terms is known as PID Control.

D.

Tuning

The constants KP , KI , TD should be tuned according


to the parameters of the system and the design constraints. For example, for a situation where large temperature variations must be avoided, the derivative term
should be increased and the proportional term increased
to reduce oscillation. On the other hand, we might like
to reach the target temperature as quickly as possible
without regards to oscillation. So, the choice of PID
parameters is not a completely precise process. This
process can be particularly time consuming if the delay
time is very large.
The Ziegler-Nichols tuning method provides a rule
of thumb for determining approximate PID constants
in order to make manual tuning easier. A pure proportional control is used, and the gain KP is increased
until the temperature starts oscillating at a constant
amplitude. The period Tc of these oscillations and the
critical gain Kc are recorded. Various rules of thumb
can then be used that give different approximate outcomes. A few are shown in the table above. A more
precise method for measuring these critical constants is
also available [1], but we were not able to explore this
option.

IV.

Figure 4: The direction and duty cycle of the current to


the TEC is controlled using the EMANT through LabView.
Wires represent the transmission of information from one
sub-VI program to another. For example, the blue 0 input
indicates that a digital bit representing the direction of the
current is written to the digital output labeled 0. The
orange wire contains the power output u (t).

LABVIEW PROGRAM DESIGN

To implement this PID control method, we use LabView. LabView programs are composed of graphical
elements connected together using wires. An example of using LabView to control the duty cycle of the
PWM and the sign of the current is shown in Fig. 4.
The proportional, integral, and derivative terms are implemented in a straightforward way by computing the

Figure 5: The front panel in LabView contains controls


and indicators. The target temperature and the constants
for the proportional, integral, and derivative terms can be
changed. The current and target temperature are also plotted on a waveform chart.

error, comparing error between feedback loop iterations,


and adding the total error over all iterations.
A graphical interface is provided by the front panel
shown in Fig. 5. The values of the controls in the
front panel can be wired into the program to be used
as constants KP , KI , TD . Outputs such as the target
and current temperatures can be shown in a waveform
chart.
One subtlety of real-world implementations of PID
is that there is often a maximum input to the system.
In our case, we cannot set the duty cycle higher than
100%. Because of this, the integral term can wind up
and increase to a large value while the TEC is working
at maximum power. This causes a significant overshoot
as the integral term winds down. To alleviate this
problem, there are a few possible anti-windup methods. We can reset the integral to zero when it reaches
some large value, we can turn off the integral term until
the current temperature is close to the goal, or we can
compare the commanded output to the actual output
and subtract the difference from the integral term. Due
to limited time, I chose the second method; the integral
does not begin summing until the temperature is within

4
51.0

V.

RESULTS

Temperature HCL

50.5

50.0

49.5

49.0

50

100

150

200

250

200

250

KP

Time HsL
72
70
68
66
64
0

50

100

150
Time HsL

Figure 6: The critical gain is found by increasing the proportional term KP until sustained oscillations occur. We found
the critical value to be 71, though damped oscillations were
present starting from a much lower value.

5 C of the target temperature. This leads to suboptimal


results, including larger than desired overshoot. Given
more time, I would implement the third method, which
smoothly turns the integral term on when it becomes
necessary.

[1] K Astrm and R Murray. Feedback Systems: An Introduction for Scientists and Engineers. Princeton University Press, 2008.
[2] J S Sharp, P M Glover, and W Moseley. Computer based

We started by implementing only proportional control, as shown in 3. The system does not reach the
target temperature, as expected. Increasing the proportional constant sufficiently leads to sustained oscillations about the target temperature 7. To find the critical gain and time constants, we more slowly increased
the gain until oscillations occurred that did not damp
out eventually 6. The critical gain was KP = 71, and
the critical period of oscillations was determined to be
3.3s, determined by Fourier analysis of the data at critical gain. I tried many of the suggested parameters
from the table shown above. One example of the supposed no overshoot rule is shown in 8. Clearly, there
is a significant overshoot of multiple degrees for larger
changes in target temperature. To attempt to understand this, I reduced the proportional term further to
find the origin of the oscillations. In 9, it is clear that
when the anti-windup function is switched off at 5 degrees from the target temperature, the temperature begins to rapidly change and begins oscillating. I believe
that the abrupt nature of my anti-windup implementation causes the integral term to overshoot the target
temperature, even when the proportional term is turned
aggressively down. Hence, if given more time, I would
implement a smoother method of turning on the integral method, as suggested above.

learning in an undergraduate physics laboratory: interfacing and instrument control using Matlab. European
Journal of Physics, 28(3):S1S12, May 2007.

5
45

Temperature HCL

40
35
30
25
20

10

20

30

40

50

60

Time HsL

Figure 7: If the proportional term is increased above the critical gain Kc , the temperature oscillates about the target value.

50

Temperature HCL

45
40
35
30
25
20
50

100

150

200

250

Time HsL

Figure 8: Response to changes in target temperature for the no overshoot tuning. The constants used are KP = 14.2,
TI = 1.645, and TD = 1.1.

50

Temperature HCL

45
40
35
30
25
20

10

20

30

40

50

60

70

Time HsL

Figure 9: Attempt to find true no overshoot parameters with a reasonably fast equilibration time. This was unsuccessful,
likely due to the abrupt turn-on of the integral term when e (t) = 5 C. The constants used are KP = 7, TI = 1.15, and
TD = 1.1.

You might also like