This is only a preview of the June 2018 issue of Silicon Chip. You can view 38 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:
Items relevant to "The USB Flexitimer: accurately timed switching":
Items relevant to "Wide-range digital LC Meter":
Items relevant to "Switch on or off anything with a Temperature Switch":
Items relevant to "800W (+) Uninterruptible Power Supply (UPS) Part II":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
Switch on or off when it’s TOO HOT or TOO COLD
• Monitors from -10°C to +125°C
• Resolution: 1°C up to 100°C;
2°C for 100-125°C
• Adjustable hysteresis
• Accuracy: typically ±2°C
• Two sets of relay contacts to
control two individual devices
By John Clarke
Temperature Switch Mk2
Turn on a pump or fan if something is too hot... or turn on a heater if
it's too cold. Two sets of changeover contacts allow a flexible switching
arrangement. All you need to set it up is a multimeter.
T
here are many instances where
you may want to switch something
on or off at a certain temperature. You
could be switching a fan, pump, light,
alarm, heater, cooler or something else.
Our new Temperature Switch Mk2 can
do any of these tasks. You can use it in
automotive, household and industrial
applications.
If switching the load directly, the
Temperature Switch can be used for
devices that have a supply voltage up
to 30V DC or AC and draw up to 5A
(or 8A if the specified Altronics relay
is used).
If you want to switch mains-powered devices you will need a separate
250VAC-rated relay, contactor or solid
state relay.
The Temperature Switch's relay
can be energised when the temperature goes above (or below) a particular
threshold, which is set using a trimpot (VR1). Then you can set a lower
(or higher) threshold temperature with
another trimpot (VR2).
Why do you need two temperature
settings? In practice, if you have just
one temperature setting, the relay may
switch rapidly on and off (chatter) as
the temperature changes by very small
amounts near your preset temperature.
The difference between the two
temperature settings can be as little
Switches a relay if the temperature goes above (or below) a preset value and keeps
it on until the temperature drops below (or goes above) a second preset value
Relay contact rating of up to 30VAC/DC at 5A or 8A (see parts list)
Adjustable hysteresis is set with an upper and lower threshold
Switching temperature can be anywhere from -10°C to +125°C
Power supply: 12-15V DC at up to 60mA; quiescent current 20mA
Indicators: power on LED1, relay energised LED2
Thermistor temperature reading between TP4 and TPref, 10mV/°C
44
Silicon Chip
Celebrating 30 Years
as 1°C but in practice you would go
for a larger difference to stop the relay from switching too frequently. In
effect, these two temperature thresholds provide hysteresis for the circuit.
For example, you could set the unit
to energise the relay if the sensed temperature goes above 60°C but once it
has been energised, it can be set to remain energised until the temperature
drops below 55°C.
If the relay is connected to a fan,
that will ensure that it runs for a minimum period before switching off, ie,
the time taken to reduce the temperature by 5°C.
Sensing the temperature
We use a low-cost negative temperature coefficient (NTC) thermistor to
measure temperature. This is a twolead device with a resistance that varies with temperature. As it gets hotter,
its resistance drops. It can be attached
to an object to sense its temperature
(eg, a heatsink).
You can get waterproof thermistors
which can be immersed in liquid, or
you could waterproof a standard NTC
thermistor. You can also get lug-mount
siliconchip.com.au
Fig.1: the circuit uses a PIC microcontroller (IC1) to monitor the temperature via an NTC thermistor (TH1). IC1
compares the measured temperature to the thresholds set by trimpots VR1 & VR2 to decide when to energise RLY1.
NTC thermistors which can easily be
attached to a flat surface using a screw
or bolt.
Circuit description
The full circuit of the Temperature
Switch is shown in Fig.1. It’s based
on IC1, an 8-pin PIC12F617 microcontroller that includes an internal
analog-to-digital (ADC) converter with
four multiplexed inputs and a PWM
(pulse-width modulation) generator.
The NTC thermistor TH1 is connected across CON2 and it forms a voltage
divider in combination with the 3.9kW
resistor from the +5V rail. Therefore
the voltage across TH1 will drops as
the temperature rises.
This voltage is stabilised by a 100nF
capacitor connected across the pins of
CON2 and it has more filtering provided by another RC low-pass filter
comprising a 10kW resistor and second 100nF capacitor, before being fed
to input pin 7 of IC1.
Pin 7 is set up as the AN0 analog
input and IC1 can read the voltage at
this pin using its internal 10-bit ADC,
with a resolution of approximately
5mV (5V ÷ 210).
It then uses a look-up table to convert the voltage reading into a temperature. This is necessary since the
relationship between temperature and
resistance of TH1 is non-linear.
siliconchip.com.au
The two threshold temperatures are
set using trimpots VR1 and VR2 which
are connected across the 5V supply
rail. Their wipers go to analog input
pins 6 (AN1) and 3 (AN3) and the setting of each potentiometer determines
the voltage at these pins, ie, 0-5V. See
the section below for an explanation
of how these voltages correspond to
temperatures.
The 100nF capacitors connected
from each analog input to ground
provide a low source impedance for
the ADC.
IC1 converts the voltages at pins 3
and 6 to digital values and then into
temperatures. It then compares the
sensor temperature to the upper and
lower switching thresholds, to decide
whether relay RLY1 should be energised. It drives digital output pin 2
(GP5) high to energise the relay or low
to de-energise it.
When pin 2 is high, NPN transistor
Q1 is turned on to energise the coil of
relay RLY1, pulling in its armature and
connecting the COM and NO contact
pairs on CON3.
The 1kW base resistor sets the base
current for Q1 to 4mA. LED2, connected across the coil of RLY1 via its 10kW
series resistor, lights to show when the
relay is energised.
When transistor Q1 is turned off to
switch off the relay, diode D2 absorbs
Celebrating 30 Years
the voltage generated by the collapsing
magnetic field in its coil. This protects
Q1 from any back-EMF spike voltages.
The DC power source is connected
to CON1 and can be in the range of
12-15V DC. Diode D1 provides supply reverse polarity protection. The
voltage at D1's cathode is (nominally)
around 11.4V and this is used to drive
the coil of RLY1.
The 100µF electrolytic capacitor filters the supply, and voltage transients
are safely clamped using a 16V zener
diode (ZD1). Current through ZD1 is
limited by the series 47W resistor.
The 3-terminal regulator REG1 provides a regulated 5V supply rail for IC1
and TH1. LED1 is connected across
the 5V supply with a 3.3kW currentlimiting resistor and lights whenever
the unit is powered up.
IC1's MCLR reset input is tied to
the 5V supply via a 10kW resistor to
provide a power on reset for the microcontroller.
Relationship between
temperature and voltage
We mentioned earlier that trimpots
VR1 and VR2 can be adjusted to provide a voltage of 0-5V to IC1, corresponding to temperature thresholds
that can be set in the range of -10°C
to +125°C. So how do you adjust the
trimpots for each temperature?
June 2018 45
lution of IC1's ADC, giving better accuracy. The equivalent scaling is done
in the software so that the temperature
thresholds match the readings at TP1
and TP2.
Monitoring temperatures
Fig.2: compare this component layout for the Temperature Switch Mk2 with the
completed prototype PCB shown below when building the project. If you need
to use the Temperature Switch Mk2 to switch on/off mains-powered devices,
you have to substitute RLY1 with a 250VAC-rated DPDT relay, which must be
mounted off the PCB.
So that you can monitor the current
sensor temperature easily, the PWM
output at pin 5 is driven with a 3.9kHz
square wave with a duty cycle that is
proportional to temperature. When
you connect a DMM between this pin
and TPref, it will internally average
out the PWM signal to give a DC voltage reading. This also has a scaling
factor of 10mV/°C.
So if you get a reading of say 275mV
between TP4 and TPref, that corresponds to a temperature of 27.5°C
(275mV ÷ 10mV). If you want to measure the voltage across the thermistor
itself, you can do so between TP3
and GND.
Selecting a thermistor
The short answer is that you connect the negative lead of your digital
multimeter to the test point marked
TPref. (It is biased to around 100mV
above ground using a 10kW/200W resistive divider across the 5V supply
rail). The positive lead of your DMM
then goes to TP1 (for setting trimpot
VR1) or TP2 (for setting VR2).
By connecting the negative lead of
your DMM to TPref, you will get a
negative reading at test points TP1 and
TP2 when trimpots VR1 and VR2 are
set close to their fully anti-clockwise
positions. This allows you to set temperature thresholds below 0°C.
The 24kW/10kW resistive dividers
between AN1/AN3 and TP1/TP2 cause
the voltages that you read with your
multimeter at TP1 and TP2 to change
by 10mV for each 1°C adjustment. So
you can simply read the voltage (in
mV) between TP1 and TPref or TP2
and TPref and then divide by ten to
convert from the voltage reading to a
46
Silicon Chip
temperature. For example, 300mV =
30.0°C, 472mV = 47.2°C etc.
So the 100mV value at TPref allows
for up to a -10°C adjustment where a
reading at TP1/2 will be -100mV. The
maximum setting of VR1/VR2 gives
a reading at the relevant test point
of 1.37V (5V ÷ [24kW ÷ 10kW + 1] 100mV) or 1370mV, corresponding to
+137.0°C. This confirms that we can
set the thresholds up to the +125°C
maximum that the unit can handle.
We considered using a scaling factor of 1mV = 1°C but were concerned
that some DMMs may be inaccurate
when reading small voltages. We were
also concerned that this could result
in increased inaccuracy due to noise
and EMI that could be picked up by
the meter.
Note that we feed the voltage at the
wipers of VR1 and VR2 directly to
IC1, rather than sensing the divideddown voltages at TP1 and TP2. This
allows us to use the full 10-bit resoCelebrating 30 Years
The thermistor we used has a reference resistance of 10kW at 25°C and a
beta value of 4100. 10kW NTC thermistors are very common so you shouldn't
have trouble finding a suitable sensor.
The beta value determines the shape
of the temperature/resistance curve.
While beta values vary from device to
device, it is very common to find NTC
thermistors with a beta close to 4000.
As long as yours is in the range of 39004200 then it should give similar results
to the one used in our prototype.
We generated the temperature lookup table for our firmware using this
online calculator: siliconchip.com.
au/link/aaj1
If you want higher accuracy
Although general-purpose NTC
thermistors are typically accurate to
within a few degrees Celsius, if you
want higher accuracy, use a thermistor with tight tolerances such as the
AVX NJ28NA0103FCC. This has a 1%
tolerance at 25°C and a beta value of
4100, also with a 1% tolerance. It is
available from RS: siliconchip.com.
au/link/aaf7
This thermistor is not encapsulated.
For remote temperature measurement,
you can extend the leads. Use insulation sleeving (eg, heatshrink tubing)
over the wire connections. For attachment to a solid object, the thermistor
can be epoxy glued to the object or
clamped against it. For outdoor use
siliconchip.com.au
or immersion in liquid, insulate the
thermistor assembly using neutralcure silicone sealant.
Note that if extending the leads over
long distances, even if the wires add a
resistance of more than 10W, this is still
only a 0.1% error at 25°C; although the
error will increase at higher temperatures. So check the total (“round-trip”)
resistance before wiring the thermistor
to a very long cable.
Construction
The Temperature Switch Mk2 is built
on a double-sided PCB coded 05105181
measuring 104 x 58.5mm. It can be
housed in a UB3 129 x 68 x 43mm Jiffy
box, mounted on short spacers.
Use the overlay diagram, Fig.2, as a
guide during construction. Fit the resistors first. These have colour-coded
bands, as shown in Table.1 but we suggest that you use a DMM set to measure
ohms to check the values, as the colour
bands can be easily misinterpreted.
Diodes D1, D2 and ZD1 are installed
next and these need to be inserted with
the correct polarity, ie, with the striped
end (cathode, “k”) oriented as shown
in Fig.2. Both diodes are 1N4004
types while the zener diode (ZD1) is
a 1N4745 or equivalent.
We recommend using an IC socket for IC1. Take care with orientation
when installing the socket and when
inserting the IC. Note that IC1 needs to
be programmed with the software for
the Temperature Switch before use. A
programmed IC can be obtained from
the Silicon Chip Online Shop (search
for it by code or month).
Alternatively, you can program a
blank chip yourself using the HEX file
which is available from the Silicon
Chip website (free for subscribers).
For the test points, we used five PC
stakes. One for TPgnd and the others
for TPref, TP1, TP2, TP3 and TP4. If
left as bare pads, they can be probed
directly using standard DMM leads.
The capacitors are mounted next.
The electrolytic types must be inserted
with the polarity shown (longer lead
is positive, with a stripe on the can
indicating the negative lead). Install
transistor Q1 and regulator REG1 now
and take care not to mix them up as
they have the same package.
Now fit trimpots VR1 and VR2. They
may be marked with code 103. Orient these with the adjusting screw as
shown in Fig.2, toward IC1.
Install terminal blocks CON1, CON2
siliconchip.com.au
Parts List
1 double-sided PCB, coded 05105181, 104 x 58.5mm
1 DPDT 12V DC coil relay (RLY1)
[Jaycar SY4052 (5A) or Altronics S4270A (8A)]
1 10kW NTC thermistor with beta ~4100; see text (TH1) [Jaycar RN3440]
2 2-way screw terminals with 5.08mm pin spacing (CON1,CON2)
2 3-way screw terminals with 5.08mm pin spacing (CON3)
1 DIL 8-pin IC socket for IC1
7 PC stakes (optional) (TPgnd,TP1,TP2,TP3,TP4 & TPref)
1 UB3 jiffy box, spacers and mounting screws (optional)
Semiconductors
1 PIC12F617-I/P programmed with 0510518A.HEX (IC1)
1 LP2950ACZ-5.0 regulator (REG1)
1 BC337 NPN transistor (Q1)
1 16V 1W (1N4745) zener diode (ZD1)
2 1N4004 1A diodes (D1,D3)
2 3mm LEDs (LED1,LED2)
Capacitors
1 100µF 25V PC electrolytic
3 10µF 16V PC electrolytic
8 100nF 63/100V MKT polyester
Resistors (all 1%, 0.25W)
2 24kW
6 10kW
1 3.9kW
1 3.3kW
1 1kW
1 200W
1 47W
2 10kW multi-turn vertical trimpots (3296W style) (VR1,VR2)
Table.1: Resistor Colour Codes
o
o
o
o
o
o
o
No.
2
6
1
1
1
1
1
Value
24kΩ
10kΩ
3.9kΩ
3.3kΩ
1kΩ
200Ω
47Ω
4-Band Code (1%)
red yellow orange brown
brown black orange brown
orange white red brown
orange orange red brown
brown black red brown
red black brown brown
yellow violet black brown
and CON3 now. CON1 and CON2 are
2-way types which are mounted separately while CON3 comprises two
3-way screw connectors dovetailed
together. Fit all three connectors with
the wire entry to the outside edge of
the PCB.
Finally, the LEDs and RLY1 can be
mounted. We placed the LEDs close
to the PCB but they can be mounted
higher or even off the PCB, for example, chassis-mounted to the case.
If mounting them off-board, wire
them to the LED pads with flying leads.
The LEDs must be oriented correctly
with the anode (longer lead) of the LED
Celebrating 30 Years
5-Band Code (1%)
red yellow black red brown
brown black black red brown
orange white black brown brown
orange orange black brown brown
brown black black brown brown
red black black black brown
yellow violet black gold brown
to the pad marked “A” on the PCB.
Although presented as a bare PCB,
the Temperature Switch can be installed within a UB3 box. Mark out and
drill the 3mm holes in the box, corresponding to the corner mounting holes
on the PCB, then attach it to the box
using short spacers and screws. Holes
will be required at each end of the box
(or on the lid) for cable glands, which
the power supply, thermistor and relay wiring will pass through.
Testing
You will need a 12-15V DC supply at
up to 60mA. Connect the power supply
June 2018 47
The PCB
fits neatly into
a UB3 Jiffy box with
M3 x 15mm spacers to support
it. The connectors and thermistor can
then have holes drilled for them through the
top of the lid or out the side of the box. Note that the
PCB is slightly less wide than the typical UB3 box to account
for variations and contraction of the material under strain.
to CON1 and the thermistor to CON2.
Leave IC1 out of its socket before
switching the power supply on. LED1
should light. Now measure the voltage between TP+5V and TPgnd. The
reading should be between 4.975V
and 5.025V. Next, check the voltage
between TPref and TPgnd. It should
be between 96.5mV and 99.5mV, ideally close to 98mV.
If these voltages are correct, then
switch the supply off and insert IC1,
taking care to orient it correctly.
Switch the power back on and
measure the voltage between TP4 and
TPref. Check that this corresponds to
room temperature, keeping in mind
the 10mV/°C scaling factor.
To test the switching operation,
connect your DMM between TP2 and
TPref, then adjust VR2 for a reading
that is a few tens of millivolts above
the reading at TP4. For example, if you
read 220mV at TP4 (corresponding to
22°C), adjust VR2 for 260mV at TP2
(corresponding to 26°C).
Now connect your DMM between
TP1 and TPref and adjust VR1 for an
intermediate reading, eg, 240mV corresponding to 24°C.
At this point, RLY1 should not be energised. Heat up the thermistor and the
relay should be energised; you should
hear it click and LED2 will light up.
48
Silicon Chip
Then cool the thermistor down and it
should click again as it’s de-energised.
Depending on the ambient temperature, you may be able to heat up the
thermistor by simply holding it between two fingers. Or you could use a
cigarette lighter, with the flame briefly
held below the thermistor body
Setting the thresholds
Now determine the temperatures at
which you want the relay to be energised and de-energised.
If you want the relay energised when
the temperature rises above a particular threshold then this temperature becomes your upper threshold. Subtract
your desired hysteresis value (in °C)
from the upper threshold to determine
the lower threshold.
In this case, use the same procedure
as described under Testing above so
that the voltage reading between TP1
and TPref equals the lower threshold and the reading between TP2
and TPref equals the desired upper
threshold.
Conversely, if you want the relay
to be energised when the temperature falls below a particular threshold then this will be your lower
threshold and you should add the
desired amount of hysteresis to it,
to determine the upper threshold value.
In this case, adjust VR1 to give
a reading between TP1 and TPref
equal to your upper threshold and
adjust VR2 to give a reading between
TP2 and TPref that corresponds to
your lower threshold.
Do not set both thresholds to the
same temperature as this will cause
relay chatter.
Installation
Wire your power supply leads to
CON1. For use in a motor vehicle, use
automotive-rated wire with the +12V
terminal connected to the switched
side of the ignition. That way, your
battery won’t be drained when the ignition switch is off.
The 0V terminal on CON1 should
be connected to the vehicle chassis
(assuming you have a negative chassis, like all modern vehicles) using a
crimp eyelet secured to a convenient
screw terminal. You may need to drill
a separate hole for this connection if
you can’t utilise an existing earth connection.
Note that while the test points can
show readings with a resolution greater than 1°C (252mV for 25.2°C) the
Temperature Switch will only switch
RLY1 on and off at the temperature
settings and readings rounded up to
the nearest degree.
Previous temperature control projects published in Silicon Chip
• Infrared-Sensing Heater Controller for convection and bar radiators up to 10A,
50/60Hz and 230VAC, with temperature control from 15°C to 31°C.You can even add
a thermopile for added precision (April 2018; siliconchip.com.au/Article/11027)
[PCB 10104181 – $10].
• Need to convert a freezer into a fridge, or even a fridge into a wine cooler? Try
the TempMaster Thermostat Mk3 (August 2014; siliconchip.com.au/Article/7959)
[PCB: 21108141 – $15 | Jaycar KC5529].
• High-temperature applications like ovens or kilns (below 1200°C) or even freezing cold (above -50°C)? Try the High-temperature Thermometer/Thermostat (May
2012; siliconchip.com.au/Article/674) [PCB 21105121 – $20].
SC
Celebrating 30 Years
siliconchip.com.au
|