This is only a preview of the April 1999 issue of Silicon Chip. You can view 34 of the 96 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 "High-Power Electric Fence Controller":
Items relevant to "Programmable Thermostat/Thermometer":
Articles in this series:
Items relevant to "A Rev Limiter For Cars":
Purchase a printed copy of this issue for $10.00. |
Do you need precise temperature
control? How about temperature
monitoring with preset alarms?
Here’s a project which will do
either – and much more!
A programmable
thermostat/thermometer
By KEITH RIPPON
T
HIS PROJECT combines the
Dallas Semiconductor DS1620
Programmable Thermometer
chip and AT89C051 8‑bit micro
controller to provide a programmable
thermometer and thermostat.
Some of the possible applications
for this project include incubators,
computers, power supplies, drying
rooms, greenhouses, home brewing,
power amplifier and heatsink monitoring or any other devices requiring
temperature monitoring or control.
The AT89C2051 microcontroller
from Atmel is one of the smallest
members of the 8051 family. As the
saying goes, “Good things come in
small packages”. This one comes
in a 20‑pin package and features 2K
bytes of programmable Flash memory,
54 Silicon Chip
128 bytes of RAM, 15 programmable
I/O lines, two 16‑bit timer/counters,
six interrupt sources and an on‑chip
analog comparator.
It is fully compatible with the
MCS‑51 architecture and it can be
programmed using the MCS‑51 instruction set.
The DS1620 Digital Thermometer
and Thermostat is capable of providing 9‑bit temperature readings from
‑55°C to +125°C in 0.5°C increments.
It has three thermal alarm outputs,
Tcom, Tlow and Thigh, which allow
the device to operate as a thermostat. Tcom is driven high when the
temperature exceeds TH and remains
high until the temperature falls below
that of TL.
Tlow is driven high if the DS1620
is less than or equal to a user defined
temperature TL. Thigh is driven high
if the DS1620 temperature is greater
than or equal to a user defined temperature TH. The temperature reading
is provided in a 9‑bit, two’s complement format.
Table 1 shows the binary output
data at various temperatures. The
temperature data is transmitted over
a 3‑wire serial interface, comprising
Data, Clock and Rst, LSB first. The
user‑defined temperature settings
are stored in non‑volatile memory
and this allows the device to be programmed prior to being installed in
a system.
This makes for a relatively cheap
and accurate thermostat, while allowing for an easy way to alter the end
April 1999 55
Fig. 2: the PC
board component
overlay. As you
can see, the board
is designed to be
divided in two and
joined by flexible
cable but can be
used intact if your
application allows
it.
product’s temperature parameters.
Reprogramming is a simple matter of
either installing it back into the programmer or via a 3‑wire interface from
the programmer to the target system.
While the DS1620 is capable of
covering the range from ‑55°C to
+125°C, in this particular application
it is only used from 0-99°C, with 1°C
increments. This should be ample for
most uses.
Circuit operation
The circuit diagram is shown in
Fig.1 and it uses four ICs and two
7‑segment LED displays.
IC1 is the programmed AT89C2051
microcontroller and 8 data lines from
its Port 1 (P1), pins 12‑19 are used to
drive IC3 & IC4. These ICs are 74LS47
BCD to 7‑segment decoders and each
one drives one of the 7‑segment LED
displays.
IC1 takes the 9‑bit temperature
reading from the DS1620 and converts
it to drive the 7‑segment displays.
Two networks, RN1 & RN2, provide
current limiting for the displays,
which incidentally are of the common
anode type (SA52).
Port 3 (P3) is used to interface to the
DS1620 and to the four pushbuttons
used for programming. Of this port,
pins 7, 8, 9 & 11 are used for the four
pushbuttons which are designated (1)
Select, (2) Increment, (3) Decrement
and (4) Store.
56 Silicon Chip
Pushbuttons S2 & S5 also serve to
put the DS1620 into the standalone
mode if this option is required. Pins
2, 3 & 6 interface to the DS1620.
Pins 1,2 & 3 of the DS1620 are the
Data, Clock and Reset (RST) pins,
respectively. Don’t confuse the RST
pin of the DS1620 with that of IC1.
The reset is active low which
means that for communication to take
place between IC1 and the DS1620,
pin 3 must be taken high, otherwise
the states of the Data and clock pins
will be ignored.
Pins 5, 6 & 7 of the DS1620 are the
three alarm outputs, with pin 5 being
Tcom, pin 6 being Tlow and pin 7 Thigh.
You have a choice of alarm output
and this is selected with jumper K4,
to control some form of heating or
cooling device
In this circuit, the selected output
controls a relay, RLY1, via diode D3
and transistor Q1.
Transistor Q2 and flashing LED1
provide a fault indicator.
Table 1
Temperature
+125°C
+25°C
+0.5°C
0°C
‑0.5°C
‑25°C
‑55°C
Binary output
011111010
000110010
000000001
000000000
111111111
111001110
110010010
Capacitor C8 and resistor R1 provide the power on reset for the microcontroller. To ensure a valid reset, pin
1 must be held high long enough to
allow the oscillator to start up plus
two machine cycles.
A 12MHz crystal and two 27pF
capacitors, C9 & C10, are the external
components for the microcontroller’s
oscillator.
Quite a few headers have been used
on the board and these were used extensively during development which
involved programming with an 80c32
SBC (single board computer)and an
EPROM emulator.
A 5V 3‑terminal regulator provides
all the on‑board power and this is
driven by a 12V DC input. This could
be a battery or a DC plugpack but
while +12V is shown on the circuit,
an ordinary 12V plugpack should
not be used as the output voltage
will usually be much higher, around
16V. That will cause the 5V regulator
to become hot. Therefore, if you are
going to use a plugpack, make it a
9V DC type.
The 12V required by the relay is
taken from the input side of IC5, after
the polarity protection diode, D1.
Board assembly
Construction of the Thermostat/
Thermometer is relatively straightforward. The first thing to do is to
decide whether or not you want to cut
the board so that you have separate
display and microcontroller boards. It
is much harder to cut the board once
it is populated so you have to make
the choice before assembly starts.
If you do decide to have two separate boards, you can mount them
Parts List
1 PC board, 89 x 144mm
1 12MHz crystal (X1)
1 20‑pin IC socket
4 16‑pin IC sockets
1 8‑pin IC socket
2 PC‑mount terminal blocks
1 8‑way pin header
4 16‑way pin headers (cut to
length)
3 2‑way pin headers
1 jumper shunt
1 20‑pin IC socket strip (for LED
displays)
1 9V 150mA DC plugpack
1 SPST toggle switch (S1)
4 SPST momentary contact
pushbutton (S2‑S5), Jaycar
SP‑0730 or equivalent
1 small finned heatsink (for 3‑
terminal regulator)
1 12V mini relay (RLY1)
at rightangles to each other or join
them with a length of ribbon cable.
Note that headers K6 and K7 make
provision for the ribbon cable link.
The next thing to do is to check the
copper side of the board for shorted
or open circuited tracks. These could
lead to problems when you come
to powering up the board, not to
mention that it could be expensive
if you happen to “blow up” some
component, especially the DS1620
or AT89C2051.
Here’s a tip before you start: if you
find that the components are falling
out of the board when you flip it over
to solder them in, a piece of masking
tape makes a good substitute for a
third hand.
You can start the board assembly
with the installation of the wire links.
They are easier to solder in if the
wire you use is not tarnished, so use
bright and shiny tinned copper wire
or freshly cut off component pigtails.
Next you can insert and solder in
the resistors, diodes, LED, transistors
(check the orientation), capacitors
and pushbuttons. After this you can
install the IC and display sockets but
don’t insert the ICs or displays yet.
I suggest using the machined pin
sockets. While they are more expensive they are more reliable. If you
can’t afford them at least use one for
the DS1620. The cheaper standard
Semiconductors
1 AT89C2051 programmed
microcontroller (IC1)
1 DS1620 programmable
thermometer (IC2)
2 74LS47 BCD to 7‑segment
decoders (IC3,IC4)
1 7805 3‑terminal 5V regulator
(REG1)
1 BC338 NPN transistor (Q1)
1 BC328 PNP transistor (Q2)
2 1N4004 silicon diode (D1,D2)
1 1N914, 1N4148 silicon
switching diode (D3)
2 Kingbright SA‑52 common
anode 7‑segment LED displays (DISP1,2)
1 flashing LED (LED1)
Capacitors
1 1000µF 25VW PC electrolytic
2 10µF 25VW PC electrolytics
5 0.1µF 63VW MKT polyester or
monolithic
2 27pF ceramic
Resistors (0.25W, 1%)
4 10kΩ
2 8.2kΩ
1 1.2kΩ
1 470Ω
2 470Ω resistor networks
(RN1,RN2)
This photo of the completed PC board is reproduced very close
to full size so it will be a handy guide to component placement in
conjunction with the component overlay.
April 1999 57
sockets do not lend themselves well
to constant insertion and removal
of ICs.
The LED displays were installed
using machine pin IC socket strips.
Just cut them to the required length
and solder them in. The 7‑segment
displays are Kingbright SA52 (common anode), available from Jaycar
Electronics.
Next, install the power connectors
K1 & K8, the relay and 3‑terminal
regulator. A small finned heatsink
should be fitted to the regulator.
Testing
At this stage the board should be
ready for testing. Check all your soldering work and make sure that there
are no solder bridges between IC pads
or other component solder pads and
tracks on the board.
Connect a 12V DC supply to K1 and
switch on. Use your multimeter to
check that you have about 11V at the
cathode of diode D1 and +5V at the
output of the regulator. If not, switch
off and check your work again to find
out why not.
If all is well, you can check for the
presence of 5V around the IC sockets. If this checks out, switch off and
insert the ICs and displays.
The ICs are all inserted with pin 1
to the lefthand side of the board (the
regulator side) and the two displays
have their decimal points to the bottom right of their individual sockets.
Buying The Parts
Some of the key components for this project can be supplied by the designer,
Keith Rippon. The prices are as follows:
Programmed AT89c2051
DS1620 programmable thermometer
470Ω resistor networks
12MHz crystal
$25
$15.00
$1.20 each
$3.50
The software listing may also be obtained for $25. Payment may be made by
cheque or money order. Please add $5 to your payment for p&p.
Send orders to:
Keith Rippon, PO Box 19, Camperdown, NSW 1450.
The PC board may be obtained by contacting RCS Radio Pty Ltd, 651 Forest
Road, Bexley, NSW 2207. Phone (02) 9587 3491.
Once you have installed the ICs
and displays it is time for the big test.
Reconnect the supply and switch on.
The “tens” display should show segments d, e & g and the “units” display
should show the c, d & g segments,
both for a couple of seconds.
If not, switch off immediately and
check your work.
After the couple of seconds have
elapsed, the current temperature
should be displayed and if you put
your finger on the DS1620 the temperature should go up a couple of
degrees or more.
While it may seem like a crude way
of testing your circuit’s operation, it
is quicker than rigging up some other
form of test apparatus. Once you have
done this you can cycle through the
current TH and TL temperatures with
pushbutton switch S2.
If you use a brand new DS1620,
the current temperature will be the
ambient temperature around your
DS1620, TH will be 15°C and TL will
be 10°C. When you return to the
current temperature, the display will
flash three times to indicate that the
current temperature is being shown.
This is helpful when all your temperature settings are similar.
The three thermal alarm output
pins on the DS1620 should be as folFig.3: this is the fullsize PC board pattern
for those who wish to
make their own. The
pattern is also
available from the
SILICON CHIP website.
You can also use this
patern to check commercial boards.
58 Silicon Chip
References:
More information about the components used in this design can be
obtained from the internet:
• At89c2051; www.atmel.com/
• DS1620; www.dalsemi.com/
• SA52 LED: www.kingbright.com/
This last website is slightly different to the others whereby you navigate around using Acrobat Reader
once you get to the data sheet section.
You need Acrobat Reader anyway
for the data sheets once you have
downloaded them from other sites
as they are in .pdf format.
If you don’t have Acrobat Reader it
is available via the SILICON CHIP web
site, www.siliconchip.com.au
You can also visit my website at
www‑personal.usyd.edu.au/~krippon/
or you can send email to me at
SC
krippon<at>mail.usyd.edu.au
Protect Your Valuable Issues
Silicon
Chip
Binders
REAL
VALUE
AT
$12.95
+$5 ea
P
&P
Or buy
5a
get th nd
postag em
e free
Each binder holds up to 14 issues
Heavy board covers with 2-tone green vinyl covering
SILICON CHIP logo printed in gold-coloured lettering on spine &
cover
Just fill in & mail the handy order form below; or fax (02) 9979 6503; or ring (02)
9979 5644 & quote your credit card number.
Yes! Please send me ________ SILICON CHIP binder(s) at $A12.95 each
plus $5.00 p&p. Australia only – not available elsewhere.
Enclosed is my cheque/money order for $__________ or please debit my
Bankcard Visa Card MasterCard
Card No.
Signature_________________________ Card expiry date______/______
Name _____________________________________________________
Street _____________________________________________________
Suburb/town __________________________ Postcode______________
SILICON CHIP PUBLICATIONS
PO Box 139, Collaroy Beach, NSW 2097, Australia.
Phone (02) 9979 5644 Fax: (02) 9979 6503.
✂
lows: Pin 5 (Tcom) high; pin 6 (Tlow)
low; and pin 7 (Thigh) high.
To program the DS1620, first select
either TH or TL with pushbutton S2
and then use S3 and S4 to increase
or decrease the value.
Keeping S3 or S4 pressed will cause
the value to increase or decrease automatically until you let go of the pushbutton. Once you have your values
set, use pushbutton S5 to write them
to the DS1620’s non‑volatile memory.
If you decide half-way through that
you don’t want to change the temperature values just press S2, which will
step you back to the current temperature, without altering TH or TL.
To put the DS1620 into the stand
alone mode, use pushbutton switch
S5. Pressing it once will change the
display to ‘55’. If you are sure you
want to put the DS1620 into the
stand-alone mode, press S2. If you
don’t, press S5 again and it will take
you back to the current temperature
reading. When the DS1620 is in the
stand-alone mode the display flashes
“00”.
If you wish to return to CPU control, just press S2.
Finally, don’t forget to switch off
before removing the DS1620 from
its socket when using it in another
application.
When you use the DS1620 in a
stand-alone application, don’t forget
to provide adequate insulation and
mounting for it. It won’t work well,
if at all, when it gets wet or the pins
are shorted, etc.
April 1999 59
|