This is only a preview of the July 2015 issue of Silicon Chip. You can view 35 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. Items relevant to "Build a Driveway Monitor, Pt.1":
Items relevant to "Install USB Charging Points In Your Car":
Items relevant to "Intelligent Charger for Nicad & NiMH Batteries":
Articles in this series:
Items relevant to "Ultra-LD Mk.4 200W RMS Power Amplifier: Preview":
Purchase a printed copy of this issue for $10.00. |
Driveway
Monitor
Pt.1: By JOHN CLARKE
Based on a Honeywell magneto-resistive sensor, this Driveway
Monitor provides an audible and visual indication when a vehicle
is detected. Alternatively, it can be made to activate a remotecontrolled mains switch to turn on lights etc for a preset time.
O
UR DRIVEWAY MONITOR will
alert you to any vehicle arriving in
your driveway and it’s equally useful
on a farm, detecting vehicles passing
through a gate.
Several methods can be used for vehicle detection, including infrared and
ultrasonic beam set-ups. However, infrared and ultrasonic beams are prone
to false triggering so a typical vehicle
detection system relies on the very
small changes in the Earth’s magnetic
field caused the presence of a vehicle.
Fig.1 shows a representation of the
distortion in the Earth’s magnetic field
caused by the presence of a vehicle.
Our previous Driveway Sentry
units published in November 2004
& August 2012 used a coil of wire to
detect changes in the Earth’s magnetic
field when a vehicle passed over it.
This coil could either be laid under
the driveway or concealed in the expansion joints, if that was possible.
While this arrangement can work well
if you are installing a new driveway,
you wouldn’t want to jack-hammer
an existing concrete driveway to lay
a cable under it!
Our new Driveway Monitor sidesteps this problem by using a Honey26 Silicon Chip
well magneto-resistive sensor, as used
for magnetic field sensing in electronic
compasses. It’s so sensitive that it
doesn’t need to be located under the
driveway; somewhere alongside the
driveway is sufficient.
The magneto-resistive sensor is
teamed with a sensitive instrumentation op amp and a PIC microcontroller
which outputs a coded 433MHz signal.
This is picked up by a companion
433MHz receiver unit with various
optional outputs.
Once triggered, the receiver unit
flashes a green or red LED and sounds
a piezo alarm. It will even tell you
which way the vehicle is heading,
since a different distinct sound is
made by the piezo transducer for each
direction, while a third tone indicates
vehicle movement in either direction.
In addition, the green LED flashes for
vehicles entering the driveway, while
the red LED flashes for vehicles exiting
the driveway.
Alternatively, the LEDs and piezo
transducer can be omitted and a couple
of reed relays fitted to the receiver PCB
instead. These can be used to trigger a
UHF remote-controlled mains socket
(via its remote), a wireless doorbell
remote or perhaps even the remote for
a motorised gate opener.
The detector circuitry is installed
in an IP65 case (115 x 90 x 55mm)
that’s dust tight and able to withstand
wet weather. This would normally be
mounted alongside the driveway, either on an adjacent fence, wall or post.
Power for the detector comes from
a single 1.25V AA NiMH cell that’s
recharged using a solar cell panel (the
same as those used with solar garden
lights). No mains power is necessary.
On the other hand, if you don’t want
to use solar power and there is access
to undercover mains power, a small
9-12V DC plugpack could be used to
recharge the NiMH cell.
The companion receiver unit is
housed in a small plastic case and is
powered from a 12V DC plugpack. It
can be placed where it can be readily
heard and seen, if you intend using it
purely as an audible/visual indicator.
Alternatively, it can be placed out of
sight if you intend using it to trigger
a remote controlled mains socket or
some other device.
Block diagram
Fig.2 shows the block diagram of
siliconchip.com.au
Fig.1: how the Earth’s magnetic field is disturbed by a vehicle travelling
along a driveway. These disturbances are detected by the magneto-resistive
sensor used in the Driveway Monitor.
+5V
+5V SWITCHED
3
SET/RESET
STRAP
OUT–
SENSOR1
OUT+
Each time the sensor detects a large
change in the surrounding magnetic
field, its magneto-resistors need to be
reset by means of an internal “strap
coil” which provides a strong magnetic
field. Hence the strap coil is subjected
to a short reset signal from the micro.
And in fact, before a measurement can
be made, a “set” signal must also be
applied, again by the microcontroller
siliconchip.com.au
IC1
INSTRUM OUT
AMP REF
5
–IN
4
2
+5.5V
Q2
P-CHAN
MOSFET
1 µF
Strap coil
LOW PASS
FILTER
7
Vdd
Vset
6
AN2
IC2
MICROCONTROLLER
PWM
The detector PCB carries the magnetoresistive sensor and is mounted in a
waterproof case near the driveway
(note: prototype PCB shown).
the detector circuit. It’s based on the
Honeywell HMC1021S one-axis magneto-resistive sensor, instrumentation
amplifier IC1, PIC microcontroller IC2
and Mosfets Q1 & Q2.
The magneto-resistive sensor is essentially a Wheatstone bridge of four
resistors (which are affected by magnetic fields). The bridge is connected
across a 5V supply and a change in
the local magnetic field changes the
resistor values so that the voltages at
the sensor’s outputs move up or down.
This shift in the output terminals is
monitored by differential instrumentation amplifier IC1.
Its output feeds microcontroller IC2
via a low-pass filter. If the magnetic
field around the sensor changes, the
micro sends an appropriately coded
signal to a 433MHz transmitter module
(not shown on Fig.2).
+IN
S
LOW PASS
FILTER
G
RB1
D
Q1
N-CHAN
MOSFET
D
S
RB0
Vss
G
Fig.2: block diagram of the detector circuit. The output from the magnetoresistive sensor (Sensor1) is amplified by differential op amp IC1 which
then feeds the AN2 input of microcontroller IC2 via a low pass-filter. IC2
then processes the amplified sensor signal and also drives Mosfets Q2 & Q1
via its RB0 & RB1 outputs to provide set and reset signals to a strap coil in
the sensor. In addition, IC2’s PWM output applies an offset voltage to the
REF input of IC1, so that IC1’s pin 6 normally sits at 2.5V (half-supply).
(see the panel on pages 30-31 for further details).
The set and reset pulses appear at
IC2’s RB0 & RB1 outputs respectively
and these drive Mosfets Q1 & Q2. The
resulting pulses are fed to the strap
resistor via a 1µF capacitor.
Each time IC2 takes RB0 low for a
set pulse, Q2 switches on and current
flows through the 1µF capacitor and
the set/reset strap to ground (0V). The
1µF capacitor charges to +5.5V and
Q2 then switches off . The amplified
sensor output (Set) is then read at IC2’s
AN2 input.
Conversely, for the reset pulse, Q1 is
switched on when RB1 is taken to +5V.
The 1µF capacitor then discharges
through the set/reset strap with current
now flowing in the opposite direction than for the set pulse. Q1 is then
switched off to end the reset pulse and
the amplified sensor output (Reset) is
again read at the AN2 input.
IC2 then needs to apply an offset
voltage to IC1 so that its output at
pin 6 normally sits close to 2.5V and
thereby ensure that its output swing
is symmetrical. IC2 calculates this
offset voltage by averaging the readings
after the set and reset pulses. It then
generates a pulse width modulated
signal at its PWM output and this is
fed via a low-pass filter to pin 5 (REF
input) of IC1.
The PWM signal generated by IC2
switches between 0V and 5V at 7.8kHz.
Its duty cycle is automatically adjusted
after each measurement to correct for
any offset changes from both the sensor
and IC1 due to temperature changes.
IC1’s output is also low-pass filtered,
to reduce any voltage ripple at IC2’s
AN2 input, due to the PWM signal, to
July 2015 27
+5V
AMPLIFIED OUTPUT DUE TO
CHANGE IN FIELD
STEADY
STATE LEVELS
UPPER
THRESHOLD
AMPLIFIED
SENSOR
OUTPUT
LOWER
THRESHOLD
+2.5V
TRACKING
THRESHOLDS
DETECT
DETECT
0V
Fig.3: this diagram shows how IC1’s pin 6 output changes when a vehicle
comes close to the sensor. It either decreases and then rises as the vehicle
approaches (as shown here) or it increases and then falls, depending on the
orientation of the sensor and the direction of the vehicle. A vehicle is detected
whenever the amplified sensor output exceeds the slowly-averaged upper and
lower thresholds set by IC2 in response to IC1’s steady-state output.
a very low level. This allows microcontroller IC2 to detect voltage changes
from the sensor as low as 5mV without
being swamped by noise and ripple.
Detecting a vehicle
Fig.3 shows how IC1’s output
changes when a vehicle comes close
to the sensor. As can be seen, it either
decreases and then rises as the vehicle
approaches or it increases and then
falls, depending on the orientation of
the sensor with respect to the Earth’s
magnetic field and the direction of
the vehicle.
This enables the microcontroller
to determine the vehicle’s direction.
A linking option on the PCB tells the
microcontroller which is the entry direction and which is the exit direction.
IC2 detects a vehicle when IC1’s output rises above an internally-generated
upper threshold or falls below a lower
threshold. These two thresholds are
set equidistant above and below the
steady-state amplified sensor output.
Main Features
• Remote vehicle detection with adjustable detection sensitivity
• Vehicle detection LED indication
• Vehicle direction detection
• Solar panel and NiMH cell powered
• Transmits vehicle detection via UHF link to the receiver
• Typical UHF range: 200m in open space
• Eight possible UHF transmission identities to allow for multiple Driveway Monitor
pairs to be used in close proximity
• Selectable vehicle entry only or exit only detection or both entry and exit detection
• Optional non-directional indication
• Vehicle direction detection setting to cater for detector positioning and driveway
orientation
Over
range indication (flashes red & green LEDs in detector unit) alternately.
•
• Diagnostic setting
• Receiver has audible and visible indication of vehicle detection
• Receiver produces different sounds for exit and entry unless non-direction detection
is selected on the detector unit
• Detection sampling rate: typically 300ms
• Set & reset pulses: every 10s
28 Silicon Chip
In operation, these upper and lower
thresholds track the sensor’s amplified
output at a slow rate to compensate
for any output changes with temperature (as well as slow magnetic field
changes) over time. So if the sensor’s
amplified DC output falls, the thresholds will also fall.
On the other hand, the tracking is
slow enough to ensure that any quick
changes in IC1’s output level (ie, due
to vehicle movement) will exceed the
thresholds for brief periods. These are
shown as the “detect” periods on Fig.3
and when the thresholds are breached,
the microcontroller determines that a
vehicle has been detected.
Note that in order to conserve the
battery, the detector circuit doesn’t
continuously monitor changes in the
magnetic field. Instead, both the sensor and IC1 are powered for a brief
period every 300ms and this is when
IC2 samples IC1’s output.
Circuit details
Now take a look at Fig.4 which
shows the full circuit of the detector
unit. The top section can be regarded
as a more detailed version of the block
diagram of Fig.2 but it also includes
433MHz UHF transmitter module
TX1, PNP transistors Q3 & Q4 and a
switching power supply.
Q3 & Q4 are respectively driven by
RB2 & RA3 of IC2 and switch power to
the sensor, IC1 and the UHF transmitter module every 300ms, as mentioned
above. The switched 5V supply rail
from Q3 is decoupled using a 1µF
electrolytic capacitor and a 100nF
ceramic capacitor.
The power supply uses a TL499A
switchmode step-up regulator (REG1),
a linear 5V regulator (REG2) and an
LMC6041 micropower op amp (IC3).
As stated above, it’s powered from a
1.25V NiMH AA cell that’s topped up
by a solar panel.
Alternatively, by cutting a track on
the PCB and installing resistor R1, a
9V or 12V DC supply can be used to
maintain cell charge if a mains supply
is available.
The 5V rail from REG2 directly
powers microcontroller IC2 and is
switched to sensor 1 and IC1 by Q3
and to the TX1 module by Q4. Sensor
1 draws a current of about 5mA each
time it is briefly powered up.
The Out+ and Out- terminals are
fed to the IN- and IN+ inputs of IC1
via ferrite beads, while the 1nF bypass
siliconchip.com.au
Q3 BC327
C
SENSOR1
HONEYWELL
HMC1021s
100nF*
2
100nF*
GAIN
1
+Rg
IC1
AD623
OUT
REF
1
–Rg
2
–IN
4
FB2
6
8
2.2k
1
1 µF
5
9
1nF*
LK1
ENTRY
SR+
5
Q2
IRF9540
SET/RESET
STRAP
SR–
EXIT
220Ω
6
1 µF
S
G
SWAP
12
LK3
11
470 µF
1 µF
10
10V
LOW ESR
D
D
Q1
IRF540
+5.5V
13
LK2
6
10Ω
7
λ
A
PWM
IC2
PIC1 6F8 8
PIC16F88
RB7
15
4.7k
2
RA3
E
B
RB6
IDENTITY
VR3
10k
17
16
RB5
Vcc
TX1
RB4
RA1
Q4
BC327
C
TP1
RA0/AN0
RB0
K
λ
AN2
18
433MHz
TX
MODULE
DATA
RB1
ANT
Vss
10Ω
S
2.2k
3
RA4
RB2
Vout
100nF
LED1
MCLR
RA6
22k
3
4
14
Vdd
7
+IN
10k
100nF
B
10k
3
4
VR1 500Ω 8
OUT+
1 µF
1nF*
FB1
OUT–
+5V
E
5
G
GND
* CERAMIC
L1 470 µH
SEE TEXT
D1
1N4004
R1 (1W)
TO +
SOLAR
PANEL –
CON1
A
+5.5V
3 SW REG
K
IN2
CUT TRACK
IF R1 USED
1.25V
NiMH
CELL
SW IN
REG1
TL499A
SW CUR
CTRL
K
D2
1N4004
470 µF
4
OUT
REF
6
IN
2
220 µF
100nF
6
IC3
A
10 µF
2
4
330Ω
+5V
3
7
10V
LOW ESR
OUT
GND
VR2
1M
1nF
10V
LOW ESR
7
5
REG2
LM2936Z-5.0
IC3: LMC6041
8
GND PGND
TP5.5
100k
TP
GND
1N4004
A
SC
20 1 5
LM2936Z
K
DRIVEWAY MONITOR DETECTOR
K
A
Q1, Q2
BC 32 7
LED
IN
B
OUT
GND
E
G
C
433MHz Tx MODULE
D
D
ANT
Vcc
DATA
GND
S
Fig.4: the full circuit diagram for the detector unit. It includes all the elements shown in Fig.2 and also shows LED1
(for exit and entry indication) and the 433MHz transmitter (TX) module which is driven by IC2’s RA1 port. Q3 briefly
switches power to the sensor and IC1 at 300ms intervals while Q4 briefly switches power to the TX module, to minimise
current consumption. Power comes from a 1.25V NiMH cell topped up by a solar cell. Switching regulator REG1 steps
up the voltage to produce a 5.5V rail for Q2 & Q1, while REG2 produces a regulated 5V rail for the rest of the circuit.
capacitors to ground attenuate any RF
signals. In addition, a 100nF capacitor
bypasses the IN+ and IN- inputs to
provide further RF suppression.
IC1 is an Analog Devices AD623 differential amplifier and it draws about
300µA from the 5V supply. Its gain is
adjusted using trimpot VR1 and can
be varied from about 201 times when
VR1 is set to 500Ω (its maximum) up
to about 1000 times when VR1 is set
to 100Ω.
IC2’s PWM signal is fed to pin
5 (REF) of IC1 via a low-pass filter
consisting of a 22kΩ resistor and a
siliconchip.com.au
100nF capacitor. The filter sets the
roll-off frequency to about 72Hz and
this effectively removes a considerable
amount of the 7.8kHz PWM switching
frequency.
However, by itself that is not effective enough to remove sufficient
PWM ripple and so IC1’s output also
has low-pass filtering, using a 2.2kΩ
resistor and 1µF capacitor.
Microcontroller IC2 (a PIC16F88)
converts the voltage at its AN2 (pin 1)
input into a digital value using a 10-bit
A-D converter. This gives a resolution of close to 4.9mV. The variation
available for the PWM output also has
10-bit resolution, allowing IC1’s offset
voltage to be set in 4.9mV increments.
Set & reset signals
Mosfet Q2 is driven by IC2’s RB0
output and provides the set pulse drive
current, while Q1 is driven by RB1
and provides the reset pulse drive for
Sensor1’s set/reset strap.
This strap is a coil with about 7.7Ω
resistance and it produces the high
magnetic field required to realign the
elements in the sensor along the “easy”
axis (see the further description of the
July 2015 29
How A Magneto-Resistive Sensor Works
The Honeywell HMC1021S sensor
used in this project is a one-axis type. In
essence, this means that it only reacts
to changes in the horizontal component
of the Earth’s magnetic field (assuming
that it is installed on a vertical PCB.
Fig.5 shows the basic construction of
this type of sensor which comprises four
identical resistive elements arranged in
a Wheatstone bridge configuration.
Each element is basically an NiFe
(nickel-iron) thin film that changes its
resistance in response to changes in
the magnetic field passing through
it. Whether an element increases or
decreases its resistance with magnetic
field strength depends on its orientation
and the magnetic field polarity.
Fig.5 shows how the elements in the
sensor are arranged. Two diagonally
opposite elements are orientated one
way, while the other two are orientated
in the opposite direction, in the Wheatstone bridge. Because of its sensitivity
to magnetic field direction, a magnetoresistive sensor is often called an
“anisotropic magneto-resistive” sensor
or AMR. The term “anisotropic” simply
means directional.
In operation, a supply voltage is applied between the top and bottom of the
bridge (ie, between its Vb and GND terminals), so a current flows through the
elements. If a magnetic field is absent,
the OUT+ and OUT- terminals are both
at half supply (ie, Vb/2).
By contrast, if a magnetic field is
present, two diagonally opposite elements will decrease in resistance while
the other two diagonally opposite elements will increase in resistance. As a
result, the OUT+ and OUT- terminals
Vb
BRIDGE
CURRENT
MAGNETIC
EASY
AXIS
PERMALLOW
THIN FILM
OUT-
OUT+
MAGNETIC
SENSITIVE
AXIS
GND
Fig.5: the magneto-resistive sensor
consists of four identical thin-film
elements arranged in a Wheatstone
bridge configuration. Two
diagonally opposite elements are
orientated one way, while the other
two face in the opposite direction.
will change voltage by equal amounts
but in different directions.
In other words, one terminal will rise
above half-supply by a certain amount,
while the other will fall below half-supply
by an equal mount.
Offset voltage
That’s the basic theory of the sensor
operation. In practice though, real sensors have an offset voltage between
OUT+ and OUT- in the absence of a
magnetic field. That’s because when
the sensor elements are made, there
PERMALLOY (NiFe) MAGNETO-RESISTIVE ELEMENT
RANDOM
MAGNETIC
DOMAIN
ORIENTATIONS
SET MAGNETISATION
EASY AXIS
SENSITIVE
AXIS
AFTER A
SET PULSE
RESET MAGNETISATION
EASY AXIS
SENSITIVE
AXIS
30 Silicon Chip
AFTER A
RESET PULSE
Fig.6: the set
and reset pulses
applied to the strap
coil inside the
sensor align the
magnetic domains
in the resistive
element along the
easy axis.
will always be small variations between
them, thereby causing an imbalance in
the bridge. In addition, this offset voltage
will vary with temperature.
Another problem is that the magnetic
domains in the sensor elements can
move out of alignment in the presence of
strong magnetic fields. Basically, the domains in the elements must be orientated
along what is called the “easy” axis and
this is the alignment that the magnetic
domains are set to during manufacture.
Fig.6 shows the general idea.
Correct easy axis alignment is necessary to ensure maximum sensitivity of
the sensor to magnetic fields. The most
sensitive direction for magnetic field
detection is perpendicular (ie, at a right
angles) to the easy axis. Any external
magnetic field (or a portion of that field)
that is not parallel to the easy axis will
cause the magnetic domains to rotate
away from the easy axis and this alters
the resistance of the sensor element.
Conversely, when the magnetic field
is removed, the magnetic domains
return to their easy axis alignment,
provided that the magnetic field does
not exceed the specified operating range
for the sensor.
Set & reset pulses
In practice, this all means that the
sensor will periodically need to be set
and reset using a high magnetic field,
to realigns the magnetic domains along
the easy axis. This set and reset procedure is achieved by applying a pulse
current to the strap coil incorporated
within the sensor.
The set and reset currents used
are opposite in polarity. When the coil
is driven with one current polarity, it
produces a magnetic field that aligns
the domains in one direction along the
easy axis. Reversing the current direction through the sensor’s coil then aligns
the domains in the other direction (ie, it
rotates them by 180°).
Fig.7 shows the effect of the set and
reset pulses on the sensor’s output. As
shown, a brief set pulse produces a large
output from the sensor, due to the large
magnetic field produced by this pulse.
Following the set pulse, the output
from the sensor goes down to Vset
which is the voltage difference between
Out+ and Out-. This voltage is shown as
being above the offset voltage (Voff) of
the sensor and is produced in response
to an external magnetic field.
siliconchip.com.au
Vset
Voff
OFFSET
TIME
Vcc/2
Vreset
+
SET
SET
AND
RESET
PULSES
RESET
–
Fig.7: this diagram shows the effect of the set and reset pulses on the sensor’s
output. Note that the output polarity switches after each pulse.
A reset pulse then follows, after
which the output from the sensor goes
to Vreset. This again is the voltage difference between Out+ and Out- and is
now below Voff.
Note that after a set pulse, a subsequent reset pulse switches the polarity
of the sensor’s output voltage. Similarly,
after a reset pulse, a set pulse switches
the output polarity back again.
Fig.7 only applies for one direction of
the magnetic field. If the field is reversed,
then the polarities of Vset and Vreset
are also reversed. In other words, Vset
will be lower than Voff after a set pulse,
while Vreset will be higher than Voff
after a reset pulse.
By contrast, the sensor’s offset voltage (Voff) is unaffected by magnetic
field variations – it’s only the sensor’s
output that varies. In the absence of
a magnetic field, the offset Voff would
simply be the difference between Out+
and Out-. In practice though, the device
operates in the presence of the Earth’s
magnetic field.
In summary, we need the set and
reset pulses to realign the magnetic domains in the sensor to ensure maximum
sensitivity. As a bonus, this also provides
a means to calculate the sensor’s offset
siliconchip.com.au
voltage (Voff) and thus compensate for
it. That’s done by simply adding the Vset
and Vreset values together and dividing
by two. Calculating Voff at regular intervals then allows us to compensate for
offset changes with temperature.
Why compensate for offset?
But why do we need to compensate
for the sensor offset? The reason is
that changes in the sensor’s output in
response to magnetic field variations are
quite small and so we need to amplify
its output. Assuming a 5V supply (as in
this circuit), the output varies by around
2.5mV, depending on the sensor’s orientation within the Earth’s magnetic field
(approximately 50μTesla or 0.5 Gauss).
By contrast, the sensor’s offset could
be up to 11.25mV. So if a 2.5mV signal
is amplified by say 500 to obtain a
1.25V signal, the 11.25mV offset voltage would also be amplified by 500 to
a level of 5.6V.
That means that unless we compensate for the sensor’s offset voltage,
the amplified signal could result in the
amplifier’s output being pegged at either
the positive or 0V supply rail, with no
resulting change in level due to magnetic
field variations.
workings of the magneto-resistive sensor in the panel at left).
As shown on Fig.4, Q2’s source is
connected to the +5.5V supply rail via
a 220Ω isolating resistor and decoupled using a 470µF low-ESR capacitor and a 1µF MKT capacitor. The set
pulse current is applied to the strap via
the 1µF capacitor as it charges when
Q2 turns on, while the discharge current from this 1µF capacitor provides
the reset pulse when Q1 turns on.
Both the charge and discharge peak
currents are in excess of the 500mA
minimum required for this operation.
The accompanying oscilloscope
traces (Fig.8 & Fig.9) show the set and
reset pulses. In each case, the top trace
is the drain voltage of Q2 & Q1, while
the lower trace is the pulse applied to
the set/reset strap of the sensor. Note
that the set pulse is a positive voltage
while the reset pulse is negative.
Note also that there is a small
amount of “dead time” between when
Q2 is switched off and Q1 is switched
on. This ensures that they aren’t both
on at the same time (however briefly)
which is necessary to prevent a momentary short across the decoupled
supply rail.
In operation, RB0 & RB1 of IC2 drive
the Mosfet gates every 10s and both
the set and reset pulses decay away
over time. These pulses produce a
magnetic field in the sensor, so the
amplified sensor signal from IC1 is
checked by IC2 only while both Q1
& Q2 are switched off to ensure that
only variations in the Earth’s magnetic
fields are detected.
Detection & link options
As previously mentioned, the voltage fed by IC1 to AN2 of IC2 is compared against high and low threshold
voltages that track AN2’s voltage at a
slow rate. Whenever AN2’s voltage
varies, the thresholds are adjusted up
or down by 4.8mV every 1.5s. How
ever, a moving vehicle will cause
AN2’s signal voltage to vary by considerably more than 4.8mV in much less
than 1.5s and so the thresholds will
be exceeded.
IC2 detects whenever AN2 goes below the lower threshold or above the
upper threshold and drives a bi-colour
red/green LED (LED1). The green LED
lights for five seconds if AN2’s voltage
initially goes below the lower threshold, while the red LED lights for 5s
if it goes above the upper threshold.
July 2015 31
Fig.8: this scope grab shows how the set pulse for the strap
coil is generated. Each time IC2’s RB0 output briefly goes
high, Mosfet Q2 switches on and the commoned Mosfet
drains go high as shown by the orange trace. The bottom
green trace shows the resulting positive-going set pulse
that’s then applied to the strap coil via the 1μF capacitor.
During this time, the detection process
is disabled.
At the same time, a vehicle detection
signal is sent to the receiver circuit by
the 433MHz transmitter (TX) module,
depending on the linking options selected for LK1, LK2 & LK3.
LK1 is used if you want entry (arrival) notifications to be transmitted,
while LK2 is installed if you want exits
(departures) to be transmitted. Either
LK1 or LK2 can be installed, or both
can be installed to warn of both arrivals
and departures.
LK3 is the “swap” link and is used to
set the unit so that it correctly identifies
the vehicle’s direction (entry or exit).
As stated, this direction indication
initially depends on the orientation
of the driveway and which side of the
driveway the detector unit is mounted
on. If the directions are incorrect, it’s
Fig.9: the following reset pulse is generated when RB1
subsequently briefly goes high. This turns on Mosfet Q1
and the commoned Mosfet drains are then pulled to 0V
as shown by the orange trace. A negative-going reset
pulse (green trace) is then generated as the 1μF capacitor
discharges
just a matter of installing the link.
Installing LK3 simply swaps over
the exit and entry transmission codes
that are sent to the receiver and the
detection LED colour.
Non-directional signalling
Yet another link option (not shown
on Fig.4) forces the Driveway Sentry
to send a non-directional signal to the
receiver unit, instead of separate entry
and exit signals. That’s done by installing a link between LK1 & LK2 to short
pins 12 & 13 of IC2. The receiver unit
then simply indicates that a vehicle
has passed by the detector without
indicating its direction.
Yet another option is to install a link
between LK2 & LK3 to short pins 11 &
12 of IC2. This is a diagnostic connection and we’ll describe this in greater
detail next month.
Fig.10: the top
trace in this scope
grab shows the
reference voltage
applied to pin 5
of IC1, while the
bottom trace shows
the filtered output
from pin 6 that’s
fed to the IC2’s
AN2 input. The
reference voltage
is about 180mV
above the half
supply of 2.5V to
compensate for the
sensor’s offset.
32 Silicon Chip
IC2 determines which links have
been installed by first pulling its RB5,
RB6 & RB7 inputs high (ie, to +5V). Its
RB4 output is then pulled low (0V) and
the RB5-RB7 inputs checked to see if
any of these are also now low. If so,
then a jumper link must be installed
on that particular input.
Determining if there is a connection
between RB7 & RB6 or between RB6 &
RB5 is only slightly more complicated.
It’s done by first making RB6 an output
and RB4 an input. RB6 is then taken
both low (0V) and high (5V) and RB7
& RB4 checked to see if either one
follows RB6. If an input follows, then
there is a jumper link between it and
RB6.
433MHz UHF transmitter
TX1 is the 433MHz transmitter
module. Its supply line is switched by
Q4 and this transistor is turned on by
IC2’s RA3 output whenever transmission is required (ie, Q4 turns on when
RA3 goes low).
Trimpot VR3 is also connected to
the +5V supply rail when Q4 turns on.
Its wiper is monitored via IC2’s AN0
input and the set voltage is included
in the UHF transmission as identity
information. This voltage then needs
to match the voltage set on a similar
trimpot in the receiver unit in order
for the transmission to be accepted
(ie, in order for pairing to take place).
There are eight valid voltage ranges
that can be set using VR3 to select one
of eight different identities. As a result,
up to eight different detector and resiliconchip.com.au
Parts List: Detector Unit
ceiver pairs can operate independently
in close proximity.
Conserving the battery
As already noted, Sensor1 draws
about 5mA and the AD623 amplifier
(IC1) about 300µA from the 5V supply when connected via Q3. That’s a
total of 5.3mA from the 5.5V output of
REG1 and means that around 25mA
would be drawn from the single 1.25V
AA cell that powers everything (taking
into account power conversion and
efficiency).
Because of this, a number of steps
have been taken to minimise the power
consumption. First (and as previously
mentioned), Sensor1 and IC1 are only
powered up each time a measurement
is required and that’s done for only
about 20ms at 300ms intervals. This
20ms duration was chosen to give
sufficient time for the filters at IC1’s
reference (REF) input and at its output
to settle (ie, much longer than the lowpass filter time constants of 2.2ms).
As a result, the power on/off ratio is
1/15 and so the average current drawn
from the 5V supply is just 5.3mA x
1/15th = 353µA.
The 433MHz UHF module draws
10mA when powered, while VR3
draws a further 500µA. However, they
draw very little power overall, since
they are only powered up when a UHF
transmission is required (ie, when a
vehicle is detected).
Even if a vehicle stops next to the
detector, the unit will quickly stop
transmitting as the upper and lower
thresholds catch up to the voltage on
IC2’s AN2 pin.
Further power is saved by shutting
down microcontroller IC2 so that it is
in sleep mode for most of the time and
drawing a maximum current of just
11µA. This current is much lower than
when actually running its internal
program and drawing up to 2.8mA.
In operation, IC2 is woken up for
20ms every 300ms by a watchdog timer
that runs while it is in sleep mode (ie,
2.8mA is drawn for just 20ms every
300ms). This means that IC2’s average
current is just 187µA.
An additional power saving has been
made by having IC2’s RB4 output normally set high, so any jumper links that
are inserted do not cause the internal
pull-up current to flow. This can save
up to 1.2mA if all the links are in place.
In operation, RB4 is taken momentarily
low when the link connections need to
siliconchip.com.au
Detector Unit
1 PCB, code 15105151, 104 x
78mm
1 IP65 polycarbonate enclosure,
115 x 90 x 55mm
1 single AA cell solar panel &
wiring
1 AA cell holder
1 NiMH AA cell
1 powdered-iron toroidal core, 15
x 8 x 6.5mm (Jaycar LO-1242)
1 2-way PCB-mount screw terminal with 5.08mm spacing
1 UHF transmitter (TX1) (eg, Jaycar ZW-3100)
1 3-way DIL pin header strip
(2.54mm spacing)
3 pin header shunts
1 18-pin DIL IC socket
3 8-pin DIL IC sockets (optional)
1 cable gland for 3-6.5mm cable
7 PC stakes
2 No.4 x 6mm self-tapping screws
4 M3 x 6mm screws
2 5mm ferrite beads
2 100mm cable ties
1 50mm length of tinned copper
wire
1 750mm length of 0.5mm-
diameter enamelled copper
wire
1 170mm length of light duty
hook-up wire
1 500Ω miniature horizontalmount trimpot (code 501)
(VR1)
1 1MΩ miniature horizontal-mount
trimpot (code 105) (VR2)
1 10kΩ miniature horizontal-mount
trimpot (code 103) (VR3)
be checked but again the overall average current is quite small.
Power supply circuit
The single 1.25V AA cell’s output
is stepped up to 5.5V using step-up
regulator REG1. Regulator REG2 is
then used to derive the 5V rail.
This second regulator helps remove
any switching noise from the output
of the step-up regulator and provides
a well-regulated 5V supply to power
Sensor1, IC1, IC2 and the 433Hz TX
module.
In greater detail, REG1 is a TL499A
step-up regulator. In operation, current
flows through inductor L1 each time
REG1’s SW IN output (pin 6) switches
low. When this reaches a peak value,
Semiconductors
1 Honeywell HMC1021S oneaxis magneto-resistive sensor
(Sensor1)
1 AD623AN instrumentation
amplifier (IC1)
1 PIC16F88-I/P microcontroller
programmed with 1510515A.
hex (IC2)
1 LMC6041IN CMOS micropower
op amp (IC3)
1 TL499A power supply controller
(REG1)
1 LM2936Z-5.0 low dropout 5V
regulator (REG2)
1 IRF540 N-channel Mosfet (Q1)
1 IRF9540 P-channel Mosfet
(Q2)
2 BC327 PNP transistors
(Q3,Q4)
2 1N4004 1A 400V diodes
(D1,D2)
1 bi-colour LED (two lead) LED1
Capacitors
2 470µF 10V low-ESR electrolytic
1 220µF 10V low-ESR electrolytic
1 10µF 16V PC electrolytic
1 1µF 16V PC electrolytic
3 1µF MKT polyester
3 100nF MKT polyester
2 100nF ceramic
1 1nF MKT polyester
2 1nF ceramic
Resistors (0.25W, 1%)
1 100kΩ
2 2.2kΩ
1 22kΩ
1 330Ω
2 10kΩ
1 220Ω
1 4.7kΩ
2 10Ω
the SW IN output is switched off and
the stored energy in the inductor is
fed via an internal diode to the pin
8 output. This output is then filtered
using a 100nF MKT capacitor and a
220µF low-ESR capacitor.
The 330Ω resistor between pin 4
of REG1 and ground sets the peak
current through the inductor to about
300mA. Voltage regulation is achieved
by sampling the output voltage using a
resistive divider (VR2 and 100kΩ) and
then feeding this sampled voltage to
the reference input at pin 2. In this case,
the inductor switching rate must be
adjusted so that pin 2 is kept at 1.26V.
This means that for a 5.5V output,
the voltage divider needs to reduce the
5.5V down to 1.26V and that’s done
July 2015 33
Parts List: Receiver Unit
1 PCB, code 15105152, 79 x 47mm
1 433MHz UHF receiver (RX1)
(Jaycar ZW-3102)
1 12V DC plugpack rated at 100mA
1 UB5 or UB3 case (see Pt.2)
1 8-pin DIL IC socket
1 PCB mount DC socket with 2.1
or 2.5mm centre pin to suit
plugpack plug (CON1)
6 PC stakes
1 170mm length of light-duty
hook-up wire
1 20mm length of 1mm-diameter
heatshrink tubing
2 10kΩ miniature horizontal mount
trimpots (code 103) (VR1,VR2)
Semiconductors
1 PIC12F675/I-P microcontroller
(programmed with 1510515B.
hex (IC1)
1 78L05 5V regulator (REG1)
1 1N4004 1A diode (D3)
Capacitors
2 100μF 16V PC electrolytic
1 100nF MKT polyester
Resistors (0.25W, 1%)
1 1kΩ
1 100Ω
with VR1 set to 336kΩ.
The voltage from the divider is then
buffered using op amp IC3 (which is
configured as a voltage follower) before
being fed to pin 2 of REG1. This buffer
stage allows the use of higher-value
divider resistors than would otherwise
be the case and this was again done to
minimise power consumption.
REG1’s 5.5V output appears at pin
8 and is used to drive regulator REG2.
The 5.5V rail from REG1 is also as the
supply for the set/reset pulse generator circuit based on Mosfets Q2 & Q1.
REG2 is a low quiescent current and
low drop-out regulator. Its low dropout specification means we only need
to provide 5.5V for the regulator to
fully regulate to 5V. By contrast, most
standard regulators require at least a
6.5V input to regulate to 5V.
Average current
The average current drawn from the
5V supply is around 550µA. However,
the current drawn from the AA cell is
much higher than this. That’s because
the AA cell has an output of just 1.25V
and this is stepped up to 5.5V before
34 Silicon Chip
Extra Parts For Version 1 (Relays &
Mains Remote Control)
1 UHF remote controlled mains
switch (Altronics A 0340, Jaycar
MS-6145, MS-6142)
1 UB3 box 130 x 68 x 44mm
2 SPST DIP 5V reed relays
(Altronics S4100A, Jaycar SY4030) (Relay1,Relay2)
2 1N4148 diodes (D1,D2)
3 2-way pin headers
3 2-way pin header plugs
1 100Ω 0.25W 1% resistor
2 M3 x 9mm tapped spacers
4 M3 x 6mm tapped spacers
12 M3 x 6mm screws OR
6 M3 x 6mm screws AND
6 M3 x 6mm countersunk screws
120mm x 6-way rainbow/IDC cable
Extra Parts For Version 2 (Audible &
Visual Indication)
1 UB5 box, 83 x 54 x 31mm
2 M3 x 9mm tapped spacers
4 M3 x 6mm screws
1 piezo transducer (Jaycar AB3440, Altronics S 6140)
1 green high intensity LED (LED1)
1 red high intensity LED (LED2)
1 1kΩ 0.25W 1% resistor
being regulated to 5V. So you would
expect the current drawn from the AA
cell to be some 5.5/1.25 = 4.4 times
higher, assuming that the TL499A
regulator’s step-up efficiency is 100%
which, of course, it isn’t.
At a more realistic 70% efficiency,
the current would be expected to be 6.3
times higher. And that means that the
calculated total average current drawn
from the AA cell is 3.5mA.
In practice, we measured a current
drain of close to 3mA in our prototype. That means that a 2000mAh AA
NiMH cell would last for about 28 days
without recharging. The solar panel
we tested charged the cell at 20mA
in mid-morning autumn sunlight and
that is more than sufficient to maintain
the cell’s charge.
Diode D1 provides protection if
the solar panel is connected with the
wrong polarity, while D2 provide reverse polarity protection if the 1.25V
cell is inserted in its holder the wrong
way around.
Finally, resistor R1 is included to
provide current limiting if a 9V or
12V mains plugpack is used instead
of a solar panel to recharge the battery. This resistor is normally shorted
out on the PCB since it is not required
when a solar panel is used. However,
the PCB track has a section that’s easily cut if the resistor is required (see
the construction details next month).
Receiver circuit
Fig.11 shows the receiver circuit
details. It’s based on the 433MHz
receiver module, an 8-pin PIC12F675
microcontroller (IC1) and a 5V regulator (REG1). Also shown are the entry
and exit LEDs, the piezo transducer
and the alternative reed relays.
Microcontroller (IC1) monitors the
data signal output from the UHF RX
(receiver) module and acts when it
receives a valid code. The arrival,
departure and non-directional signal
codes are all different, so that IC1 can
discriminate between them.
IC1 also monitors trimpot VR1 at
its GP4 input. This is the identity adjustment that is divided up into eight
separate voltage bands. This voltage
needs to match that set in the detector unit before any received signal is
deemed valid.
Trimpot VR2 has its wiper monitored by IC1’s GP2 input (pin 5).
This trimpot sets the alert duration.
Alternatively, it sets the time period
between relay 1 closing and relay 2
closing (and thus the period for which
a remote-controlled mains socket is
powered on).
In operation, IC1 converts the
voltages at GP4 and GP2 to 8-bit digital
values. When a valid signal is received,
its GP0 and GP1 outputs drive either
the piezo transducer and one of the
LEDs (LED1 or LED2) or relays Relay1
and Relay2. If used, the latter are wired
across the On and Off switch contacts
on the hand-held remote that’s used
with a remote-controlled mains socket.
Piezo transducer
The exit (or departure) tone from the
piezo transducer is a 440Hz horn-type
“bip” lasting about 1s, followed by a
440Hz tone that smoothly increases
to 6.8kHz over a period ranging from
1-5s (depending on the setting of VR2).
LED1 (exit) also lights while ever the
piezo sounds and stays lit for about
15s after the tone ceases.
By contrast, the entry (or arrival)
tone starts with a 1s 440Hz horn “bip”
and is followed by a 6.8kHz tone that
decreases to 440Hz (again adjustable
siliconchip.com.au
D3 1N4004
REG1 78L05
+5V
OUT
100nF
K
IN
GND
100 µF
4
2
DATA
GP0
GP5
PIEZO
TRANSDUCER
100Ω
1
Vdd
MCLR
+12V
7
RELAY 1
3
GP4
GP2
VR2
10k
5
Vss
8
IDENTITY
ENTRY
LED2
ALERT
DURATION
A
λ
K
A
100Ω
λ LED1
K
D3 1N4004
A
A
K
THESE PARTS
USED ONLY
FOR AUDIBLE
& VISUAL
INDICATION
D2
1k
OFF
A
433MHz Rx MODULE
K
78L05
LEDS
SC
DRIVEWAY MONITOR RECEIVER
RELAY 2
K
TP1
D1, D2: 1N4148
ON
D1
EXIT
GND
K
A
IN
OUT
Vcc
DATA
DATA
GND
6
IC1
PIC12F675 GP1
VR1
10k
20 1 5
0V
THESE PARTS USED ONLY FOR
RELAY SWITCHED OUTPUTS
K
GND
A
CON1
16V
ANT
GND
GND
Vcc
ANT
433MHz
RX
MODULE
+12V
IN
100 µF
1k
Vcc
A
Fig.11: the circuit diagram for the receiver circuit. The 433MHz RX (receiver) module picks up the signal from the
detector unit and feeds its data output to PIC microcontroller IC1. When a valid code is received, IC1 drives a piezo
transducer & activates either LED1 or LED2 to indicate vehicle entry or exit. Alternatively, the LEDs & piezo transducer
can be omitted and reed relays fitted instead. These can then be wired across the buttons of a remote control unit, eg,
for a remote-controlled mains socket or a wireless doorbell.
from 1-5s). This makes it quite distinct
from the exit sound, since the tone
now decreases instead of increasing. In
addition, the entry LED (LED2) lights
during the tone and again stays lit for
15s after the tone ceases.
The non-directional tone is different yet again. In this case, there is a
1s 440Hz horn “bip” followed by a
further 440Hz “bip” lasting from 1-5s.
In addition, LED1 & LED2 both light
and then flash alternately for 15s after
the tone ceases.
Relay version
For the relay version, Relay1 is first
switched on for 500ms, thereby allowing its closed contacts to activate the
“On” button on a UHF remote control
(eg, for a mains socket). Then, after
a preset period ranging from 20s to
five minutes as set by VR2, Relay2 is
switched on for 500ms to activate the
“Off” button on the UHF remote.
Both relays are driven via 100Ω
resistors, while diodes D1 & D2 clamp
any switch-off voltage spikes produced by the relay coils. The 100Ω
resistors are there to protect IC1’s GP0
& GP1 outputs.
siliconchip.com.au
The receiver PCB can be built in two
versions (relay version shown here). See
Pt.2 next month for the assembly details.
The program in IC1 automatically
detects if the piezo transducer has
been installed or if the relays have
been installed instead. It does this
by first making the GP1 pin an input
and then switching GP0 high. If GP1
goes high immediately after switching
GP0 high, then the piezo transducer is
connected. That’s because the piezo
transducer’s capacitance allows the
voltage transition to be coupled
through to GP1.
Conversely, if GP1 stays low, the
software assumes that the relays are
connected since Relay2’s coil provides
a low resistance path to ground.
Power for the circuit is derived from
a 12V DC plugpack, with diode D1
providing reverse polarity protection.
REG1 then provides a regulated 5V supply for IC1 and the UHF RX module.
The 100µF input and output bypass
capacitors provide supply line filtering, while a 100nF capacitor provides
additional decoupling for the supply
going to the microcontroller.
That’s all for this month. Pt.2 next
SC
month has the assembly details.
July 2015 35
|