This is only a preview of the July 2007 issue of Silicon Chip. You can view 37 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Articles in this series:
Items relevant to "Tank Water Level Indicator":
Items relevant to "PICAXE Plays Music":
Items relevant to "A PID Temperature Controller":
Items relevant to "20W Class-A Amplifier Module; Pt.3":
Purchase a printed copy of this issue for $10.00. |
ove hoot
For temperature control without overshoot
rs
PID Temperatur
What’s a PID controller? PID stands for “proportional integral
differential” and relates to a process which seeks to continuously
correct the error between a measured variable and a desired
setting by calculating an appropriate correction process.
In practice, it can largely avoid the large overshoots and
undershoots that occur in simple temperature control systems.
By LEONID LERNER
58 Silicon Chip
siliconchip.com.au
re Controller
K
EEPING TIGHT TEMPERATURE
control is essential in many
processes. For instance, good
temperature control of a PC board
etching bath is essential for best
results.
Too low a temperature and the
process will be very slow, while too
high a temperature will cause the
etch resistant film to degrade and the
solution to steam appreciably.
Another, arguably more important,
process where precise temperature
control is vital is in a good home
brew!
Getting good temperature control is
not as easy as it may seem. Consider
the setup in the photo at left and
represented below in Fig.1.
When the hot plate is turned on,
heat passes from the hotplate to the
solution through the walls of the
container. When the temperature of the
solution reaches the desired value, the
controller (the Digital Thermometer/
Thermostat featured in the August
Fig. 1: model diagram of vessel on a hotplate showing equivalence to an electrical
circuit consisting of a series connection of
two RC circuits.
THERMOMETER
C3
VESSEL
R2
R3
I
R2
C1
2002 issue
of S ILICON
CHIP) switches
the hot plate off
but the temperature
will continue to rise.
This is because there
is significant thermal
resistance in the surface contact
between the container and the hot
plate, so that the temperature of the
hot plate when it is turned off is much
higher than the set temperature.
The actual amount by which it
is higher than the set temperature
depends on the relationship of the
set temperature to the maximum
temperature attainable by the hot
plate.
For instance, a 2000W hot plate
was found to have heated to 150°C
when the temperature of the solution
reached the optimal temperature of a
persulphate bath – 65°C.
Heat therefore continues to pass
through the walls of the container
HOT PLATE
Temperature difference
Thermal resistance
C1
R1
OUT
R3
R1
= Power flow
Voltage difference
Resistance
= Current
Temperature difference x Heat Capacity
Voltage difference x Capacitance
= Power flow x Time
= Current x Time
siliconchip.com.au
C3
and the temperature
continues to rise, until the hot
plate and the solution are in thermal
equilibrium.
The result is temperature
overshoot. Furthermore, after the peak
temperature has been reached the
system starts to cool down towards the
desired temperature and the hot plate
turns on again at the set temperature.
The overshoot repeats, although
this time it is smaller. The end
result is that with on/off control, the
temperature of the system in Fig.1
oscillates periodically.
For etching PC boards, the result
is the inconvenience of a lot of steam
being generated but for many processes
such as distillation, overshoot is
simply not permissible.
Our aim here is to understand the
operation of the thermal delay of the
system in Fig.1 and counteract it to
achieve good temperature control. To
do this we need to design a controller
which has a more complicated
response than simply on/off.
But first we shall develop a model
to make it easier to understand what
is happening.
It turns out that the thermal setup on
the left side of Fig.1 is well modelled
by an electrical circuit consisting of
resistors and capacitors, as shown
on the right side of Fig.1. This is
more than just a convenient picture;
it is based on actual mathematical
July 2007 59
OVERSHOOT
(DEGREES)
DEGREES
SECONDS
SET TEMPERATURE / MAXIMUM TEMPERATURE
Fig.2: temperature plot of a typical “switched” hot-plate
which has an initial large overshoot, followed by a series
of smaller over-temperature peaks.
correspondence. If we make the
equivalence
temperature
power
<----->
<----->
voltage
current
then the equations in Fig.1 show that
Newton’s law of cooling corresponds
exactly to Ohm’s law, while the Law
of Heat Capacities corresponds exactly
to Coulomb’s Law for the capacitor.
Therefore, we can view the thermal
system as a good approximation to a
passive resistor-capacitor network.
CONTROLLER
Fig. 3: temperature overshoot for a typical vessel on a
hot-plate as a function of set temperature for equal time
constants (blue line) and their ratio equal to 5 (red line).
The heat capacities of the hot
plate and of the vessel correspond
to capacitors C1 and C2, the thermal
resistance between the hot plate and
the vessel corresponds to resistor
R2, and the heat loss of both the hot
plate and vessel to the surroundings
is modelled by resistors R1 and R3,
respectively.
The ambient temperature in the
thermal system then corresponds to
earth potential in the electrical circuit.
However, it is easy for confusion
SYSTEM
Tset
Tout
G(s)
C(s)
Tout = Tset x C(s) x G(s)
(a) – OPEN LOOP CONTROL
CONTROLLER
Tset
SYSTEM
–
Tout
C(s)
G(s)
Tout =
Tset x C(s) x G(s)
1 + C(s) x G(s)
(b) – FEEDBACK CONTROL
Fig. 4: block diagram showing the response to a change in set temperature
(Tset) of a controller-system combination connected in (a) open loop and (b)
with a portion of the output (Tout) fed back to the input.
60 Silicon Chip
to arise due to the fact that in the
correspondence, thermal power is
equivalent to electric current and not
to electric power.
Thus expressions such as V2/R
and 1/2 CV2 which correspond to
power and energy in electric networks
have no simple interpretation in the
equivalent thermal circuit.
Theory of PID control
If we use a computer to switch the
electric circuit of the right side of Fig.1
on or off, depending on whether a
preset temperature has been reached,
the response is shown in the graph
of Fig.2.
It is characterised by an initial large
overshoot, followed by a series of
smaller oscillatory overshoots, which
tend to an oscillation of constant
amplitude above and below the preset
temperature.
In fact, the initial overshoot and
oscillation amplitude are easily
calculated in terms of the time
constants of the RC circuit and the set
voltage, as shown in Fig.3.
The overshoot depends on two
ratios; the ratio (τ1:τ2) of the time
constants of the hot plate and vessel
RC circuits, and the ratio of the set
temperature to the maximum steady
state temperature, when the hot plate
is on continuously.
From Fig.3 we can establish a
simple rule of thumb to determine
whether overshoot is likely to be a
problem in a given situation.
First of all, if the maximum
temperature achievable by the
heating (or cooling) element, when
it is on continuously, is much greater
siliconchip.com.au
CONTROLLER
OUTPUT
TIME
Fig. 5: the user interface of the PID controller showing a
typical impulse response.
in magnitude than the desired
temperature, then substantial
overshoot is a possibility.
For it definitely to occur, the time
constants of the heating element and
the heated vessel must also be within
an order of magnitude of each other.
So if τ1 is much greater than τ2 for
example, the vessel reacts much faster
than the hot plate and is able to follow
its temperature much more closely,
meaning there is no substantial
overshoot.
Similarly, if the set voltage is near the
maximum voltage, no large overshoot
is possible since we are operating close
to the maximum temperature anyway.
Both these criteria are satisfied for the
usual situation of a vessel heated on
a hot plate. The equivalent maximum
temperature for typical hot plates is
of the order of 1000°C (which is the
value used in Fig.3) and so is much
greater than typical set temperatures.
To cope with the overshoot problem
we adopt a simple strategy. The
response of the equivalent RC circuit
to a step in the set voltage, shown in
Fig.2, is a calculable function of the
circuit.
If we feed this circuit from a
controller with an exactly inverse
response, then the response of the
whole system will be flat – ie, it will
behave like a resistor. The situation is
shown in Fig.4(a).
The response of the RC network
in Fig.1 we write as G(s), while the
response of the controller we write as
C(s). Then if we choose a controller
so G(s)C(s) = R, the combined circuit
behaves as a resistor, so that the output
voltage is related to input control
siliconchip.com.au
Fig. 6: drive energy provided by the PID controller to the
thermal system as a function of time for a critical response.
Starting with 100%, the drive has a trough to avoid
overshoot, and then equilibrates to a steady-state value.
current by Ohm’s law: Vout = Icontrol x R
For a resistor, on/off control gives
no overshoot.
The controller with the required
response – R/G(s) – does not have to
be built physically. We can calculate
this response on a microprocessor and
pass the digital values it generates to
a DAC which provides the control
currents. The system is still driven by
the computer directly, not in simple
on/off fashion but with an R/G(s)
response.
However we have to investigate our
ability to realise the R/G(s) controller
response using a microcomputerDAC combination. It turns out this
is a problem because G(s) for a two
time-constant system requires infinite
control currents to achieve an inverse
response. For finite voltages, we
cannot achieve G(s)C(s) equivalent to
a resistor.
The best we can do is approximate a
2-pole RC network with a single time
constant τd, which we can choose so
that Tset is reached in the minimum
possible time with no oscillation.
This corresponds to what is called the
“critical response”.
Obviously, if we set τd = 0 we get
the inverse response, which as we
stated above is impossible. Hence we
have to determine the minimum value
of τd corresponding to our maximum
current.
Our controller drive will initially
be 100% so as to attain the preset
temperature as quickly as possible
and will then drop quickly to avoid
overshoot, before levelling off to its
steady-state value. Fig.6 shows the
result. If we push the time constant
of the response below a critical
value, a point will be reached where
negative drive is required. Since this
is impossible, overshoot will result.
Hence the critical value of τd
corresponds to that where the curve of
Fig.6 just touches the horizontal axis.
What we are required to do to
complete this program is to measure
the system response G(s). This is
most simply done by pulsing the
circuit for a set period, usually of
the order of a minute and measuring
the response.
For typical systems, the temperature
hardly rises during the pulsing (this is
why it is called an impulse response)
and what we see is a large overshoot
after the power had been turned
off, followed by decay to ambient
temperature. Typical results obtained
with the present project are shown in
the diagram of Fig.5.
In fact, this curve is characterised by
just three parameters. The first is the
maximum steady-state temperature.
We cannot measure it directly because
this would mean overheating the hot
plate, in which case other thermal
processes, such as convection and
radiation will come into play.
Our thermal to electrical
correspondence is based only on
conduction, so the actual maximum
temperature of the hot plate is
substantially less than we estimate
from the curve in Fig.5.
However this does not matter,
provided we operate the system at
temperatures below about 500°C or
so, when these other processes are
unimportant.
The other two parameters are the
July 2007 61
62 Silicon Chip
siliconchip.com.au
4.3k
IC4
OP37
3
4
7
2
+9V
4.3k
47
100nF
6
1 F
B
3
2
C
E
6
–9V
Q1
MJE2955
–9V
4
IC3
OP37
7
100nF
100k
B
PD6
PB0
PB6
PB7
PB5
V–
C
E
R
V+
LM334
Vdd
C
10
GND
IN
GND
22pF
BTA10-600B
G
OUT
2
1
1 F
1 F
10 F
X1 4MHz
220
7805
5
4
15
3
A1
A2
XTAL1
XTAL2
PB3
PD1/TxD
2
100nF
PD0/RxD
20
IC1
AT90S2313
RESET
PB1
MJE2955
11
12
18
6
1
1
13
19
150
3
+9V
R
82nF
V–
V+
4
82k
10k
CS1
LM334
17
5
4 x 100
470 F
+5V
PID TEMPERATURE CONTROLLER
470 F
GND
OUT
Fig. 7: circuit diagram of the PID controller. The inset shows the
modifications required to the thermometer circuit published in
SILICON CHIP in August 2002.
2007
SC
CON3
DIN SKT
–9V
THERM SET
1
3
THERM EARTH
THERM SIGNAL
5
+9V
2
IN
REG1 7805
CON2
ISP CONN
4
FROM
DIGITAL
THERMOMETER
2 +9V
470 F
+9V
1k
0.5W
G
390
0.5W
14
13
5
4
A1
A2
39
0.5W
1 F
10nF
250V
X2
TRIAC1
BTA10-600B
1 F
A
240V AC
OUTPUT
SOCKET
(FEMALE)
A
240V AC
INPUT PLUG
(MALE)
2
(ADDED
DIN SKT)
4
5
1
3
–9V
+9V
IN
HI
7
2
4.7k
(LCD MODULE)
11
DP1
S2b
1
S3b
9
8
7
6
N
10A
SB
TO PC
NO
NC
N
E CASE
E
5
4
3
2
1
CON1
DB9F
CAUTION! ALL WIRING WITHIN RED SECTION
OPERATES AT 240V AC
CON3b
4
6
15
IC2
MAX232
6
SOCKET & CONNECTIONS ADDED TO AUGUST 2002 THERMOMETER
22pF
OPTO 1
MOC3061
11
12
3
1
2
16
time constants τ1 and τ2, which in
the usual case when R2 is small, can
be understood as the heating constant
of the hot plate, which is usually
smaller than the third parameter, the
cooling constant of the hot plate-vessel
combination. All three parameters are
extracted by the software from the
curve in Fig.5.
Another problem with the open
loop controller configuration (Fig.4(a))
we have been considering, is that it
relies on our ability to measure model
parameters exactly, allowing for no
variations in time.
PID control
The fact that we are not able to
measure system parameters exactly,
as well as slight variations in these
parameters during the experiment (for
instance a breeze arising), means we
have to introduce negative feedback
into the system to reduce errors. This
changes the system from open-loop to
closed-loop as shown in Fig.4(b). The
output temperature is sampled and fed
back into the controller input.
In effect, the system functions as
a feedback amplifier. And just as in
that case, the feedback changes the
response of the system.
In order to achieve an RC type of
response now, it turns out that the
controller can be of the proportionalintegral-differential variety (PID).
This is a particularly simple type
of control where the control current
is based on the sum of three terms: a
term proportional to the input voltage
to the controller, a term proportional
to the integral of this voltage, and a
term proportional to the differential
of this voltage.
The constants of proportionality are
the tricky parts requiring calculation
and are determined by the requirement
that we obtain our desired RC response
with minimum τd. These values, as we
have seen, are available directly from
the impulse response.
Thus, for a new system, we operate
the controller by carrying out an
impulse response (this can take up to
a few hours depending on the system)
and registering its parameters as well
as the ambient temperature. These can
also be entered manually, if desired.
For instance, the value of τd
can be decreased from critical if a
faster response is desired and some
overshoot can be tolerated. Now
we enter the set temperatures and
siliconchip.com.au
RECEIVE COMMAND
FROM PC
COMMAND
=
PULSE?
YES
RECEIVE DUTY
FROM PC
PULSE FOR
1 SEC
NO
MEASURE TEMP
SEND TO PC
COMMAND
=
RUN?
YES
RECEIVE PID
DATA FROM PC
CALCULATE
DUTY
NO
COMMAND
=
Tambient?
NO
YES
ABORT
received
from
PC?
YES
MEASURE AMBIENT
TEMP SEND TO PC
NO
SET
button
pressed?
YES
SET
held >
2 sec?
YES
MEASURE SET
TEMP
NO
Simplified Flow Chart of AT90S2313 Code
Fig. 8: this flow chart shows how the microcontroller interprets a range of
commands from the PC.
durations we wish to cycle our system
through (the thermal regimes of the
system) and run the controller.
Circuit operation
The hardware part of the project is
fairly straightforward – see Fig.7. It
is designed to be used in conjunction
with the Digital Thermometer/
Thermostat project referred to earlier
and published in the August 2002
issue.
The heart of the PID Controller
circuit is an AT90S2313 microcontroller IC1 which, in addition to an
extensive ALU (arithmetic logic unit),
features 1kb of program flash memory,
128 bytes each of SRAM and EEPROM
memory, a UART and a fast analog
comparator. The analog comparator is
used in conjunction with the LM334
constant current source (CS1) and
an 82nF capacitor to form a simple
tracking ADC (analog-to-digital
converter) which the microcontroller
uses to measure temperature.
The voltage signal representing
temperature is passed to the ADC
by op amp IC3, configured as a noninverting amplifier with a gain of 20.
Its high-impedance non-inverting
input is fed directly from the digital
thermometer via a shielded 4-core
cable and DIN socket CON3.
Thus IC3 provides minimum
loading to the thermometer circuitry.
This is important since the digital
thermometer outputs voltages in the
range 0-200mV and its temperature
precision corresponds to a voltage of
100mV. Since the ADC has an input
voltage range of 0-4V, maximum
precision and minimum non-linearity
due to input offset requires a gain of
20 for IC3. The OP37 op amp was
chosen here for its low-noise/input
offset characteristics.
The AT90S2313 (IC1) drives the load
(ie, a 240VAC heating element) from
its PB3 output (pin 15) via a MOC3061
optically coupled driver (OPTO1) and
an insulated tab Triac (TRIAC1). OPTO1
July 2007 63
64 Silicon Chip
siliconchip.com.au
TP3
A
K
1N4004
–
+
S1
POWER
ADJ
–2.49V
D6
1N914
VR6
10k
D5
1N914
D4
1N914
VR1
10k
LM335, LM336
3.3k
ADJ
ADJ
TP1
–
+
–9V
TP4
D2 1N4004
–16V
470 F
25VW
470 F
25VW
+16V
IC1
7
OUT
GND
GND
OUT
REG2 7909
IN
IN
1k
10k
TP2
10 F
25VW
10 F
25VW
VR5
500
6
10 F
25VW
VR4
500
0.1 F
10k
–9V
REG1 7809
–9V
4
3 LM627
2
SENSOR1: K TYPE
THERMOCOUPLE
+
1.1k
430
750k
100k
VR2
10k
D1 1N4004
5.6k
ADJ
SENSOR2
LM335
VR3
10k
100k
NC
NO
VR7
1k
S3a
VR8
500
22k
TP5
–9V
+9V
C
2
S2: POS1 –55° – 199.9°C
POS2 –55° – 1200°C
2
RANGE
1 S2a
–2.49V
5.6k
27
470
5.6k
K-TYPE THERMOCOUPLE THERMOMETER/THERMOSTAT
–
+
–
+
D3
1N914
+2.49V
5
4
–9V
4
IC2
OP77
7
–9V
6
3
1
E
B
7
+
1
–
2
–2.49V
+2.49V
A
–16V
D8
1N914
K
D7
1N914
+16V
11
DP1
ZD2
15V
1W
B
B
S2b
2
1
150 0.5W
2.2k
10k
10k
2.2k
150
0.5W
C
6
5
8
RFL
D
G
2N7000
INLO
COM
S
9
RFH
A
K
10
ROH
ZD1
15V
1W
GND
IN
TO
RELAY1
COIL
-1V
G
NO
NC
OUT
10k
TO
RELAY2
COIL
GND
OUT
7809
Q3
2N7000
IN
S
D
BUZZER*
* ONLY ONE
BUZZER USED
BUZZER*
7909
12
DISP– 4
DP2
C
S3b
Q2
BC327
Q1
BC337
LED
C
E
E
C
LCD MODULE
INHI
BC327, BC337
ADDED
5-PIN
DIN SKT
4.7k
K
A
LED1
RED/GRN
2.2k
+9V
A
10 F
25VW
10M
S3: PUSH TO SET
ALARM TEMP
2
3
Fig.9: the red wiring (ie, to the DIN socket) shows the modifications required to the Thermometer/
Thermostat project (August 2002) so that it can be used with the PID Controller.
SC
2007
12V
AC IN
REF2
LM336
-2.5
REF1
LM336
-2.5
+2.49V
3.3k
provides zero voltage switching of the
Triac for minimum electromagnetic
interference. Resistor R1 is used to
limit the current to the MOC3061 LED,
consistent with reliable triggering.
Communication with an optional
PC is provided via the UART serial
interface of the AT90S2313 using
outputs PB0 & PB1 and the MAX232
level converter, IC2. The latter changes
the unipolar 0-5V signals of the
AT90S2313 to the ±10V of the RS232
specification. The serial interface is
used by the PC to send control codes
to the microcontroller and receive
digitised values of the temperature.
The PID Controller circuit is
powered from the ±9V regulators on
the Thermometer PC board and is
interfaced to the LCD module in the
same circuit. These connections are
made via a 4-core shielded cable and
5-pin DIN socket CON3.
Negative current arrangement
A problem would have arisen if we
had attempted to power the microcontroller and MAX232 directly from
the Digital Thermometer, since these
require a single +5V supply. Then the
supply for the digital circuitry would
share a common ground return path
with the analog temperature signal
and since the latter must be precise to
100mV, spikes due to load switching
and UART transmission would be
superimposed onto the signal due to
the voltage drop across the connecting
cable.
To prevent this, the negative currents
from the AT90S2313 and MAX232 are
returned to the -9V supply, instead of
the Digital Thermometer ground, via
PNP power transistor Q2. Its emitter is
held at ground potential (0V) by voltage
follower op amp IC4. Thus, the earth
line from the Digital Thermometer
only carries signal current.
The controller can be run in standalone mode without serial connection
to a PC and to support this, triggering
of the controller by the temperature
set button of the Digital Thermometer
is provided.
The sensing is performed at PD6 (pin
11) of the AT90S2313, which detects a
train of pulses generated by the digital
thermometer when the set button is
pressed. These pulses are normally
generated by the decimal point driver
of the thermometer’s LCD panel.
The original Digital Thermometer
was wired in such a way that the
siliconchip.com.au
decimal point is disabled when the
set button is pressed and this is used
by the PID Controller circuit.
Note that in the original thermometer
project, the “temperature set” button
was wired as a 2-contact switch, which
will therefore still function if the two
wires are interchanged. In the PID
project, all three contacts of the switch
are used, hence you must ensure the
wiring is as per the circuit of Fig.7.
Fig.9 shows the complete circuit
of the Digital Thermometer with the
necessary modifications to connect it
to the PID Controller. These changes
are shown in red.
PID software
Most of the project complexity is
in the software but unless you want
to examine the source code, you only
need to acquaint yourself with the
user-interface screen shown in Fig.5.
Although the controller can be used
to control the load in stand-alone
mode, a PC is required initially to set
the load parameters.
Once the PC is connected via the
serial cable to the programmed microcontroller and the latter connected
to the powered Digital Thermometer,
the PC application can be launched,
whereupon the screen of Fig.5 appears.
The first step is to make the software
connection to the controller box. This is
done by selecting the appropriate COM
port (1-4) and pressing any command
button. For first time use, the test button
is best. If no error message appears, a
connection has been made.
The controller has several modes of
operation, as shown by the simplified
(not all-encompassing) flow chart
in Fig.8. The test and pulse modes
can be started immediately. The test
mode pulses any load connected to
the controller at a 50% duty cycle
and sends temperature values to the
PC, which graphs them. The pulse
mode is similar except a duty cycle
percentage must be entered in the
appropriate edit box.
The other modes require a thermal
regime to be entered. This is done
by entering up to four different
temperatures and durations in the
appropriate edit boxes.
Following this, the ambient
temperature needs to be recorded. You
must either enter a known temperature
and press the enter button on the
screen, or press the measure button
and let the controller measure it as
Parts List
1 PC board, code 04107071,
85.5 x 79mm
1 diecast metal case, 115 x 55 x
90mm (eg, Jaycar HB 5042)
1B9F 9-pin DIN socket (CON1)
1 6-pin PC-mount ISP connector
(CON2)
1 5-pin DIN socket (CON3)
1 240V fused male IEC socket
1 240V female IEC socket
16 10mm M3 screws
8 M3 nuts & washers
4 M3 x 10mm threaded standoffs
1 M3 x 10mm csk screw, nut and
washer
1 M4 x 10mm screw, nut & washer
10 Nylon cable ties
Semiconductors
1 AT90S2313 IC (IC1)
programmed with pid.hex
1 MAX232 RS232 interface (IC2)
2 OP37 op amps (IC3,IC4)
1 MOC3061 optocoupler (OPTO1)
1 BTA10-600B insulated tab Triac
(TRIAC1) (do not substitute)
1 7805 5V regulator (REG1)
1 LM334 current source IC (CS1)
1 MJE2955 PNP transistor (Q1)
1 4MHz crystal (XTAL1)
Capacitors
3 470mF 16V electrolytic
1 10mF 16V electrolytic
4 1mF 16V electrolytic
3 100nF MKT polyester
1 82nF MKT polyester
2 22pF ceramic
1 10nF 250V AC Class X2
Resistors (0.25W, 1%)
1 100kW
1 82kW
2 4.3kW
1 150W
4 100W
1 47W
Resistors (0.5W, 1%)
1 1kW
1 390W
1 10kW
1 220W
1 39W
Miscellaneous
Mains-rated cable (brown, blue
& green/yellow, medium-duty
hookup wire
the current temperature of the probe.
The mode of temperature control
is then chosen. If overshoot is not
expected to be a problem (for instance
the system is effectively a single-pole
system), on/off control can be chosen
since it is faster than PID.
Otherwise PID control is chosen and
PID parameters need to be entered.
July 2007 65
IC3
OP37
4.3k
82nF
100k
C AB
1k 0.5W
IC4
OP37
CABLE TIE
T IE
220
E
BL
CA
100
10k
CON2
150
These parameters (as well as the
5
1 2 3
CABLE TIES SHOULD BE USED TO SECURE ALL
necessity for PID control) can be
CONNECTING WIRES TO EACH OTHER (IE
established by running the system
CON1
LOW VOLTAGE TO LOW VOLTAGE,
MAINS TO MAINS, ETC)
in impulse response mode – that
6
9
is, entering the pulse duration
CON3
(the default is 60 seconds) in the
CA
1
3
BL
corresponding box and pressing the
E
TIE
impulse response button. The load
5
4
will be turned on for the chosen
2
duration and subsequently left
CABLE TIE
alone, while the temperature is being
recorded.
10 F
4.3k
A system with manifest 2-pole
100
82k
+
100nF
(ie, two time-constants) response
1 F
100
will show almost no increase in
100
CS1
temperature during the on period
and subsequently a large overshoot
100nF
Q1
IC1 AT90S2313
470 F
will be recorded, following by a
cooling down period.
X1
470 F
Data acquisition can be ended
REG1
MAINS OUTPUT:
SIDE
2 x 22pF
FEMALE IEC
OF
once a response resembling that
+
CONNECTOR
BOX
in Fig.5 has been obtained. The
1 F
IC2 MAX232
1 F
470 F
essential element here is to allow
+
+
+
47
the load to cool at least 20% below
TRIAC1
100nF
1
F
1
F
its peak temperature before ending
data acquisition.
CS
A
If at any stage during the run,
OPTO1
39 0.5W
17070140
the temperature or time limits of
E
the waveform displayed on the
390 0.5W
MOC3061
screen are exceeded, or if different
10nF 250V X2
N
scales are desired for any of the two
axes, new initial and/or final time/
E
TI
LE
temperature values can be entered
AB
C
into the appropriate four edit boxes
CAUTION!
(FUSE)
adjacent to the graph axes and the
THESE COMPONENTS
redraw button pressed.
AND TRACKS
ARE AT 240V
At this stage the four PID
MAINS POTENTIAL.
A
parameters can be calculated
N
DO NOT CONNECT
TO POWER WHEN
immediately, by pressing the
MAINS INPUT:
OUTSIDE CASE OR
E
FUSED MALE IEC
Calculate button. The values
WITHOUT CASE LID.
COMMON
CONNECTOR
appearing in the corresponding boxes
EARTH POINT
(CASE)
are the three main characteristics of
Fig.1, discussed in the PID Control
NOTE: INSULATE ALL TERMINALS ON THE IEC SOCKETS WITH HEATSHRINK SLEEVING
Theory section: ie, the maximum
Fig.10: the PC board parts layout and external board wiring. Note that the case
effective temperature of the element
must be earthed to the mains earth and the PC board also earthed at this point.
and the time constants τ1 and τ2.
If the response shows no peak or
a weak peak, error messages will appear. In this case, you
In the PC mode, the PC calculates the required duty cycle
must either re-acquire the response (after changing the pulse
and sends it to the controller, which pulses the load and sends
duration appropriately) or run the load in on/off mode. You
the current temperature value back to the PC to be displayed.
can alter the PID parameter values if you wish, at this stage.
In stand-alone mode, the controller runs its own algorithm
This might be necessary to improve control, since the real
to calculate the duty cycle but still sends temperature values
setup can deviate from the model of Fig.1.
to the PC. In this mode, the PC can be disconnected at any
Thus if previous runs with the same system have shown
time with no effect on system operation. Both modes can be
that the final temperature is always 1% lower than the set
terminated using the “Abort” button.
value, the maximum effective temperature of the element
The third mode of operation does not require the
can be decreased by 1%. Once the parameters have been
participation of a PC at all. In this case, the Digital
calculated, the “Set Parameters” button needs to be
Thermometer and PID Controller are used to run the thermal
pressed, so they and the thermal regime are recorded in
regime already stored in the controller EEPROM. This mode
the microcontroller’s EEPROM.
is initiated by pressing the temperature set button on the
The load can now be run in the desired regime. Three
digital thermometer for at least 0.5s.
choices are available, two operating under PC control and
If this button is held down for longer than two seconds,
one stand-alone.
an additional feature is turned on, whereby rather than
LE TIE
C
LE
AB
LE
AB
T IE
C
T IE
66 Silicon Chip
siliconchip.com.au
SECURE LOW-VOLTAGE WIRING AT
BOTH ENDS WITH CABLE TIES
NOTE: INSULATE ALL
TERMINALS ON IEC SOCKETS
Here’s how it fits together in the diecast case as per
the diagram at left. Not shown here are the cable ties
used to prevent wires moving and shorting. Note: use
medium-duty hook-up wire for the connections to CON1
& CON3 (not rainbow cable as shown here) and keep the
connections as short as possible (see safety panel).
using the set temperature stored in memory as the first set
temperature value, the controller reads the temperature set
on the digital thermometer and uses it instead. This mode is
terminated, either when the time stored in memory elapses
or the thermometer is turned off.
Construction
All the components of the PID Temperature Controller
are mounted on a PC board measuring 85.5 x 79mm and
coded 04107071. This is housed in an aluminium diecast
case measuring 115 x 55 x 90mm (eg, Jaycar HB-5042).
The complete wiring diagram is shown in Fig.10. An
accompanying photo shows the wiring layout of the
prototype which is slightly different to that shown in Fig.10.
The diecast case needs to be drilled to accept an IEC male
mains socket which contains an integral 250V 10A slowblow fuse, an IEC female mains socket, and 5-pin DIN and
RS232 sockets. The required cut-outs for the IDE sockets
(male and female) can be made either by drilling around
the periphery with a small drill and filing out, or by using
a mill if one is available.
Two other holes also need to be drilled: one 3mm hole
to affix the isolated-tab Triac and a 4mm hole to affix the
mains earth lugs.
Assembly of the PC board is quite straightforward but
we suggest the following procedure. Install the PC pins (at
the low-voltage wiring points), the sockets and connector
siliconchip.com.au
CON2 first, then the passive components such as resistors
and capacitors, followed by the link and 4MHz crystal.
Next are the 3-terminal regulator, transistor Q2 and the op
amps, current source (LM336) and the optocoupler. Ensure
that the 1mF and 10mF tantalum capacitors are connected
with the correct polarity.
The Triac should be soldered to the PC board, keeping its
leads as short as possible, while still allowing them to be
cranked slightly, so that its insulated tab can be secured to
the case. Be sure to use an insulated tab Triac, as specified
in the parts list.
Note that the entire mains section of the track needs to be
tinned with a layer of solder about 1mm thick, to reduce PC
board heating when high-power loads are being controlled.
Use a 40W soldering iron or higher for this.
Once the diecast case has all holes drilled and machined,
the IEC male and female power sockets can be installed,
followed by the 5-pin DIN socket and 9-pin D socket. Don’t
get the IEC sockets mixed up – the male socket mounts at
the end of the case.
Before installing the board in the case, it will be necessary
to solder the two brown mains wires to it, near the 1kW 0.5W
resistor – see Fig.10. Do not use PC stakes to terminate these
leads – solder them direct to the PC board. In addition,
you will need to connect the green/yellow earth wire to the
board at bottom right. Be sure to use 240VAC cable for all
the wiring to the IEC sockets and use heatshrink sleeving
to insulate all the terminals.
The Triac tab can now be smeared with some heatsink
compound and the assembled PC board mounted in the
case, using the four corner mounting holes pre-drilled in the
box. Secure the Triac tab to the case, using a screw, nut and
lockwasher, then connect the wiring to the two IEC sockets
and install the cable ties. The earth leads are connected to
solder lugs which are then bolted to the diecast case using
an M4 x 10mm screw, nut and lockwasher.
Make sure the mains wiring is as short as possible and
is kept well away from the low voltage parts of the circuit.
Once the controller is assembled, the Digital Therm
ometer must be equipped with a DIN socket so that a
connection can be made to the controller. This is done by
drilling a hole in the back panel, fitting a DIN socket and
wiring it as shown in Fig.8.
Our photos show the Dick Smith Electronics version of
the Digital Thermometer, which was different in a number
of aspects to the original
project featured in
August 2002. The
DSE version
July 2007 67
These photos show the modifications to the Digital Thermometer – the DIN socket on the rear panel allows interfacing to
the PID Controller. This is the DSE kit version which is slightly different to the original August 2002 project.
had additional 5V regulators for its LCD module and slightly
different interfacing to the LCD. However, the DIN socket
connections are still the same.
Operation
Connect the controller to the Digital Thermometer using
a 5-wire DIN cable and to the PC with a 9-way RS232 cable
(do not apply mains power to the controller at this stage).
Turn on the thermometer and check for the presence of +9V
& -9V on pins 7 & 4 of either of the two op amps. Check
for +5V at pin 20 of the AT90S2313 and confirm that the
voltage difference between the controller box and the digital
thermometer earth is no more than 1mV or so.
When the unit has passed the above tests, connect an
AVR programmer to the programming header and program
the microcontroller’s FLASH and EEPROM. The software
will be available on our website at www.siliconchip.com.au
Remove the programming connector and close the box.
Connect a suitable resistive load and mains power to the
controller and launch the PC application. Choose a suitable
COM port number and press “Test”. If an error message
indicates “no connection”, change the COM port number
(in the range 1-4) and try again.
If everything is working, the load should be pulsed on/
off with a 50% mark-to-space ratio and a graph of the probe
temperature-versus-time should appear. You can touch the
temperature probe with your fingers and check that the
temperature rises and then falls.
Calibration
It is likely that at this stage you will notice some
difference between the Digital Thermometer reading and
the temperature displayed on the screen. This is mainly
due to the particular ADC component values in your
circuit. Choosing the scaling and offset appropriate to
your components can reduce these errors. This is done by
pressing the “Calibrate” button and changing the scalings
displayed in the dialog which appears.
You should only do this after you have taken comparative
readings of the temperature at two different points and
calculated the required changes in the scaling and offset.
68 Silicon Chip
Some residual random variation between the Digital
Thermometer and screen temperature readings might
still be observed after this but it should not exceed a few
tenths of a degree. The reason is that the LCD voltmeter
in the thermometer averages temperature values over an
interval of about one second, whereas the controller reads
instantaneous values.
We should also note that the accuracy with which the
desired temperature is maintained depends, amongst other
things, on the accuracy with which the ambient temperature
is measured. If the latter varies during the run, this variation
will be reflected in the temperature set by the controller.
This is most easily seen by referring to Fig.1.
A change in ambient temperature is equivalent to a
change in earth potential, which is reflected in all voltages
which are measured with respect to it. To counteract errors
introduced this way, the run should be aborted, a new ambient
SC
temperature entered and then operation resumed.
Check These Important Safety Points
(1) Use medium-duty hookup wire for the connections between
the PC board and connectors CON1 & CON3. These leads must
be kept as short as possible and secured at both ends using
Nylon cable ties. That way, if a lead comes adrift, it cannot move
and contact any mains-operated components on the PC board or
the terminals of the IEC sockets. DO NOT use rainbow cable (as
shown in the prototype) – it breaks too easily.
(2) Use mains-rated cable for all connections to the IEC
sockets and insulate the terminals using heatshrink tubing.
Alternatively, use insulated spade lugs (use a ratchet-driven
crimping tool to properly secure the spade lugs to the leads).
(3) Secure the high-voltage wiring between the PC board and
the IEC sockets with cable ties. Again, the idea is to make it
impossible for any leads to move and contact other parts of
the circuit if they come adrift.
(4) Part of the circuitry on the PC board operates at mains
potential (as do the terminals of the IEC sockets). Do not touch
any part of this circuitry while this device is plugged into the
mains. DO NOT attempt to build this device unless you know
what you are doing and are familiar with high-voltage wiring.
siliconchip.com.au
|