This is only a preview of the February 2020 issue of Practical Electronics. You can view 0 of the 80 pages in the full issue. Articles in this series:
|
Motion-Triggered
12V Switch
This simple circuit switches on a 12V circuit
when it detects acceleration or vibration. It has
many uses, but it’s especially handy if you have an
always-on car accessory power socket. These are becoming
quite common but they make it tricky to use a standard dashcam or GPS.
This project solves that problem and it can be built in a couple of hours.
T
his solves a problem that
shouldn’t exist – but it does, and
it’s really annoying. While it has
many different potential uses, I designed it specifically to switch a dashmounted video camera (‘dashcam’) on
automatically when you start driving
the car, then off again when you stop.
But, you are wondering, don’t
dashcams already do that? Aren’t they
powered on and off automatically as
the accessory socket switches on and
off with the vehicle ignition? Of course
they are… in most cases.
The problem
But for whatever reason, the accessory
power socket (‘cigarette lighter’) in my
wife’s car does not switch on and off
with the ignition. Since it’s always
on, after driving, her dashcam runs
until the car’s battery is almost flat,
at which point the accessory power
socket shuts off.
As if that wasn’t annoying enough,
when (if!) you start the car the next
time, it doesn’t come back on automatically – very frustrating.
by Nicholas Vinen
You have to remember to unplug
and re-plug the dashcam to get it to go
on. Somehow, I doubt we are the only
people with this problem.
Obviously, this is not very satisfactory. I guess the power socket remains
on so you can charge your phone (or
run other accessories) with the ignition
off. But I think this ‘feature’ causes
more problems than it solves.
And while the socket is no doubt under the control of the body computer, I
can’t find any way to set it back to the
old-fashioned scheme – which worked
fine, thank you very much. There’s no
obvious physical or software switch
to do so.
Hence, I had to come up with this
project as a way to switch the dashcam on and off automatically, while
drawing very little power when it is
off, so the vehicle’s battery still has
a reasonable charge after sitting for
a few days.
The solution
The obvious solution was to sense
when the car is running via the battery
voltage. But another ‘feature’ of this
otherwise fine vehicle is that it doesn’t
always charge the battery while running, So I had to find another way.
My next idea was to have an accelerometer that’s monitored by a lowpower microcontroller, waiting for the
vehicle to move before switching on
power to the dashcam.
It could then leave the power on as
long as the vehicle was in motion (with
a timer, so it doesn’t go off when you’re
stationary for a couple of minutes at
a time), and switch it off at the end
of the trip.
But I realised that I was over-complicating matters. There is a much simpler
solution – using a vibration switch.
These small, low-cost devices consist
of a spring surrounding a metal post
inside a can. At rest, the spring doesn’t
touch the post; but any movement or
vibration causes it to come into contact,
closing the switch contacts. Less sensitive versions use stiffer springs.
It’s a problem that shouldn’t exist; but it does if your cigarette lighter socket doesn’t power off when the ignition is off!
26
Practical Electronics | February | 2020
Q2 IRF4 9 05
S
CON1
S1
S2
100 µF
LL
ZD1
15V
10M
+
12V
IN
820k
–
E
820k
CON2
+
10k
Q1
BC547
LL: LOW LEAKAGE
12V
OUT
LED1
B
K
–
BC547
ZD1
A
G
A
C
B
100nF
D
K
G
E
C
D
D
S
Fig.1 (left): the circuit diagram for
the version of the circuit which uses
a P-channel MOSFET (Q2). It has the
advantage that the incoming and outgoing
ground connections are continuous – power
is interrupted on the positive side only.
Vibration or motion causes S1 to discharge
the 100µF capacitor, which switches on Q1
and then Q2 and gives a five-minute time
delay before they switch off again if S1 is
not triggered in the meantime.
IRF4905
Motion
Sensing
12V Switch
(P-channel)
SC MOTION
SENSING
12V SWITCH
(P-CH)
2019
100nF
CON1
Fig.2 (right): this version of the circuit
uses an N-channel MOSFET for Q2
instead. If you compare it to Fig.1, you
can see that the changes essentially
involve flipping everything upside-down
to deal with the different gate drive
polarity requirement of this MOSFET.
Otherwise, it works the same, except
for the fact that it breaks the ground
connection between the input and output
side to switch the connected device(s) off.
So it’s just a matter of using that
switch to trigger a separate device to
switch 12V power to the dashcam,
and adding a timer to delay switch-off.
The design presented here uses
just nine (mandatory) components,
plus the accessory plug and socket,
to achieve that. That’s certainly a lot
simpler than the accelerometer-based
solution would have been!
I set the time-out period to about five
minutes. Even in the worst traffic, you
usually are not stationary for that long.
Circuit description
Refer now to the circuit diagram
shown in Fig.1. This uses a P-channel
MOSFET as the switch (Q2) so that
it’s the +12V line which is switched.
The ground connection is unbroken.
This may be important in some cases,
where your dashcam might connect
elsewhere in the vehicle and could
have a separate ground connection to
the chassis.
In that case, switching the negative
end of the power supply wouldn’t do
anything useful.
The 100µF capacitor provides the
five-minute delay, in combination
with the two 820kresistors between
its negative end and ground. Initially,
when power is applied, the 100µF
capacitor is discharged. That means
that current flows through it and the
upper 820kresistor, to the base of
NPN transistor Q1, as it charges.
Practical Electronics | February | 2020
820k
12V
IN
10k
E
+
Q1
BC557
B
820k
+
C
LED1
K
–
S1
S2
100 µF
LL
ZD1
15V
10M
G
12V
OUT
–
A
D
BC557
ZD1
B
K
Q2
IRF540N
S
LL: LOW LEAKAGE
A
CON2
E
G
C
D
D
S
IRF540
SC MOTION
Motion
Sensing
12V 12V
Switch
(N-channel)
SENSING
SWITCH
(N-CH)
2019
Q1 therefore switches on, pulling
the gate of MOSFET Q2 low, close to
0V. As a result, Q2’s channel conducts
current from the 12V positive input
to the 12V positive output, powering
the dashcam.
The 100µF capacitor charges, and
after about five minutes the base of
Q1 drops below about 0.5V. Q1 then
begins to switch off, allowing the gate
of Q2 to be pulled up to +12V by the
10Mresistor, switching Q2 off.
The reason we do not have the
capacitor directly on the gate of Q2 is
because that would cause Q2 to switch
off slowly, over about 30 seconds, due
to the slow charging rate of that capacitor. During this time, the MOSFET
would be in partial conduction and
so it would have a high dissipation,
The heart of the project is one of these
tiny vibration switches, shown with a
$2 coin for size reference (approx same
size as a UK £1 coin). On the left is the
Soyo SW-1801P from Pakronics; on the
right is the CM1800-1 from element14.
(See parts list for UK alternatives.)
heating up and possibly burning out.
Since Q1 is a bipolar junction transistor, and its load impedance is so high,
it only takes a few millivolts of change
in its base voltage to go from fully on
to fully off. That, in turn, allows Q2 to
switch off fast, typically spending less
than one second in partial conduction,
so it doesn’t heat up too much during
switch-off.
The 100µF capacitor needs to be a
low-leakage type due to the high charging impedance of 820k + 820k=
1.64M. Otherwise, it will never fully
charge and so Q2 may never switch off.
Alternatively, you can use two 47µF
tantalum capacitors in parallel (as we
did on our prototype) although a lowleakage electrolytic may be cheaper.
ZD1 protects the gate of Q2 from
excessive voltages, which may be due
to power-supply spikes in the system.
It clamps the gate to around +16V and
−1V, well within its ±20V rating.
The current through ZD1 is limited
by the relatively high base impedance
of Q1. The maximum base current
with a 14.4V supply is (14.4V − 0.5V)
÷ 820k = 17µA. The highest beta for
a BC547 is around 800 at 2mA, but it’s
less than half that at very low currents,
so the maximum figure is around 400.
That translates into a collector current
of no more than 17µA × 400 = 6.8mA.
That’s more than enough current
to pull the gate of Q2 to 0V, but low
enough that neither Q1 nor ZD1 will
27
820k
+
100 µF
S1
CUT HERE
Q2
10k
CUT HERE
Note: view of both boards is from the top
(component) side, just like PCB layouts.
The copper strips are on the underside of the
board, as if you were looking through the board
with x-ray vision.
100 µF
12V
IN
S1
CUT HERE
LED1
+
820k
820k
Q1 100nF
Q2
10k
12V
OUT
10M
ZD1
12V
IN
LED1
Q1 820k
10M
ZD1
100nF
12V
OUT
Fig.3: above, a guide to building the P-channel version on
a piece of stripboard. Note the two locations where the
tracks are broken, with a knife or drill. Ensure you avoid
the possibility of component leads or exposed metal tabs
shorting each other if components are moved slightly.
Fig.4: this is the stripboard layout for the N-channel
version of the circuit. As with the circuit diagram, this is
basically just a flipped version of Fig.3 to compensate for
the difference in behaviour between an N-channel and
P-channel MOSFET.
be damaged if the supply voltage is high enough for ZD1 to
conduct. Even if the supply voltage is considerably higher
(which it would need to be, for ZD1 to conduct), nothing
is going to burn out.
The 100nF capacitor between the base and emitter of Q1
is important because the supply voltage in a vehicle can
vary a great deal, from around 10V when cranking up to
around 14.4V when the battery is being charged. And there
can also be a great deal of noise and some significant voltage
spikes on the supply line. This 100nF capacitor prevents
supply spikes from causing Q1 to switch off briefly, which
would cut power to the dashcam.
high-current N-channel MOSFET. You may even have one
lying around somewhere.
But keep in mind that it interrupts the negative power
connection, rather than the positive connection, meaning
you can only really use it to switch devices which do not
connect to any other powered devices (unless they get their
power from the same socket).
As there are so few components in this circuit, I built mine
on stripboard (‘Veroboard’) and you could do the same. The
stripboard component layouts are shown in Figs.3 and 4.
Optional components
Pushbutton switch S2 is shown wired across the vibration
switch, as a manual means of forcing the unit to switch
on. But you will notice that we have left it out of our PCB
designs. That’s because merely bumping the PCB is enough
to switch the unit on; so it would probably come on even
before you could press S2. So while it makes sense in
theory, in practice, you don’t need it.
LED1 and its 10kcurrent-limiting resistor are wired
across the output so you can easily see if the unit’s output
is switched on. This only adds about 1mA to the current
consumption when the unit is on. It’s handy for debugging
and testing, but you don’t need it, so you could leave it
off your version.
By the way, the circuit draws almost no power when off
– basically just the leakage current of the 100µF capacitor,
which is usually around 1µA. So it will not affect your
vehicle’s battery life.
The vehicle itself will typically draw around 10mA,
plus another 10mA or so of battery self-discharge, for a
total of around 20mA, which is 20,000 times more than
this circuit draws.
Construction
One critical aspect of construction is to note that one of
the leads of the vibration sensor may be extremely thin
and easy to break.
It depends on exactly which sensor you use; we used a
very common type (SW-18010P) and managed to break one
lead while testing it. Interestingly, the other lead is really
thick and presumably intended to allow it to be rigidly
mounted to the board.
The layout for the P-channel version is shown in Fig.3,
with the layout for the N-channel version in Fig.4. As with
the circuits, they are almost a mirror-image of each other.
47 F 47F
47F
47 F
Fig.5: the PCB overlay for
Q2
the SMD version of Fig.1 –
10k
ZD1 Q1
the P-channel version of the
LED1 12V
12V
10M
K OUT
circuit. It is slightly taller
IN
820k
SAIA
but it is narrower and much
100nF
SW-18010P
S1
thinner, so it should give a
more compact result. MOSFET
Q2 is in an 8-pin SOIC package which is easy to solder, as
are all the other components. Note the two 47µF capacitors
connected in parallel, which are used instead of a single
100µF capacitor which would be larger.
820k
Alternative versions
Fig.2 shows how you can build the circuit using an Nchannel MOSFET instead of a P-channel MOSFET. Essentially, everything is inverted. Q1 changes from an NPN
transistor to a PNP transistor. All the other parts are the
same, just connected differently. You might want to build
this version just because it’s easier and cheaper to get a
SMD PCB version
However, many people don’t like stripboard (to be honest,
I’m normally one of them!), so I also designed a small PCB
for the P-channel version only. The PCB, coded 05102191,
is 25.4 x 19.5mm and available from the PE PCB Service
This uses SMD parts (see Fig.5) so has the advantage of
being much shorter and thinner, at just 25 × 20 × 5mm. It’s
therefore suitable for encapsulation in a smaller (~16mm
diameter) piece of heatshrink tubing, making it easy to
tuck away.
The only through-hole part used is the vibration sensor
itself, S1. This is laid on its side and held down to the board
using a couple of wire straps to keep everything nice and
rigid, minimising the overall size of the module.
The only difference in the circuit is that we’ve used two
parallel 47µF 16V SMD ceramic capacitors rather than a
single 100µF electrolytic, as 100µF 16V SMD capacitors
tend to be larger and more expensive. In addition to being
compact, ceramic capacitors are very reliable and more
heat-tolerant compared to electrolytics.
We won’t go into any great details regarding the assembly
of the SMD version, although we have an alternative SMD
parts list at right.
This photo is taken from the opposite side of the stripboard
than the diagram above (ie, output on left and input on
right) to more clearly show the smaller components which
could be otherwise hidden.
28
Practical Electronics | February | 2020
Both designs require tracks to be cut in two places; the
cuts are shown on either side of Q2. Look closely at Fig.3
and Fig.4; the breaks are shown but they are visually subtle.
You can make these cuts with a sharp knife but make sure
you remove a fair bit of copper so they can’t accidentally
come in contact.
Some people prefer to use a ~4mm drill turned by hand
but it needs to be sharp or it will not cut the copper. It
probably wouldn’t hurt if you actually drilled through the
board but might weaken it slightly.
Having made the two track cuts, fit the components.
The axial components (resistors and zener diodes) are all
mounted with their leads 0.2-inch or 5.08mm apart, so
they will need to have their leads bent so that they sit on
the board in a semi-vertical position.
You have a choice of which side to place the component
body; try to orient them to avoid the possibility of component leads shorting together.
Make sure that the cathode stripe of ZD1 faces in the
correct direction, as shown in Fig.3 and Fig.4.
The radial components (electrolytic capacitor, sensor,
LED) have their leads soldered to adjacent tracks, 0.1-inch
or 2.54mm apart, and this should be the natural pin spacing
of these parts, making it easy.
Watch the orientation of the electrolytic capacitor; its
positive lead is longer and should be located where shown
with the + symbol in Fig.3 or Fig.4.
Similarly, you will probably not need to bend the leads
of Q1 or Q2 as they will likely already have the requisite
0.1-inch spacing. Watch the orientation of both parts.
The orientation of the vibration sensor doesn’t matter
since it just acts as a switch.
Wiring it up
With all the components on the board, now you just need
to wire up the plug and socket.
At this stage you can simply purchase a vehicle accessory (cigarette lighter) plug and socket separately, or use
something like Jaycar’s ‘cigarette lighter double adaptor’
(Cat PP2006).
I did the latter opened up the plug (undoing one screw
and unscrewing the tip), removed the contacts, de-soldered
the wires and pulled them through the strain-relief boot.
That gave me two pre-wired sockets plus a plug, which I
put aside since I already had a pre-wired accessory plug
(eg, Jaycar Cat PP1995).
The PP1995 plug wires went straight into the stripboard
holes and I soldered them to the tracks, although I found
I had to add some flux paste as I had difficulty getting the
wires to take solder. I had to drill the board holes for the
socket wires out to 1.5mm. After pushing the wires through
the holes, I bent them over to come in contact with the
copper strips and soldered them in place.
Testing
Ideally, testing should be done with a current-limited 12V
DC supply in case there is a short circuit on the board, or
one component has been installed incorrectly.
This can easily be achieved by connecting a 1005W
or 2201W resistor in series with the supply. You can
monitor the voltage across this resistor to get an idea of
the circuit’s current draw.
You can connect the supply to the cigarette lighter plug
using a couple of alligator clip leads.
LED1 should light up immediately and you should get
a reading of around 0.1-0.2V across the resistor due to the
1mA used to light it. Leave the board alone for about five
minutes, being careful not to touch or bump it, and LED1
should go out and the voltage across the safety resistor
Practical Electronics | February | 2020
Parts list –
12V movement/vibration switch
P-channel version on strip board
1 piece of stripboard/Veroboard, five strips x 14 holes
1 Soyo SW-18010P vibration sensor, or similar (S1)
1 car accessory power extension cable, length to suit
(cut in half to get cables with plug and socket on ends)
Short lengths of various diameter heatshrink tubing
Semiconductors
1 BC547 NPN transistor (Q1)
1 IRF4905 P-channel MOSFET or equivalent (Q2)
1 blue 3mm LED (LED1
1 15V 0.4W or 1W zener diode (ZD1)
Capacitors
1 100µF 16V/25V low-leakage electrolytic or
2 47µF 16V tantalum
1 100nF ceramic
Resistors (all 0.25W, 1% or 5%)
1 10M (brown black green brown or brown black black yellow brown)
2 820k (grey red yellow brown or grey red black range brown)
1 10k (brown black orange brown or brown black black red brown)
Parts substitutions for N-channel version
1 BC557 PNP transistor (Q1)
1 IRF540N N-channel MOSFET or equivalent (Q2)
Parts for SMD version on PCB
1 double-sided PCB, coded 05102191, 25.4 x 19.5mm
available from the PE PCB Service
1 Soyo SW-18010P vibration sensor, or similar (S1)
1 car accessory power extension cable
Semiconductors
1 AO4421 P-channel MOSFET or equivalent, SOIC-8 (Q1)
1 BC847 NPN transistor, SOT-32 (Q2)
1 blue 3216/1206 LED (LED1)
1 15V 0.25W zener diode, SOT-23 (ZD1)
Capacitors
2 47µF 16V X5R ceramic, SMD 3226/1210 package
1 100nF 50V X7R ceramic, SMD 3216/1206 package
Resistors (all SMD 3216/1206 package, 1%)
1 10M
2 820k
1 10k
Where to get the vibration sensor:
Pakronics (www.pakronics.com.au) have two vibration
sensors in stock: the recommended Soyo SW-1801 P (Cat
ADA1766), described as ‘easy to trigger’, plus a ‘hard to
trigger’ (ie, less sensitive) Cat ADA 1767.
Alternatively, element14 (au.element14.com) has a range of
slightly different ‘Comus’ vibration switches (Cat 607253 and
540626) which could also be used in this project.’.
(These sensors are the ones in the photo at the bottom of the
article’s second page – the Soyo SW-18010P on the left and the
Comus [element14] on the right.)
Cheap sensors are currently avaible from Amazon.co.uk –
search for: ‘sourcing map SW-18010 High Sensitivity Spring
Electronic Vibration Sensor Switch 30Pcs’. At the time of
writing, just go to: http://bit.ly/pe-feb20-sense where there
is a good choice. Note that the SW-18015P and SW-18020P
versions are probably too insensitive to be useful
should drop to no more than a few millivolts. When LED1
goes out, give the board a tap. The LED should switch back
on. If it does, everything looks good.
If LED1 doesn’t go out, or it doesn’t go back one when
you tap the board, check it carefully for short circuits. It’s
29
Unfortunately we didn’t have any clear heatshrink large
enough – so red had to do! If there is any danger of any
component being shorted (remember there’s lots of movement
under a dashboard) we’d also be inclined to crimp the edges
of the heatshrink together before shrinking it.
JTAG Connector Plugs Directly into PCB!!
No Header!
No Brainer!
Our patented range of Plug-of-Nails™ spring-pin cables plug directly
into a tiny footprint of pads and locating holes in your PCB, eliminating
the need for a mating header. Save Cost & Space on Every PCB!!
Solutions for: PIC . dsPIC . ARM . MSP430 . Atmel . Generic JTAG . Altera
Xilinx . BDM . C2000 . SPY-BI-WIRE . SPI / IIC . Altium Mini-HDMI . & More
www.PlugOfNails.com
Tag-Connector footprints as small as 0.02 sq. inch (0.13 sq cm)
ESR Electronic Components Ltd
All of our stock is RoHS compliant and CE
approved. Visit our well stocked shop for
all of your requirements or order on-line.
We can help and advise with your enquiry,
from design to construction.
3D Printing • Cable • CCTV • Connectors • Components •
Enclosures • Fans • Fuses • Hardware • Lamps • LED’s •
Leads • Loudspeakers • Panel Meters • PCB Production •
Power Supplies • Relays • Resistors • Semiconductors •
Soldering Irons • Switches • Test Equipment • Transformers
and so much more…
Monday to Friday 08:30 - 17.00, Saturday 08:30 - 15:30
Station Road
Cullercoats
North Shields
Tyne & Wear
NE30 4PQ
Tel: 0191 2514363 sales<at>esr.co.uk www.esr.co.uk
30
easy to accidentally short adjacent tracks on stripboard. It
could also be due to a leaky electrolytic capacitor.
Use a DMM set to measure ohms and probe adjacent
tracks. If you get a reading lower than 10Ω, chances are
you have a short circuit.
Also check your component placement and orientation,
using Fig.3 or Fig.4 as a reference.
If it’s working, remove the safety resistor and power the
circuit directly from 12V. Measure the voltage at the socket.
You should get a reading of +12V with the red probe touching the small contact area inside the base of the socket and
the black probe on the inner metal surround.
You can then try plugging a vehicle accessory such as a
dashcam or GPS into the socket and check that it powers
up correctly.
Finishing it off
Assuming all is well, disconnect everything and add some
heatshrink insulation. It’s a good idea to slip some tubing
over the TO-220 package and shrink it down to ensure it
can’t short against any adjacent components. Do the same
with any other components you think could short if they
move or are bent.
Then slide larger diameter clear heatshrink tubing over
the cigarette lighter plug and onto the board and shrink it
down, so it can’t short against any exposed metal that may
be in the vehicle, or loose items like keys.
Installing it in the vehicle is simple. Just plug it into the
accessory socket, plug in your dashcam, GPS or whatever,
then find somewhere to tuck the circuit board away. It would
be a good idea (at least initially) to put it somewhere where
you can observe LED1, ideally from outside the vehicle,
through a window.
Leave it for 5-10 minutes, somewhere where the vehicle
is not going to be rocked by vehicles passing at high speeds
(eg, trucks).
Then check to see if LED1 has gone out. If it has, open the
door and get in. The motion from doing so will probably
trigger the unit and switch LED1 back on. Otherwise, give
the board a little nudge and check that it switches back on.
You may find the unit is too sensitive; perhaps passing
traffic often triggers it. In this case, you have two main options. The easiest is to add some cushioning around it like
foam, to reduce the amount of movement and vibration
transferred to it, reducing its sensitivity. You will need
to experiment with the type and thickness of material to
achieve a good result.
If that’s no good, you will have to remove the vibration
sensor and fit a less sensitive version. We’ve found that they
are usually too sensitive, so you’re better off with the foam.
Reproduced by arrangement with
SILICON CHIP magazine 2020.
www.siliconchip.com.au
Practical Electronics | February | 2020
|