This is only a preview of the November 2011 issue of Silicon Chip. You can view 26 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "Build A G-Force Meter":
Items relevant to "The MiniMaximite Computer":
Items relevant to "Ultra-LD Stereo Preamplifier & Input Selector, Pt.1":
Items relevant to "2.2-100V Zener Diode Tester":
|
For when you need to know...
G-FORCE METER
Just what are the g forces involved in a balls-to-the-wall lap of Mt
Panorama? This little beauty will tell you: instantaneous acceleration,
braking, cornering; forwards, backwards, sideways . . . and it’s battery
operated and completely portable, so you can swap it from car to car!
W
hy would you want a g-force
meter in your car? Good
question. This project comes
about because as soon as we published
the Digital Spirit Level (August 2011)
we had a number of readers contact us
to ask “Can this be used as a g-force
meter?”. Your wish is our command!
We know they are fitted to some
high-performance vehicles, such as the
Nissan GTR, showing the instantaneous acceleration, braking and cornering forces.
These can be used to gauge vehicle and/or driver performance. The
faster the car accelerates or corners,
the higher the g-force. Ditto for braking – is the driver putting the vehicle
under too much stress by braking too
late or too hard?
And what about the driver him/herself? Throwing the car around a corner
might look pretty spectacular but it’s
also pretty stressful on the driver (not
to mention the car!).
Of course, you’re unlikely to do a
hot lap around Bathurst. But the g force
meter can just as easily be used to save
petrol and wear & tear and/or temper
youthful exuberance by making your
driving as smooth as possible.
G-force meters, more properly called
accelerometers, measure force in a
particular direction. If your car doesn’t
have one of these (and let’s face it, you
probably don’t think it does), now you
can easily add one!
Actually you might be surprised to
find out that most modern cars do contain one or more accelerometers. For
example, air-bag systems use them to
detect accident severity and so decide
whether to inflate the air-bags and if
so, how fast.
The engine or body computer may
also contain an accelerometer to detect
when the vehicle is on a hill, in order to
change how the transmission or engine
behaves. But in most cases, there’s no
display to show you the readings – nor
Design by Andrew Levido
28 Silicon Chip
is there any way to capture the data.
Apart from automotive use, there
are many other places where g force
measurement would be handy. For
example – a powerboat crashing over
waves: you know you can really get
thrown around . . . but just how much?
Or perhaps one of those heart-inyour-mouth thrill rides at theme parks
and shows. Just what are the forces
involved? (Actually you might be surprised at how low many of them are!)
But if you’ve ever tried to buy a
commercial g-force meter (or accellerometer) you would know that for
most people, they have been basically
unaffordable. We’ve changed that with
this little beauty!
On the level? Yes!
So this project is an adaptation of
the Digital Spirit Level which was
published in our August 2011 issue.
In fact, it uses the same MMA8451Q
accelerometer IC and shares virtually
Words by Nicholas Vinen
siliconchip.com.au
all of the hardware with that project.
But the software has been changed
so that, rather than reading out a tilt
angle in degrees, it shows the forward/
back or left/right acceleration in units
relative to the earth’s gravity (1g =
9.81N = 9.81m/s2).
The new software places the
MMA8451Q in a mode where it can
make rapid readings but the range is
limited from -2g to +2g for each axis.
Why not a greater range? Simple:
if your vehicle experiences forces in
excess of 2g, the limited range of the
readout will be the least of your worries; such high g forces are usually
only experienced during a prang (and
a pretty bad one at that!).
For instance, the Bugatti Veyron,
which is the world’s fastest production car (top speed on the up side of
400km/h), can accelerate from a standing start to 100km/h in 2.4s. Measured
maximum g-force? 1.55g.
Readings
At this point we should explain just
what the readings on the Acceleromsiliconchip.com.au
eter display mean. Firstly, the reading
indicates the experienced force which
doesn’t necessarily match the actual
vehicle acceleration.
Say you are in a car accelerating at
full throttle. Depending on how powerful the engine is (and how much the
vehicle weighs), you will experience a
sensation of being pressed back into the
seat. This is due to Newton’s third law
of motion: “For every action there is an
equal and opposite reaction”. In this
case the action is the car accelerating
forwards and the reaction is you being
pressing back into the seat.
Now consider the same car, parked
facing up a hill. You will experience
a similar sensation. In this case, it is
the force of gravity pushing you back
into the seat.
In these situations, the accelerometer will experience the same forces
you do. So in both cases, it will report
a “forward acceleration” - despite the
fact that in the second example, the
car isn’t moving.
So why didn’t we make it read zero
in the second case? Firstly, the force
being reported is real, so you could
argue that the unit should respond to it.
Consider what happens if you accelerate up a hill; the engine must work
harder than it would to accelerate at
the same rate on level ground. So the
fact that the accelerometer reading
will be higher in that situation makes
sense. Similarly, it will read lower
when accelerating down a hill, which
is gravity-assisted.
Secondly, to compensate for the effects of gravity would be surprisingly
difficult. To disentangle the gravity and
acceleration vectors, we would need a
digital gyroscope (also available, using
MEMS technology).
This could be integrated to keep
track of the vehicle’s orientation,
compute the effect of gravity and
thus eliminate it from the readings.
But because a gyroscope measures
instantaneous rotation (not tilt angle),
calculating the gravity vector would
still be a bit tricky, requiring an integration function.
In the end we decided that including the gravitational component in the
November 2011 29
readings was both sensible
and easy.
If you want to measure
pure vehicle acceleration,
you will need to do so on a
flat surface.
represents the acceleration
of the vehicle. It is then split
In this article, we use the words “force” and “acceleration” interinto forward-back and leftchangeably, even though we know they aren’t the same thing.
right components.
Newton’s second law of motion says: Force = Mass x Acceleration.
If either of these is higher
So while the acceleration due to gravity (1g) is more or less constant,
than the currently disthe force due to gravity depends on the weight of the object.
played acceleration value,
Form factor
While this is a “g-force” meter, it actually reads acceleration. But it
the display is updated with
Besides the software, the does so by measuring the force it experiences due to that accelerathe new value and the fiveother change compared to tion. Is that confusing or what?
second timer is reset.
We decided to risk the wrath of physicists everywhere and use
the Digital Spirit Level is the
If the timer expires, ie,
cheaper and simpler hous- these terms as people are familiar with them, rather than worrying
the same peak value has
about being technically correct.
ing; a UB3 jiffy box.
been displayed for five
Power is still from two AA
seconds, the display is realkaline cells but if you want to run it By measuring the amount of deflec- set and it then shows the acceleration
from 12V (eg, from a cigarette lighter tion, the IC can measure the force it value for whichever of the two axes
socket), it’s a simple matter to add an experiences.
is currently experiencing the highest
appropriate voltage regulator.
The arms each form a capacitor acceleration.
with the surface they are mounted on
In a non-accelerating vehicle on a
How it works
and this capacitance changes as they level surface, the reading will be close
The circuit is built around the deflect, because the distance between to zero.
3-axis MEMS accelerometer (IC1), the capacitor “plates” is changing.
PIC18LF14K22 microcontroller (IC2) These capacitance shifts change the Circuit description
and a four-digit LED 7-segment display frequency of an oscillator in the IC and
The full circuit for the accelerometer
(DISP1-4).
the oscillation frequency is counted.
is shown in Fig.1. The only change
The g-force experienced is shown on
A mathematical formula can then from the digital spirit level is that we
the display with the first digit indicat- be used to convert this frequency into have added a power switch, S2.
ing the direction (F=forward, b=back, an acceleration reading for that axis.
The digital spirit level was switched
L=left, r=right) and the three remaining
When the calibration button (S1) is on by shaking and it automatically
digits showing g-force in the range of pushed, IC2 reads the current measure- turned off with inactivity but since
0.00-2.00g.
ment from the accelerometer and stores this unit may be used for long periods,
The MEMS accelerometer contains it in its internal flash memory.
a power switch was judged the more
three micro-machined mechanical
From then on, this is used as the sensible approach.
arms. They are at right-angles to each gravity reference vector. This is subThe micro, IC2, drives the eight
other and they each bend and deflect tracted from subsequent readings, 7-segment display anodes directly
in response to force along one axis. forming a difference vector which from its outputs, via 4.7 current-
Force vs acceleration
+3V
DISP1–4: FND500 OR EQUIVALENT
10 F
100nF
10
1
Vdd
10k
4.7k
4.7k
4
POWER
10 F
MCLR
100nF
Vpp
2x AA
CELLS
1
VddIO
2
100nF
7
BYP
14
Vdd
6
SDA
13
4
11
SCL
IC1
MMA8451Q
11
SA0
INT1
INT2
GND GND GND
5
10
12
SC
2011
PGC
18
17
9
G-force meter
30 Silicon Chip
1k
10
CAL
S1
+3V
16
RC0
15
RC1
14
RC2
7
RC3
6
RC4
5
RC5
8
RC6
9
RC7
8x 4.7
DISP1
10 g
9
f
7 a
5
dp f
1 e
6 e
SCK/RB5
INT1/RA1
INT2/RA2
RB5
RA0
RA5
RA4
RB7
Vss
20
DISP3
a
b
g
f
DISP4
a
b
g
e
c
d
f
a
b
g
e
c
d
f
b
g
e
c
c
d
d
K
IC2
PIC18LF14K22
SDA/RB4
a
b
2
d
4 c
DISP2
8
8
8
8
D
Q1
TN0604
G
12
S
19
G
PGD
D
Q2
TN0604
S
D
Q3
TN0604
G
2
S
3
Vpp +3V
D
Q4
TN0604
G
S
PGC
GND
1
(ICSP SKT)
5
Fig.1: with the exception of the power switch, the circuit of the g-force
meter is identical to that of the digital spirit level published in our August
issue. For a full description of how the accelerometer chip operates, refer
to that issue. Note that the software is quite different for this project.
TN0604(N3)
D
G
S
siliconchip.com.au
Fig.2: (above) the PCB component overlay, with the
underside of the board at right showing the SMD
accelerometer chip. A same-size top-side photo is
below (only the SMD chip is on the underside).
limiting resistors. The display common cathodes are driven using four
Mosfets, Q1-Q4. Their gate voltages are
controlled by outputs RA0, RA4-5 and
RB5 of IC2. These are special Mosfets
which have a low on-resistance even
with a low gate drive voltage.
This is important since the supply
voltage is limited and any voltage
losses across the Mosfets will reduce
the display brightness.
Since the display is multiplexed,
with each digit on 25% of the time and
since the microcontroller outputs driving the anodes have limited current
capability, we need as much brightness
as we can get.
Communication with the accelerometer, IC1, is via I/O pins RB4-5 and
PA1-2. RA1 and RA2 are connected
to the interrupt pins of IC2 (INT1 and
INT2 respectively) and these are used
by IC2 to signal events and that acceleration data is ready to be read out
from its internal buffers.
Commands and data are sent over
the I2C bus with pins SDA (data) and
SCL (clock). Each has a 4.7k pull-up
to VCC, as I2C utilises open-collector
outputs to enable bus sharing.
The power supply for IC1 is
smoothed with an RC filter consisting
of a 10 resistor and 100nF and 10F
capacitors in parallel. It also has a
separate filter capacitor connected to
the BYP (bypass) pin, pin2.
For calibration, pushbutton switch
S1 is connected between input RB7
of IC2 and ground. IC2 enables its
internal weak pull-up current source
on that pin so that when the button
is pressed, the input state changes
from high to low. It is debounced in
software.
The whole circuit runs off a 3V
battery consisting of two AA cells
bypassed with a 10F capacitor. IC1
also has a 100nF high-frequency bypass capacitor.
Construction
First mount is IC1, the accelerometer. This only comes in a small 16-pin
QFN (quad-flat no-leads) package.
In fact, all MEMS accelerometers
and gyroscopes seem to come in
similar packages, presumably for compactness (they are frequently found in
mobile phones).
Because it has no leads, it’s quite
tricky to solder. In the Digital Spirit
Level article, one particular method
was recommended. We have also tried
another method which worked quite
well and this is described in the panel
on p33. Follow those directions there
to solder the IC.
Then flip the board over and install
the resistors. We recommend the use of
a digital multimeter to check the value
of each before it is installed. Follow
with the IC (a socket is optional), ensuring it goes in the right way around.
Next, fit the four 7-segment displays,
again careful with polarity (the decimal point goes at lower-right in each
case) and make sure they are neatly
lined up and flat against the PCB before
soldering them in place.
Solder the capacitors in next. Note
that the two electrolytic types should
be laid over on their sides. In each
case the longer lead goes into the pad
towards the bottom of the board. The
four Mosfets can then be mounted,
with their leads cranked out using
small pliers, to suit the pad spacing
on the PCB. They are static-sensitive
so be careful in handling them.
Mount the 5-way pin header next.
This provides an in-circuit programming connection, compatible with
Microchip’s PICkit3. If your chip is
pre-programmed and you don’t plan
to re-program it, this header may be
omitted.
The PCB “hangs” off the front panel by means of four 12mm spacers, as these two photos (one taken from top, one from
the bottom) show. The pushbutton switch (SW1) is the only control which emerges through the panel.
siliconchip.com.au
November 2011 31
Re-flow its pins using
flux and solder wick, as
described in the panel.
Then try again.
Here’s the
case lid shown
without the PCB in place,
to reveal the four mounting
pillars, the SW1 access hole and the red
acrylic “lens” for the 7-segment LED displays.
Finally, solder the tactile pushbutton (S1) in place. Ensure it is pushed
right down against the PCB before
soldering. The button should be orientated so that its leads project out to
the left and the right (this is really the
only way it will fit as the pads aren’t
quite arranged in a square). When you
are finished, its actuator shaft should
be perpendicular to the PCB surface.
Testing it
Pass the battery wires up through
the hole in the board and solder them
to the appropriate pads. Double-check
that the polarity is correct (there is no
reverse polarity protection!). Tighten
a small cable tie around the leads just
above the hole that they pass through
and trim it. Insert the cells and check
that the unit is operating correctly.
If it is, the display will light up and
read either “Fx.xx”, “bx.xx”, “Lx.xx”
or “rx.xx”, where xx.x is a number
between 0.00 and 2.00. Hold the PCB
vertically and press S1. The number
shown should then be closer to zero.
You can then change the reading by
moving the board in, out and sideto-side. Remember that it has a fivesecond peak hold. Remove the cells
from the holder.
If it didn’t work, check the orientation of all polarised components (IC1,
IC2, Q1-Q4 and the
two electrolytic capacitors). Assuming they’re OK, the
most likely problem is that IC1 isn’t
soldered properly.
Finally, the
completed g-force
meter opened up to
show the method of
assembly with a 2x
AA battery holder
glued to the bottom
of the case and a
power switch (S2)
through the case
side.
32 Silicon Chip
Housing it
Remove the lid from
the UB3 jiffy box and
attach a printout of the
front panel (available
from siliconchip.com.au)
to use as a drilling/cutting template.
Use a sharp knife to cut out the display
area rectangle from the photocopy
before attaching it. You can then use
the same knife to (carefully!) etch the
outline of the display into the lid.
Drill the five holes to 3mm where
indicated. Also drill a series of holes
around the inside of the outline for
the display, then knock the panel out
(side-cutters can be used to remove any
remaining plastic sections keeping it
in place). Use a large, flat file to carefully file the edges flat and to shape the
cut-out to the etched outline. You may
need to use needle files to finish the
corners. Remove any “lip” formed in
the process of filing with a sharp knife.
De-burr the holes then temporarily
attach the PCB to the rear of the lid
using the four 12mm tapped spacers
and eight M3 machine screws, with the
black screws on the outside. Check that
the pushbutton is properly lined up
with its hole and that it doesn’t “stick”
when pressed due to misalignment
or the hole being slightly too small.
Enlarge it if necessary.
Remove the board and place the
acrylic sheet behind the cut-out and
glue it in place. We used hot melt
glue but you can also use neutral cure
silicone sealant. Make sure not to get
the glue on surface of the “lens” or it
Parts list –
g-force meter
1 PCB, code 04108111, 100 x
44mm *
1 tactile pushbutton momentary
switch with 22mm actuator
(S1; Altronics S1119)
1 pushbutton cap to suit S1
(Altronics S1481)
1 SPST (or SPDT) miniature
toggle switch (S2)
1 5-way 2.54mm pitch pin header
1 2 x AA battery holder
1 UB3 jiffy box
1 transparent red Acrylic or
Perspex sheet, 60 x 25mm
4 M3 x 12mm tapped spacers
4 M3 x 6mm pan-head machine
screws
4 M3 x 5/6mm black machine
screws
1 small cable tie
1 60mm length foam-cored
double-sided tape
hot melt glue or neutral cure
silicone sealant
* see
below
Semiconductors
1 MMA8451Q 3-axis
accelerometer (IC1) *
1 PIC18LF14K22-I/P microcontroller programmed with
0410811C.hex (IC2) *
4 TN0604N3 Mosfets (Q1-Q4) *
4 FND500 7-segment LED
displays or equivalent (Jaycar
ZD1855, Altronics Z0190)
Capacitors
2 10F 16V electrolytic
3 100nF MKT or monolithic
ceramic
Resistors (0.25W, 1%)
1 10k
2 4.7k
1 10
8 4.7
1 1k
SHORT FORM KIT
* A short-form kit consisting of:
1 Printed Circuit Board (04108111)
1 MMA8451Q Accelerometer Chip
1 PRE-PROGRAMMED
PIC18LF-14K22-I/P microcontroller
4 TN0604N3 Mosfets
(IE, ALL THE HARD-TO-GET PARTS!)
is now available direct from SILICON
CHIP for only $44.50 plus $10 p&p.
See the handy order form on P102
siliconchip.com.au
Soldering the QFN SMD IC
The procedure for soldering the QFN device, as detailed in the Inclinometer article,
is (briefly) as follows: tin the pads, place
the IC on top, line up its pads, then reflow
the solder added earlier to form the joints
between the PCB pads and the IC pads.
While this method works and doesn’t
require any special tools, we tried a different
approach this time, which we think might
be more reliable.
First, place a small amount of solder
on one of the PCB pads. We started with
the top-right pad; left-handers may prefer
to start at the upper left. Then place the
IC alongside its final position (but not on
this pad) and check its orientation. Be very
careful as it’s difficult to remove once it’s
in place.
Then heat the solder on that pad and,
using angled tweezers, slide the IC into
position. Remove the heat and check the
IC under a illuminated magnifying lamp to
see whether its pads are lined up correctly
on all sides. They are copper coloured and
are just visible around the bottom edge of
the chip; the PCB pads should be tinned
and therefore look silver.
It’s unlikely that the IC will be perfectly
positioned on the first attempt, so re-heat
the solder on that one pad and very gently
will be damaged. Just flow it around
the edges, as shown in the photo. Once
the glue has set, trim away any areas
that interfere with the corner posts,
programming header or any other tall
components.
Then drill a small hole in the box
itself, for the toggle switch. You can
put it anywhere you like; we opted
for the left side. Don’t put it too close
to the lid.
Cut the red battery wire about 5cm
from where it leaves the PCB, strip both
ends and solder them across one pole
of the chassis-mount toggle switch (ie,
one to the centre and one to an adjacent
tab). Re-insert the two AA cells and
check that the switch works.
You can then re-attach the PCB to
the rear of the lid and push on the cap
for switch S1 (push it hard, so it won’t
come off easily). Install the switch in
the box and do up the nut tight. Then
peel the protective coating off the strip
of double-sided foam-core tape, press it
onto the back of the battery holder and
stick the battery holder in a convenient
location in the case (in the middle is
best). Make sure it’s stuck down well.
siliconchip.com.au
nudge the chip in the right direction (again
using the tweezers). Check it again under a
magnifying glass and repeat this procedure
as many times as is necessary, until it is
correctly positioned.
Note that boards with a solder mask can
fool you; the solder mask isn’t necessarily
perfectly aligned with the pads themselves.
See the photo above. We thought we had
lined up the IC with the pads but we had
instead lined it up with the holes in the
solder mask layer – we fixed this (and the
shorted pads!) after taking the photo.
Once the pads are properly lined up on
all four sides, apply solder to the pad diagonally opposite the one you started with.
Unless your soldering iron has a very fine
tip, you will need to put a fair bit fo solder
on the tip for it to bulge, then use gravity to
flow it up against the corner junction formed
by the the IC and the PCB.
You can then flow solder onto all the
remaining pads using the same method
(ignoring solder bridges for now). Then
apply a thin layer of flux paste all around
the edges.
Now place some solder wick flat on
the PCB, as close to the IC as possible
and heat it with your soldering iron. Once
the flux starts to smoke, gently push it up
against the edge of the IC. After a couple
fo seconds, any excess solder will flow
into the wick and also under the IC pads,
filling the gap between it and the PCB. Wait
a few seconds, then remove the wick and
the soldering icon. It should leave just the
right amount of solder on the pads.
You can then clean off any remaining flux
with isopropyl alcohol, although if you used
“no-clean” flux paste (usually a good idea)
this isn’t strictly necessary.
Our board worked first time after installing the IC using this method. If yours
doesn’t, add some more solder to each pad
and re-flow them again to ensure that they
are all properly connected.
Note that this method is very similar
to that described for soldering fine-pitch
SMD ICs such as TSSOP and QFP in the
October 2009 issue (“How To Hand-Solder
Very Small SMD ICs”) and once you get
the hang of it, it can be applied to a wide
variety of SMDs.
It’s then just a matter of screwing
the lid on the box and (if provided)
pushing the rubber caps over the screw
holes to hide them.
All that’s left is to figure out how
to stick the unit to your dashboard
(or wherever you want to put it). You
can use double-sided tape or BluTak
(which can work surprisingly well,
depending on the other surface).
But be careful because both are likely
to leave residue on the dashboard
which may be hard to remove. If you
have an obsolete or broken GPS unit,
you could re-use its suction cup mount
for this purpose.
Wherever it is mounted, make sure
it doesn’t interfere with your field of
vision or block the visibility of any important instruments (eg, speedometer).
the accelerometer on and press the
calibrate button. The display should
then read close to zero.
It will then remember the calibration setting even after it is switched
off. It only needs to be re-calibrated if
the mounting arrangement is changed.
To use it, just switch it on and glance
at it after a manoeuvre to see the peak
acceleration.
Don’t be distracted by it and remember to keep your eyes on the road!
You can interpret the readings as
follows:
Calibrating it
You will need to be parked on a level
surface for proper calibration. If you
have access to a poured concrete parking lot or garage floor, that is probably
the best option (although it may have
shifted since it was poured).
Park the car on a flat surface, turn
0.00-0.20g:
gentle acceleration/braking/
cornering or gentle slope
0.20-0.35g:
moderate acceleration/
braking/cornering or
moderate to steep slope
0.35-0.60g:
hard acceleration/braking/
cornering or very steep
slope
0.60-0.80g:
racing
0.80-1.00g:
super-car territory
1.00g+:
extreme manoeuvres/
collision
SC
November 2011 33
|