This is only a preview of the October 2008 issue of Silicon Chip. You can view 30 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 "USB Clock With LCD Readout, Pt.1":
Items relevant to "Digital RF Level & Power Meter":
Items relevant to "Versatile Special Function Timer":
Items relevant to "Railpower Model Train Controller, Pt.2":
Purchase a printed copy of this issue for $10.00. |
A multi-purpose timer with external triggering
and several modes of operation
Design by JOHN CLARKE
Special Function Timer
This automatic timer has a wide range of applications whereby
a timing cycle is initiated in response to a trigger signal. There
are quite a few uses for it in a car or you could use it on a model
railway layout, in a home security system or whatever.
T
HIS PROJECT WAS originally presented as a “Versatile Auto Timer”
in our book, “Performance Electronics
for Cars” but since it has considerably
wider applications than in cars, we
have decided to give it a wider audience by publishing it in SILICON CHIP
with an updated microcontroller, the
PIC16F628A.
Since it is based on a microcontroller, it can be easily configured to
give a wide range of times and triggering options. As well, it can run as a
“one-shot”, giving a fixed ON time for
a device after being triggered or it can
cycle the device on and off repeatedly
62 Silicon Chip
after being triggered.
There are a number of triggering
operations. For example, you could
just use a pushbutton to start the
timer or it might be triggered by the
application or removal of more than
6V to the input.
As you might imagine, there are any
number of applications for this timer
in a car. For example, it could run a fan
for 10 minutes at the push of a button
or it could run the ventilation fan for
a couple of minutes every 10 minutes
when the car is locked in a sunny car
park. When you come back to the car,
it would not be stifling inside and there
would not have been too much drain
on your battery.
Or what if you have a model railway
layout with points switching? Say you
have just changed over the points and
you want lights to flash and bells to
sound at a road crossing for three minutes after? That’s a job for this timer.
There are many others.
Basically, the Special Function Timer is just a small PC board with a 12V
relay on it. You can run it anywhere
that 12V DC is available. Want to run
it off 24V DC? Simple; just substitute a
24V relay. Want to run it at 6V? Again,
it is simple; just substitute a 6V relay.
siliconchip.com.au
D1 *
+11.4V
REG1
1N4004
LM2940-5
A
+12V
K
IN
ZENER,
1N4004
+5V
OUT
GND
100 µF*
16V
10 µF
100nF
16V
10k
A
K
10k
LED
BC327, BC337
GND
B
*
USE 1N5819
FOR 6V SUPPLY
*
1k FOR 6V SUPPLY
4.7k FOR 24V SUPPLY
*
10k
SIGNAL
INPUT
A
RB6
RB4
10k
K
MCLR
10k
Q1
BC337
ZD1
16V
1W
B
150Ω
6
RB5
RB0
RB7
1nF
IC1
PIC16F628A
100k
SC
2004
RB1
RA4
RA3
X1
4MHz
15
OSC1
RA2
OSC2
RA1
OUT
GND
RB2
RB3
16
22pF
22pF
SPECIAL FUNCTION TIMER
A
10
2
11
Vss
5
RA0
7
3
9
+11.4V
COM
4
13
8
BCD SWITCH
0–9 (1's)
1
A
8
TP1
LM2940CT-5
IN
S1
12
C
E
C
4
14
Vdd
USE 100 µF 35V
FOR 24V SUPPLY
K
E
+5V
S2
λ LED1 D2
1N4004
K
BCD SWITCH
0–9 (10's)
1
K
2.2k*
2
COM
4
A
8
Q2
BC337
10k
2
B
NO
COM
NC
E
+5V
1
NO
COM
NC
C
RELAY1
18
17
100 µF*
16V
LK2 10k
LK1
LK3
1-SH
H/L
x10
ALT
L/H
x0.1
TRIGGER
MULTIPLIER
(OPEN = x1)
MODE
Fig.1: the circuit is based on a PIC16F628A microcontroller that’s programmed to provide a timed output after being
triggered. The output at pin 2 drives a double-pole relay via transistor Q2.
OK, there are a couple of other component variations which might need
to be made and we will detail those
later in this article.
Circuit description
The full circuit is shown in Fig.1.
As already noted, it is based on IC1,
a PIC16F628A microcontroller programmed to provide a timed output
after being triggered. The output drives
a relay which is closed during the timing period. A LED also lights whenever
the relay is activated. The relay has
changeover (DPDT) contacts so that it
activates or de-activates a circuit for
the set time.
The time duration is set using
two 10-position BCD (binary coded
decimal) rotary switches that provide
a timing range of 1-99 seconds in steps
of one second. A separate jumper connection (link LK3) selects either x 0.1,
x1 or x10 multipliers of the set time
siliconchip.com.au
duration. In the standard x1 position
(LK3 open), the time duration is in
seconds, as already noted. When LK3
is in the 0.1 multiplier position, the
timer provides 0.1s to 9.9s timing periods, selectable in 0.1s steps. Similarly,
when LK3 is in the x10 multiplier position, it allows timing from 10s through
to 990s, in steps of 10s.
Three modes are available:
(1). The standard one-shot mode provides a timing period where the relay
is activated for the set period after
triggering.
(2). The alternating mode switches the
relay on and off at the rate set by the
time selection rotary switches.
(3). The variable on/off alternating
mode allows you to independently
set the length of the on and off periods
when the timer is alternating.
The triggering options are a rising
edge or falling edge trigger for the
one-shot mode, or a low-to-high (L/H)
or high-to-low (H/L) signal for the
alternating mode. These options are
set using links LK1 and LK2.
The trigger signal is applied via a
10kW resistor and 16V zener diode
ZD1 to limit transient voltages. This
Main Features
• Triggered on rising or falling
voltage (user selectable)
• One-shot or alternating (pulse)
operation
• Pulse mode can be set for variable on/off periods
• Precise 0.1s to 16.5-minute
timing period
• Relay output with dual doublethrow contacts rated at 5A
• LED indicator for timing
October 2008 63
10k
x10
MULTIPLIER
(OPEN = x1)
+
100 µF*
O NNO
C
10k
NC
CN
1 C 4
LED1
A
2.2k*
COM
s'PERIOD
01
SWITCHES
1nF
A D2 K
Q2
S2
10'S
18001150
NC
CN
901
S1
1'S
23
10k
LK3
COM
8 C 2
150Ω
x0.1
D1: 1N4004
1 C 4
NO
C ON
X1
4MHz
L/H
H/L
1-SHOT ALT
ZD1
10k
10k
A
1
23
901
INPUT
100nF
22pF
IC1
PIC16F628A
BC337
K
TP1
456
+12V
DNG
GND
Q1
D1*
NI 2 1 +
GND
K
s'1 8 C 2
456
LM2940-5
100k
10k
REG1
LK2 LK1
78
➡
+ A
78
➡
+
RE MIT OTUA
TP
GND
22pF
10k
10 µF 100 µF*
RELAY 1
K
BC337
* SEE TEXT & CIRCUIT FOR 6V & 24V OPERATION
Fig.2: follow this parts layout diagram to build the Special Function
Timer. Jumpers LK1-LK3 are installed to suit your application (see Fig.1 &
Figs.3-6). Link LK1 sets the mode (1-shot or alternating); LK2 sets the input
signal trigger sense (low to high or high to low); and LK3 sets the timing
multiplier. BCD switches S1 & S2 set the timing period.
Resistor Colour Codes
Value
4-Band Code (1%)
5-Band Code (1%)
100kΩ
10kΩ
2.2kΩ
150Ω
brown black yellow brown
brown black orange brown
red red red brown
brown green brown brown
brown black black orange brown
brown black black red brown
red red black brown brown
brown green black black brown
effectively clamps the signal at a
maximum of +16V and -0.6V above
and below ground. This signal then
drives transistor Q1 via another 10kW
resistor.
Q1’s collector inverts the input signal and drives pin 6 of IC1 via a 10kW
pull-up resistor and a 150W series
resistor. A 1nF capacitor filters any
high-frequency voltage fluctuations,
while the pin 6 input of IC1 includes
an internal Schmitt trigger to ensure a
clean signal for measurement.
Rotary BCD switches S1 & S2 are
monitored by IC1’s RB1-RB7 and RA4
inputs. The RB inputs are normally
held high via internal pull-up resistors
within IC1, while RA4 has a 10kW pullup resistor to ensure it is high unless
pulled low via S2. In operation, the
switches provide a unique BCD (binary
coded decimal) code on these inputs
for each setting and these codes are
processed by the program within IC1
to determine the timing period.
The RA0 and RA1 inputs of IC1 are
held either high or low via links LK1
and LK2 to select the Mode and Trigger options. The RA2 input operates
slightly differently. It can be held either high or low using the x10 or x 0.1
jumper (LK3) and this level is checked
by IC1. Initially, this pin is set as an
output and is driven low. The pin is
then set as an input and the level is
checked. If the input is high, then IC1
“knows” that the x10 jumper must be
in place.
The pin is then set as an output
and is set high. When set as an input
again, the level is checked and if it
is low, then the x0.1 jumper must be
in place. If the level does not change
in both cases, then the input must
be open-circuit and the microcontroller assumes the setting is for the
x1 range.
The RA3 output drives transistor Q2
which in turn switches on the relay.
Q2 also turns on LED1 to indicate
when the relay is activated. Diode D2
prevents damage to Q2 from any backEMF spikes produced when the relay
coil is switched off.
IC1 is operated at 4MHz using crystal
X1. The two 22pF capacitors provide
the correct loading for the crystal, so
that the clock starts reliably.
Power supply
Power for the circuit is derived via
the vehicle’s fuse box if used in a car
or truck and is fed via diode D1 which
provides reverse polarity protection.
Alternatively, the circuit may be powered from a battery or other source of
DC power at 6V, 12V or 24V, depending
on the relay fitted (see parts list).
If the circuit is run from 6V, then
D1 should be changed to a 1N5819
Schottky diode to minimise voltage
Looking for real performance?
•
•
•
•
Learn how engine management systems work
Build projects to control nitrous, fuel injection and turbo boost systems
Switch devices on and off on the basis of signal frequency, temperature and voltage
From the publ
ishe rs of
160 PAGES
23 CHAPTE
RS
Build test instruments to check fuel injector duty cycle, fuel mixtures and brake & temperature
Mail order prices: Aust. $A22.50 (incl. GST & P&P); Overseas $A26.00 via airmail. Order by
phoning (02) 9939 3295 & quoting your credit card number; or fax the details to (02) 9939
2648; or mail your order with cheque or credit card details to Silicon Chip Publications,
PO Box 139, Collaroy, NSW 2097.
64 Silicon Chip
Intelligent
turbo timer
I SBN 09585
2294
9 78095
8
-4
TURBO BO
OST
&
nitrous fuel con
5229
46
$19.80 (inc GST) NZ
$22.00 (inc GST)
trollers
How engin
e
management
works
siliconchip.com.au
Helping to put you in Control
Control Devices
New PLC With Analogs
This PLC is great
value. Features 9
Digital in, 10 Relay
out, 8 Analog In and
2 Analog Out. Can
accept quadrature encoder input and
high speed counters
$425+GST.
This view shows the fully assembled unit, which was built from a Jaycar
Auto Timer kit. Note that if your kit comes with a PIC16F628A for IC1,
then IC2 is left out of circuit. Conversely, if you get the original kit with a
PIC16F84 microcontroller, then IC2 must be installed.
drop and reduce the possibility of
regulator dropout. Conversely, if the
circuit is run at 24V, the two 100mF
capacitors should be rated at 35V
instead of 16V.
In addition, the current-limiting
resistor in series with LED1 will need
to be varied according to the supply
voltage: 1kW at 6V, 2.2kW at 12V and
4.7kW at 24V.
The +5V rail for IC1 is derived from
an LM2940CT-5 regulator which is
designed specifically for automotive
applications and includes transient
voltage protection. The 100mF capacitor at REG1’s input provides further
transient voltage suppression.
other suppliers will have the PC board
encoded as 05110081.
When assembling the PC board,
make sure that you insert the polarised
components the right way around.
These parts include the two rotary
switches, diodes, ICs, LED1, the transistors, the voltage regulator and the
electrolytic capacitors. You should
also carefully compare the photos
with the parts layout diagram (Fig.2)
to avoid making any mistakes.
If you are assembling a PIC16F84
version of the circuit, make sure that
you do not swap the MC34064 for one
of the transistors – that could lead to
smoking components!
Construction
Testing
All of the timer components are
mounted on a PC board which measures 106 x 61mm. A complete kit of
parts for the 12V version of the kit is
available from Jaycar Electronics (Cat.
KC5379). In this case the PC board will
have the code number 05car81.
However, since this is the previous version of the circuit which was
based on a PIC16F84, it also needs an
MC34064 5V supply supervisory chip.
This device performs a power-on reset
for IC1 to ensure that pin 4 of IC1 is
only switched high when the supply is
above about 3.5V. For voltages below
this, IC1 is held in the reset state.
We expect that, once existing stocks
are exhausted, Jaycar will upgrade
their kit to use the PIC16F628A, in
which case the MC34064 is simply
omitted from the PC board. Kits from
The timer should now be benchtested for correct operation and to
configure it for your application. This
will also allow you to become familiar
with the way it works.
First, connect +12V and 0V to the
timer. Also connect a floating lead to
the input, so that you can trigger the
unit.
Now place the Mode and Trigger
links (LK1 & LK2 respectively) in their
upper positions (as viewed with the
PC board orientated as in Fig.2) and
remove the multiplier link. Turn the
upper BCD switch to “2” and set the
lower switch to “0”.
The timer is now configured for
Alternating Mode, L/H (Low-to-High)
Trigger and two seconds.
When you connect the floating lead
to +12V, the LED should light and the
siliconchip.com.au
New Logomatic
Serial Data Logger Has a USB
connection so it
appears as a flash
drive. Logged serial data is saved on micro-SD media
as text files. Download to a PC over
USB connection or remove microSD
card and insert into a card reader.
$89.95+GST
Humidity Temperature Controller The
N322RHT has 2
relay outputs
which can be configured independently as control or alarm, either for
temperature or relative humidity. A
Relative Humidity and Temperature
included. $195+GST
USB-RS422/485
Converter
Our popular isolated converter can
be configured for
four-wire RS422
and two-wire RS485 networks.
Transmission rates to 1Mbps
From $129+GST
Signal Isolators and Converters
TxIsoBlock and
TxIsoRail are programmable isolated transmitters.
Convert Pt100 and
thermocouples to
4-20mA or 0-10V.
TxIsoBlock is a
head mount unit
and TxIsoRail is a DIN rail mount
unit. Non-isolated models also available From $89+GST
Contact Ocean Controls
Ph: 03 9782 5882
www.oceancontrols.com.au
October 2008 65
+12V
S1
1'S
1 8 0ra c 5 0
CN
COM
ON
STD
BOOT
SWITCH
C
1
23
901
NI 2 1 +
NO
C ON
10k
DNG
GND
23
901
1-SHOT
INPUT
S2
10'S
CN
s' 0 1
x10
CHASSIS
(0V)
+
Fig.3: want to automatically switch a 12V lamp or some other load off after
a preset time? This one-shot set-up will do the job. Note the position of link
LK1.
+12V
PUSHBUTTON
SWITCH
CHASSIS
(0V)
DNG
+12V
INPUT
S1
1'S
ON
C
23
901
NI 2 1 +
1
23
901
1-SHOT
GND
NO
COM
S2
10'S
1 8 0ra c 5 0
s'1
CN
HIGH
C ON
+ GOING
10k
RE MIT OTUA
+
78
➡
66 Silicon Chip
s'1
78
➡
Note: change the 2.2kW resistor
in series with LED1 to 4.7kW for
24V operation or to 1kW for 6V
operation. Also, change D1 to
1N5819 for 6V operation.
HIGH
78
➡
24V & 6V Operation
RE MIT OTUA
+ GOING
+
456
Resistors (0.25W, 1%)
1 100kW
1 2.2kW
7 10kW
1 150W
STD
BOOT
LAMP
456
Capacitors
2 100mF 16V PC electrolytic OR
2 100mF 35V PC electrolytic, for
24V operation
1 10mF 16V PC electrolytic
1 100nF MKT polyester (code
104 or 100n)
1 1nF MKT polyester (code 102
or 1n)
2 22pF ceramic (code 22 or 22p)
CHASSIS
(0V)
456
Semiconductors
1 PIC16F628A microcontroller
programmed with 0511008A.
hex (IC1)
1 LM2940T-5 low dropout regulator (REG1)
2 BC337 NPN transistors
(Q1,Q2)
1 5mm red LED (LED1)
1 16V 1W zener diode (ZD1)
2 1N4004 1A diodes (D1,D2).
Note: D1 should be 1N5819
for 6V operation
+12V
456
1 PC board coded 05car081 or
05110081, 105 x 60mm
1 4MHz crystal (X1)
1 18-pin DIL socket for IC1
5 PC-mount 2-way screw
terminals with 5mm pin
spacing
2 BCD PC-mount rotary switches (S1,S2)
1 12V PC-mount DPDT 5A relay
(Relay1) OR
1 6V PC-mount DPDT 5A relay
(Relay1: Altronics Cat S4188C) for 6V operation OR
1 24V PC-mount DPDT 5A relay
(Relay1: Altronics Cat S4195C) for 24V operation
1 70mm length of 0.8mm tinned
copper wire
3 3-way headers, 2.54mm spacing
3 jumper shunts, 2.54mm spacing
2 PC stakes (for test points)
+12V
78
➡
Parts List
LOAD
CN
s' 0 1
x1
+
CHASSIS
(0V)
Fig.4: this is the set-up to use if you want to turn a load (eg, a lamp) on at the
press of a button and then have it turn off at the end of a preset timing period.
Link LK1 is again in the 1-shot position.
relay should click in. Two seconds
later, the LED should go out and the
relay should turn off. This process
should then keep repeating for as long
as you have the signal wire connected
to +12V.
Setting the timing
The rotary switches set the time
duration. Set the upper switch to
“7” and the cycling will slow to 7
seconds on, 7 seconds off. Now set
the lower rotary switch to “1” while
leaving the upper switch at “7”. The
time period will now be 17 seconds
on, 17 seconds off.
If you leave the rotary switches set
to 17 (top one on 7 and bottom one on
1) and place the multiplier link in its
uppermost position, the time shown
on the rotary switches will be divided
by 10, giving a 1.7 second on and off
time. Move the multiplier link to its
bottom position and the rotary switch
time will be multiplied by 10, ie, giving
170 second (2 minutes and 50 seconds)
on and off times.
In summary, the upper rotary switch
shows units and the lower switch
shows tens. The multiplier can be set
in three positions:
(1) Link LK3 removed, so the time dissiliconchip.com.au
+12V
HEAVY
DUTY
RELAY
CHASSIS
(0V)
RE MIT OTUA
s'1
DNG
+12V
CN
901
COM
S1
1'S
CHASSIS
(0V)
ON
C
1
901
23
INPUT
456
NI 2 1 +
23
78
➡
GND
1-SHOT
456
GOING
LOW
NO
1 8 0ra c 5 0
10k
+
C ON
+
IGNITION
SWITCH
S2
10'S
CN
LOAD
78
➡
s' 0 1
x10
+
CHASSIS
(0V)
Fig.5: this 1-shot set-up will continue to supply power to a load (eg, a car radio or the headlights)
after the car’s ignition has been turned off. The heavy-duty relay is included to ensure reliable
operation with high-current loads. Note the location of link LK2 compared to the other set-ups (ie,
it’s fitted in the H/L position).
+12V
SWITCH
CHASSIS
(0V)
901
456
23
78
➡
DNG
GND
+12V
S1
1'S
ON
23
901
INPUT
COM
C
456
NI 2 1 +
1
NO
S2
10'S
1 8 0ra c 5 0
s'1
C ON
PULSE
HIGH
CN
+GOING
10k
RE MIT OTUA
+
LOAD
CN
78
➡
s' 0 1
x10
+
CHASSIS
(0V)
Fig.6: in this set-up, LK1 is in the “ALT” (or pulse) position and so the load
(eg, a lamp or a siren) pulses on and off according to the period set by the
BCD switches (and link LK3). The switch simply turn the circuit on or off.
played on the rotary switches equals
seconds;
(2) Link LK3 at top position, so the
time displayed on the rotary switches
equals seconds divided by 10; and
(3) Link LK3 at bottom position, so the
time displayed on the rotary switches
equals seconds multiplied by 10.
Now try the one-shot mode by moving LK1 to its bottom (1-shot) position.
Then remove the multiplier link and
set the rotary switches to give a 5-second timing period (ie, bottom switch
on “0” and top switch on “5”).
Now when you connect the signal
input lead to 12V, the relay will click
siliconchip.com.au
in for five seconds and then switch
off. If you disconnect and then reconnect the signal input within the timed
period, the timer will start counting
again – so the timing period is from
the last sensing connection.
In practice, you can set the positions
of the rotary switches and multiplier
link to give any time period you want
from 0.1 seconds to 990 seconds (16.5
minutes).
Variable alternating mode
Once you’re familiar with the oneshot and alternating modes, you can
try out the variable on/off alternating
mode. This gives you the option of
different “on” and “off” times.
This mode is activated as follows:
(1). Set the timer to alternating mode
(link LK1 in upper position).
(2). Set the top rotary switch (S1) to
the number 7.
(3). Temporarily connect TP1 to TP
GND (these are the two test pins near
the top rotary switch). Note: this needs
to done for a least 2s before the change
occurs.
In this mode, the bottom rotary
switch sets the length of time the relay
is closed and the top rotary switch sets
the length of time the relay is open. For
example, if you set the top switch to
“3” and the bottom switch to “1”, with
the multiplier link (LK3) removed, the
relay and its accompanying LED will
cycle on for 1 second, off for 3 seconds,
on for 1 second, etc.
If you want to change back to
standard alternating mode, set S1 to
the number 7 and again temporarily
connect TP1 to TP GND for at least 2s.
High to low triggering
Up until now, you have been triggering the timer by connecting the floating
lead to +12V. Now let’s configure it to
trigger when the floating input lead is
disconnected from +12V.
To do this, move the Trigger Mode
link (LK2) to its lower position (H/L)
and then check that the timer starts
when the floating input lead is disconSC
nected from +12V.
October 2008 67
|