This is only a preview of the August 2018 issue of Silicon Chip. You can view 41 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. Items relevant to "Brainwave Monitor – see what’s happening in your brain":
Items relevant to "Miniature, high performance sound effects module":
Items relevant to "Turn any PC into a media centre – with remote control!":
Items relevant to "Bedroom (or any room!) no-connection door alarm":
Purchase a printed copy of this issue for $10.00. |
M-u-u-u-m . . . he’s been in my room again!
Do you have children or grandchildren who are very territorial?
Do they want extra security against
invasion of their rooms by pesky
siblings? Why not build a Personal
Security alarm so they can be alerted
when their room is about to be
invaded? It will sound an alarm as
soon as the door knob is touched and
possibly avert any noisy squabbles.
The kids will love it! Of course, you
may then have to make an alarm
for each kid who wants one.
Build the
watchdog alarm
(for peace in your home!)
By
JOHN CLARKE
A
kid’s domain is sacrosanct – especially
if they are fortunate enough to have their
own room. But no amount of threats or
retribution will keep a sibling (or parent!) out
when they’re uninvited! Kids are sneaky that
way. . .
This Watchdog Alarm is effective and
certainly preferable to more drastic measures
such as trip wires, buckets precariously balanced above doorways, trapdoors, Gatling guns
and other schemes which war-like adolescent
humans are likely to dream up to protect their
room, cave, cubby house or lair.
Having an audible warning means the hostile
room occupant will immediately be alerted to
an undesirable alien (eg, little brother!) touching
the doorknob, even before they open the door.
That warning may or may not be sufficient
to prevent the mischief maker from creating
mayhem by opening the door, knowing they
76
Silicon Chip
have been detected, but it will certainly be a
deterrent against further incursions.
(OK, we’re not seriously suggesting
this alarm as a proper security device
. . . but it could have other applications where a
change in the capacitance of a metal object needs
to be detected.)
The idea for this project came from an article
in the April 1981 edition of Electronics Australia
for a portable burglar alarm.
Powered from a 9V battery, it used a hex
Schmitt trigger connected as a couple of oscillators and a timing circuit to drive a siren whenever
the doorknob was touched.
That article suggested it as being suitable for
use in hotel rooms but that is not practical today for modern hotel and motel rooms, which
are usually entered by swiping a card through a
magnetic scanner, or even via an RFID tag.
Nevertheless, with child territoriality in mind,
Australia’s electronics magazine
siliconchip.com.au
we have updated this concept using a
low power microcontroller. The resulting Watchdog Alarm uses an 8-pin
micro on a small PCB which can be
easily assembled and set up within
an hour. It is powered from a small,
onboard 3V cell and is presented as
a bare printed circuit board (PCB) assembly to minimise cost.
A sensor loop is placed over the
doorknob (no electrical connection required) to detect when this is touched.
The Watchdog Alarm is turned on
and off with a toggle switch and an
indicator LED flashes to show that the
Fig.1: the Watchdog’s microcontroller feeds a 2MHz signal via trimmer
capacitor VC1 to the doorknob sensor loop. If someone touches the doorknob,
doorknob is being monitored.
their body capacitance shunts this signal to ground. The micro senses this and
When the Watchdog Alarm is first
sounds the piezo alarm or siren.
switched on, the indicator LED flashes
rapidly for about 10 seconds during which time the doorknob can be an off-board piezo siren. This is more 2MHz signal which is applied to the
touched without sounding the alarm. likely to wake more comatose room doorknob which is monitored at the
Touching the doorknob during this occupants (no guarantees, though!).
same time.
period will cause the LED to light fully.
If a pesky human touches the
You can use the 10-second period
doorknob, the person’s body cato check the operation of the
pacitance will effectively shunt
Watchdog Alarm. We’ll explain
away the 2MHz signal and this
• Detects the presence of a hand on a doorknob
this later in the setup section.
will cause the micro to sound
Once the 10-second period has • Option of piezo transducer or louder siren for alarm the alarm. The circuit requires
expired, the LED will flash about
a “counterpoise”, made from
• Testing period during initial power on without
once per second to indicate that
three lengths of wire and this
sounding alarm
the Watchdog Alarm is armed.
serves to provide a virtual ground
Touching the doorknob then will • LED indicator shows initial test period, normal
reference.
cause the alarm to sound.
The circuit, shown in Fig.2,
monitoring and alarm
There are two alarm options.
is based on a PIC12F617 8-pin
One is a on-board piezo transducer Block & circuit diagrams
microcontroller (IC1).
that beeps twice every three seconds
Switch S1 connects the 3V button
Fig.1 shows the block diagram.
(about 1.5Hz) if the alarm is triggered. As already noted, this alarm uses a cell and diode D1 provides reverse poFor a much louder alarm you can use microcontroller and it produces a larity protection. If the cell is somehow
Features
Fig.2: the micro provides two alarm options. The first is a piezo transducer driven with anti-phase tone burst signals
which effectively doubles the single pin output voltage. The second is a lounder off-board piezo siren which has its own
internal oscillator. LED1 shows the alarm status.
siliconchip.com.au
Australia’s electronics magazine
August 2018 77
The two “sirens” applicable, shown here not far off life
size. On the left is the louder of the two which must be
mounted off the PCB. At right, the piezo transducer, can be
mounted directly on the PCB.
inserted incorrectly, the diode will conduct and safely limit
the reverse voltage to IC1 at around -0.6V. Admittedly, the
cell holder we use makes it rather difficult (if not impossible!) to allow the cell to be inserted incorrectly, so that
is an added prevention.
IC1 uses an internal 8MHz oscillator and this is divided
by four to provide a clock signal of 2MHz at pin 3, CLKOUT.
Most of the time IC1 is in sleep mode and its internal
8MHz oscillator is stopped. It is woken once a second by
its internal watchdog timer (yep, that’s where we got the
name from!) to flash the red indicator LED and check if the
doorknob is being touched. Sleep mode reduces the current
consumption of IC1 down to a very low level in order to
maximise the life of the cell.
In more detail, the internal watchdog timer runs continuously and once a second it wakes up IC1. The 8MHz
oscillator then starts, the program in IC1 runs and the CLKOUT output at pin 3 then produces the 2MHz signal. This
signal is applied via an adjustable trimmer capacitor, VC1,
to the T0CKI (pin 5) via 470Ω resistors. The wire loop for
the doorknob sensing is attached to the trimmer capacitor
at the opposite side to CLKOUT.
Fig.3: the complementary (anti-phase) drive signals
applied to the piezo transducer, from pins 6 & 7. The two
signals are at 4.05kHz and have an amplitude very close
to 2.06V and 2.44V peak-to-peak, not allowing for the
overshoot spikes. Therefore the total signal applied to the
transducer will be close to the sum of those voltages 4.5V
peak-to-peak, as shown in the purple mathematical trace.
78
Silicon Chip
If the doorknob is not touched, the input to IC1 at T0CKI
will receive the 2MHz signal passing through the trimmer
capacitor.
The block diagram of Fig.1 depicts what happens inside
IC1. The 2MHz signal is applied to a divide-by-four prescaler
and then to an 8-bit counter (TIMER0). At 2MHz, the output
from the prescaler is 500kHz (2MHz/4). TIMER0 counts at
the 500kHz rate and the overflow output (T0IF) goes high
after 256 counts – the full count of the 8-bit counter.
TIMER 0 reaches the full count in 512µs. If its output
does not go high after this period, then the software assumes there is no signal. Lack of signal would mean that
the 2MHz signal is being diverted to ground by flow through
the doorknob by body capacitance.
Several extra parts are used between the VC1 output
and the T0CKI input. This includes the 470Ω resistors and
diodes D2 & D3 which are included to protect the pin 5
input. Should the person have a static charge before touching the doorknob, diodes D2 or D3 will clamp the voltage to
the positive or 0V supply depending on the static voltage
polarity. The 470Ω resistor to D2 and D3 limits current. The
next 470Ω resistor to pin 5 protects the internal protection
diodes of IC1.
The 1MΩ resistor is there to pull pin 5 to 0V so the input
does not float at a voltage between 0V and the supply. Additionally, during sleep, the pin 5 input is changed from an
input to a low output, further ensuring the input is not floating. A floating input will cause IC1 to draw extra current.
Piezo drive
The GP3 input, pin 4, connects to the 3-pin header
JP1. The position of a 2-pin jumper on this header selects
whether you use the lower-cost on-board piezo transducer
or the louder off-board piezo siren. The selector is necessary
because each is driven differently. The piezo transducer is
driven by a burst signal generated by the micro, while the
piezo siren has its own internal constant tone generator and
is turned on when pin 7 goes high, feeding it with 3V DC.
When set in the piezo position, GP3 is tied low and if
Fig.4 shows the same complementary drive signals fed to
the transducer as in Fig. 3 but at a slower sweep speed
of 5ms/div. This shows how the signal bursts are rapidly
chopped to give it a burbling sound, which is more
attention-getting. Note that we are running the piezo
transducer at close to its resonant frequency to maximise
its audible effect.
Australia’s electronics magazine
siliconchip.com.au
Specifications
Supply voltage: 3V lithium cell which operates down to 2V
Current drain: 5.4µA at 2V; 7.5µA at 3V,with LED flashing
once per second
(Piezo siren; when sounding add an extra 250µA)
Expected cell life: ~1 year continuous use
Indicator flash: 3.2ms once each 1.152s, constantly lit during
detection
Testing period indication: LED flashes 3.5 times per second
during first 10 seconds after power up. Fully lit during
detection
Alarm response time: 0.5s (285ms during 10 second testing
period)
Piezo Transducer: 200ms bursts of 4.05kHz warbled at
between 400Hz and 600Hz at a 1.55Hz rate
Piezo siren alarm: Uses intermittent siren or siren burst
Fig.6: the PCB component overlay,
with matching photo at left.
It is shown here without the
piezo siren mounted to reveal the
PIC and other components underneath.
the doorknob is touched to trigger the alarm, the piezo
transducer sounds, as pins 6 & 7 (GP1 & GP0) alternately
go high and low, to deliver bursts of 4kHz signal. In a small
room and at close quarters, this can be quite loud.
Certainly, there is no mistaking that the miscreant has
been “pinged”. The alarm will sound while ever the doorknob is touched. As soon as the doorknob is released, the
alarm will stop.
The scope screen grabs of Fig. 3 & 4 show the complementary drive signals applied to the piezo transducer, from
pins 6 & 7. In Fig.4, the two signals are at 4.05kHz and have
an amplitude very close to 2.06V and 2.44V peak-to-peak,
not allowing for the overshoot spikes. Therefore the total
signal applied to the transducer will be close to the sum of
those voltages÷ 4.5V peak-to-peak, as shown in the purple
mathematical trace of Fig.3.
By the way, the reason the signals on both sides are the
transducer are not identical is explained by the presence
of the series 100Ω current-limiting resistor from pin 6.
Note that we are running the piezo transducer at close to
its resonant frequency to maximise its audible effect.
Fig.4 shows the same complementary drive signals but
at a slower sweep speed of 5ms/div. This shows how the
signal bursts are rapidly chopped which gives it a burbling
sound which is more attention-getting.
Finally, Fig.5 shows the same signal at the very low
sweep speed of 500ms/div and this shows the 260ms duration and 1.55Hz frequency of burbled tone bursts from
the transducer.
When the JP1 jumper is in the siren position, the siren
is powered by a high level (ie, the Vcc supply voltage) at
the GP0 output with its other terminal connected permanently to ground.
Construction
Fig.5: the piezo transducer signal from pin 7 of IC1,at
the very low sweep speed of 500ms/div and this
illustrates the 260ms duration and 1.55Hz frequency of
the burbled tone bursts from the microcontroller. The
burbling of the tone bursts makes the sound seem much
louder.
siliconchip.com.au
The Watchdog Alarm is constructed on a PCB coded
03107181, and measuring 42 x 93mm. It is presented as a
bare PCB that can be hung on the doorknob.
Fig.6 shows the PCB overlay. Begin construction by
installing the resistors. There are only three values and
of these, the only ones you could mix up are the 100Ω
(brown black brown brown) and the 1MΩ (brown black
green brown) in four-band code. Use a multimeter to check
the value of each before inserting into the PCB. The three
470Ω resistors have yellow, purple, brown, brown coding.
Diodes D1 to D3 can now be installed taking care to
orient correctly and noting that D1 is the 1N4004 and the
remaining diodes are 1N4148s. The 100nF capacitor can
be fitted now, followed by the IC socket (for IC1). It must
Australia’s electronics magazine
August 2018 79
You’re likely to see
this warning when
programming the
PIC12F617-I/P
On the PICkit 3
it can be safely
ignored, but other
programmers may
not support this
programming.
Parts list – Watchdog Door Alarm
1 double-sided PCB, coded 03107181, 42 x 93mm
1 SPDT PCB toggle switch (S1) [Altronics S1421]
1 20mm PCB button cell holder [Jaycar PH-9238, Altronics
S5056]
1 CR2032 lithium cell
1 8-pin DIL IC socket
1 piezo transducer [Jaycar AB-3440, Altronics S6140] OR
11-13V pulsating piezo siren [Jaycar AB3456, Altronics
S6117]
1 3-pin header with 2.54mm spacing (JP1)
1 jumper shunt (JP1)
2 PC stakes (optional)
2 M3 tapped x 9mm spacers
4 M3 x 6mm screws (at least two polycarbonate or Nylon)
1 4m length of multistrand insulated wire (eg 24 x 0.2mm)
1 150mm length of 6mm diameter heatshrink tubing
4 10mm diameter self-adhesive surface savers (stick-on feet)
Semiconductors
1 PIC12F617-I/P microcontroller
programmed with 0310718A.hex (IC1)
1 1N4004 1A diode (D1)
2 1N4148 diodes (D2,D3)
1 3mm red high brightness LED (LED1)
Capacitors
1 100nF 63V or 100V MKT polyester (Code 104 or 100n)
1 9.8-60pF trimmer capacitor (VC1)
Resistors (0.25W 1%)
1 1MΩ (Code brown black green brown or brown black
black yellow brown)
3 470Ω (Code yellow purple brown brown or yellow purple
black black brown)
1 100Ω (Code brown black brown brown or brown black
black black brown)
be oriented with the notch facing the 100nF capacitor.
The 3-way pin header for JP1 is next. Optional PC stakes
are installed at the wiring points for the piezo transducer or
for the siren (the wires could instead be directly soldered
to the relevant pads).
Make sure the plus terminal of the button cell holder is
oriented toward IC1 on the PCB. LED1 is mounted raised
off the PCB (we made ours about 10mm high but it can be
mounted higher). Take care with orientation – the longer
(anode) lead goes to the hole marked with the ‘A’.
VC1 can be installed either way around on the PCB.
Switch S1 is inserted into position and soldered in place.
The switch applies power when the toggle is up. The toggle
Here’s how the
on-board piezo
transducer mounts
on stand-offs
above the PIC.
The larger, more
powerful siren can
be mounted some
distance away. It
would connect to
the “siren” pads,
not the “piezo”
pads as seen here.
80
Silicon Chip
is protected inside the PCB cut out so is less likely to be
inadvertently moved.
Leave the siren or piezo transducer off for the moment.
Programming the microcontroller
If you purchase your PIC12F617-I/P microcontroller from
the SILICON CHIP Online Shop (and tell us which project
it’s for!) it will come already programmed (there is no extra
charge for programming).
However, if you want to program the PIC yourself, the
file 0310718A.hex can be downloaded from the SILICON
CHIP website.
There is one caveat: we are not using pin 4 of IC1 as the
master clear (MCLR) input but as an input for JP1. For master
clear we use the internal MCLR instead. Some programmers
will not support programming when the internal MCLR and
internal oscillator are selected. If you are using a PICkit 3,
the warning can be ignored and programming continued.
Make sure IC1 is oriented correctly before inserting into
its socket (the notch on the IC matches the notch on the
socket).
Now install the CR2032 cell in its holder and place a
jumper link onto the 3-way header at JP1. Switch on S1
and if all is well, the LED will light or flash rapidly to
acknowledge power has been connected.
All that’s left now is to fit the piezo transducer or the
off-board siren.
If you choose the piezo transducer, it is mounted to the
PCB on 9mm spacers using 15mm M3 screws. It sits up
10mm above the PCB surface as there are other components (including IC1) underneath. The two flanges on the
transducer housing will need the holes drilled out to 3mm.
There’s a little wrinkle here: the piezo housing flanges
do not quite allow for M3 screw heads, as the heads foul
the circular side of the transducer. With our prototype,
the sides of the heads were filed down for each screw that
secures the piezo transducer.
Plastic polycarbonate or Nylon screws are easier to file
down than steel. To secure the two screws, the standoff is
rotated onto the screw thread instead of rotating the screw.
Then the Piezo and standoffs can be secured to the PCB
with the screws on the underside of the PCB.
If you choose the significantly louder off-board siren,
note that it is polarised – the negative (usually black) wire
goes to the – siren terminal while the “pulse” wire (usually
yellow) goes to the + siren terminal. The red wire is not
used for three-wire sirens. By extending the siren’s black
Australia’s electronics magazine
The lip on the piezo transducer
doesn’t quite allow the screw heads
to fit, so we filed off one edge before
mounting. We used Nylon screws
because they’re a lot easier to file than
normal screws!
siliconchip.com.au
Here’s the door
handle loop before
heatshrinking and
soldering in place. It
consists of four turns
of hookup wire,
90mm in diameter.
The heatshrink helps
hold its shape.
and yellow wires with suitable hookup or thin figure-8 wire,
you can locate it some distance away from the PCB – even
a few metres or so, if you wish.
Finally, don’t forget to install the jumper shunt at JP1
in the correct position for the piezo transducer or siren
whichever is used (the PCB is clearly marked).
Wiring
The loops for the door handle are made up using a 1.2m
length of insulated wire to make four turns at 90mm in
diameter. We fed our loops through lengths of 6mm diameter heatshrink tubing so that the loops would stay in
place without unravelling. Strip back the two wire ends
a few millimetres and solder the ends into the doorknob
holes on the PCB.
For the counterpoise, cut three 900mm lengths of insulated wire, strip insulation from one end of each and solder
to the counterpoise holes located at the bottom of the PCB.
In use, these are spread out over the door and fixed using
Blu-Tack or tape.
It makes sense, if possible, to use wires the same colour
(or close) as the door to make them unobtrusive.
If you are placing this on a door that is not your own,
then check to see if the mounting method does not stain
or leave a mark on the door. In some cases, just having the
three wires loosely dangling straight down will be sufficient.
And here it is shrunk
and soldered. The loop
simply drops over
the door handle – no
electrical connection
is required as it detects
capacitance – in this
case, the capacitance
of the person touching
the doorknob on the
other side of the door.
When they do so . . .
GOTCHA!
Place the wire loop over a doorknob and switch on.
Adjust VC1 so that the LED flashes with the door handle
untouched but lights up when touched. This is a trial and
error adjustment, so try various settings of VC1. Once you
find a good position where the hand is detected readily,
the adjustment should not need changing again.
Note that for the first 10s after power is switched on, the
LED will flash at a fast rate before flashing about once per
second. That is if it is not detecting a touched door knob
and the adjustment of VC1 is correct.
The period when the LED is flashing at the faster rate
indicates that the piezo or siren, when connected, will not
sound when the doorknob is touched until the 10 seconds
has expired.
This is to allow the testing of the Personal Door Alarm
when first switched on without causing a lot of noise from
the alarm.
If you wish, stick some self-adhesive surface savers
(hemi-spherical adhesive buttons) to the corners of the
PCB to protect against scratching the door.
SC
Testing
Note that the Watchdog Alarm will not work if the door
is metal-sheathed or if the door jamb is metal. It works
best with timber-framed and timber doors with metal
doorknobs. There is no need for an electrical connection
from the doorknob to the wire loop, so the doorknob can be
lacquered (such as coated gold or brass finishes) or exposed
metal (such as brushed aluminium).
The three counterpoise
wires can, like the
doorknob loop, be
made from any surplus
hookup wire. They
should be about 900mm
long each – but can
be a little shorter if
your door handle is
lower than standard.
They solder to the PCB
but don’t connect to
anything else. The short
length of heatshrink
tubing provides strain
relief to the solder joints
on the PCB.
siliconchip.com.au
Australia’s electronics magazine
Fig.7: you need to secure the
counterpoise wires to the
door to ensure consistent
operation. Blu-Tack is good
because it doesn’t usually
leave marks when
removed.
August 2018 81
|