This is only a preview of the February 2019 issue of Silicon Chip. You can view 47 of the 112 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 "Versatile Trailing Edge Dimmer with Touch Plate & IR ":
Items relevant to "El Cheapo Modules 22: Stepper Motor Drivers":
Items relevant to "Motion-sensing 12V Power Switch":
Items relevant to "USB Mouse and Keyboard Interface for Micros":
Items relevant to "Build-it-yourself DAB+/FM/AM radio":
Purchase a printed copy of this issue for $10.00. |
Motion-Triggered
12V Switch
This simple circuit switches on a 12V circuit
when it detects acceleration or vibration. It has
many possible 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 rather difficult
to use a standard dashcam or GPS. This project solves that problem
and it can be built in a couple of hours.
by Nicholas Vinen
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
dash-mounted 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.
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
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!
48
Silicon Chip
Australia’s electronics magazine
siliconchip.com.au
Q2 IRF4 9 05
S
CON1
S1
S2
100 µF
LL
ZD1
15V
10M
+
12V
IN
820k
–
E
820k
SC
2019
+
12V
OUT
–
LED1
BC547
ZD1
B
K
CON2
10k
Q1
BC547
LL: LOW LEAKAGE
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 cause S1 to discharge
the 100uF 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-CH)
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.
12V
IN
10k
E
Q1
BC557
B
820k
S2
100 µF
LL
ZD1
15V
10M
12V
OUT
–
A
D
BC557
ZD1
B
K
Q2
IRF540N
G
S
LL: LOW LEAKAGE
A
LED1
K
S1
CON2
+
C
–
SC
siliconchip.com.au
820k
+
2019
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.
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.
100nF
CON1
E
G
C
D
D
S
IRF540
MOTION SENSING 12V SWITCH (N-CH)
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 heart of the project is one of these
tiny vibration switches, shown with
a $2 coin for a size reference (and
they don’t cost much more than $2
anyway!) On the left is the Soyo SW1801P from Pakronics; on the right is
the CM1800-1 from element14.
Australia’s electronics magazine
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.
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.
As the 100µF capacitor charges, 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 caFebruary 2019 49
820k
+
100 µF
S1
CUT HERE
10k
Q2
NOTE: VIEW OF BOTH BOARDS IS FROM
THE TOP (COMPONENT) SIDE, AS WE NORMALLY
SHOW WITH 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
LED1
+
820k
820k
CUT HERE
CUT HERE
S1
Q1 100nF
Q2
10k
12V
OUT
10M
ZD1
12V
IN
LED1
Q1 820k
10M
ZD1
100nF
12V
OUT
Fig.3: use this diagram as a guide to building the P-channel
version of the circuit on a piece of stripboard. Note
carefully the two locations where the tracks are broken,
with a knife or drill. Watch out to avoid the possibility of
component leads or exposed metal tabs shorting to each
other if the 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.
pacitor directly on the gate of Q2 is that 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, 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 low-leakage electrolytic will probably 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 x 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 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 since 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.
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.
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
12V
IN
820k
47F
47
F 47F
47 F
10M
SAIA
SW-18010P
S1
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.
50
Silicon Chip
Q2
ZD1 Q1
10k
LED1 12V
K
OUT
820k
100nF
Fig.5: the PCB overlay for the SMD version of Fig.1, the
P-channel version of the circuit. It is slightly taller but it
is narrower and much 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.
Australia’s electronics magazine
siliconchip.com.au
easier and cheaper to get a 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 (or “Veroboard”) and you could do
the same. The stripboard component layouts are shown
in Figs.3 and 4.
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.
This uses SMD parts (see Fig.5) so has the advantage of
being much shorter and thinner, at just 25 x 20 x 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 heattolerant 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.
If you want to build this version, you can purchase the
short form kit (which includes the PCB and all on-board
parts) from our online shop (Cat SC4851). Solder them in
place where shown in Fig.5.
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 that I built 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.
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.
siliconchip.com.au
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
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 SMD short-form kit:
(Includes PCB and all on-board parts): Cat SC4851 from the
SILICON CHIP ONLINE SHOP (siliconchip.com.au/shop)
Where to get the vibration sensor:
The SILICON CHIP ONLINE SHOP stocks the SW-18010P for $1
each (Cat SC4852). Our standard $10 p&p charge per order
applies – it pays to order several things at once!
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. Both are priced at
$3.36 plus GST and freight.
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. Both are priced at $4.06 plus GST and freight.
(These sensors are the ones in the photo on page 49 – the Soyo
SW-18010P on the left and the Comus [element14] on the right.)
Australia’s electronics magazine
February 2019 51
The axial components (reshould go out and the voltsistors and zener diodes) are
age across the safety resistor
all mounted with their leads
should drop to no more than
0.2” or 5.08mm apart, so they
a few millivolts.
will need to have their leads
When LED1 goes out, give
bent so that they sit on the
the board a tap. The LED
board in a semi-vertical poshould switch back on. If it
sition.
does, everything looks good.
You have a choice of which
If LED1 doesn’t go out, or
side to place the component Unfortunately we didn’t have any clear heatshrink large
it doesn’t go back one when
body; try to orientate them enough – so red had to do! If there is any danger of any
you tap the board, check it
to avoid the possibility of component being shorted (remember there’s lots of movement carefully for short circuits.
component leads shorting to- under a dashboard) we’d also be inclined to crimp the edges It’s easy to accidentally short
of the heatshrink together before shrinking it.
gether.
adjacent tracks on stripboard.
Make sure that the cathode stripe of ZD1 faces in the It could also be due to a leaky electrolytic capacitor.
correct direction, as shown in Fig.3 and Fig.4.
Use a DMM set to measure ohms and probe adjacent
The radial components (electrolytic capacitor, sensor, tracks. If you get a reading lower than 10W, chances are
LED) have their leads soldered to adjacent tracks, 0.1” or you have a short circuit.
2.54mm apart, and this should be the natural pin spacing
Also check your component placement and orientation,
of these parts, making it easy.
using Fig.3 or Fig.4 as a reference.
Watch the orientation of the electrolytic capacitor; its
If it’s working, remove the safety resistor and power the
positive lead is longer and should be located where shown circuit directly from 12V. Measure the voltage at the socket.
with the + symbol in Fig.3 or Fig.4.
You should get a reading of +12V with the red probe touchSimilarly, you will probably not need to bend the leads ing the small contact area inside the base of the socket and
of Q1 or Q2 as they will likely already have the requisite the black probe on the inner metal surround.
0.1-inch spacing. Watch the orientation of both parts.
You can then try plugging a vehicle accessory such as
The orientation of the vibration sensor doesn’t matter dashcam or GPS into the socket and check that it powers
since it just acts as a switch.
up correctly.
Wiring it up
Finishing it off
With all the components on the board, now you just need
to wire up the plug and socket.
Rather than purchase a vehicle accessory (cigarette lighter) plug and socket separately, I bought a Jaycar Cat PP2006
“cigarette lighter double adaptor”.
I then simply 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
(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 so after pushing the wires
through the holes, I bent them over to come in contact with
the copper strips and soldered them in place.
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, trucks, etc.
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, eg, 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.
But we’ve found that they are usually too insensitive so
SC
you’re better off with the foam.
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. If you leave board alone for about
five minutes, being careful not to touch or bump it, LED1
52
Silicon Chip
Australia’s electronics magazine
siliconchip.com.au
|