This is only a preview of the September 2000 issue of Silicon Chip. You can view 36 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 Swimming Pool Alarm":
Items relevant to "8-Channel PC Relay Board":
Items relevant to "Fuel Mixture Display For Cars, Pt.1":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
readout
* Digital
plus bargraph
shows
* Display
air-fuel ratio
to install
* Easy
in a vehicle
auto* Display
dims at night
Monitor engine air-fuel ratios with this:
Mixture Display
Monitor the air-fuel ratio of your car’s engine
in real-time with this Fuel Mixture Display. It
boasts both digital and bargraph displays and
can be used as a tuning aid, or when making
engine modifications or just to indicate when
there are problems.
Pt.1: By JOHN CLARKE
Your car engine’s air-fuel ratio has
a considerable bearing on fuel consumption and air pollution. For this
reason, modern cars use an exhaust
gas oxygen (EGO) sensor mounted in
the exhaust system to continuously
monitor air-fuel ratios and generate
corresponding output voltages. This
information is then fed to the engine
management computer (EMC) which
continuously adjusts the mixture to
provide optimum power and econ54 Silicon Chip
omy, consistent with low exhaust
emissions.
As can be imagined, if the EGO
sensor is not functioning correctly,
engine performance suffers and
this can lead to very high fuel bills.
Conversely, a properly functioning
sensor ensures good engine performance and helps keep fuel costs
down – something that’s even more
important than ever given the recent
petrol price hikes.
A system that’s in good nick also
minimises air pollution. In modern
cars, the combustion products from
the engine are made safe by a catalytic converter which is mounted
in the exhaust system. Combustion
byproducts such as carbon monoxide
(CO) are converted to carbon dioxide
(CO2), unburnt hydrocarbons to CO2
and water (H2O) and nitrous oxide
(NO) to nitrogen (N2) under the action
of the catalysts within the converter.
However, this only works properly if the air-fuel ratio is held within
certain limits. And that in turn is
dependent on the EGO sensor. An
EGO sensor, by the way, does not last
indefinitely. Depending on the car, it’s
usually a good idea to replace it every
50,000 to 80,000km.
Stoichiometric ratio
A catalytic converter works best
when the air-fuel ratio is such that
there is just sufficient oxygen to give
complete combustion. This is called
the “stoichiometric” ratio. It varies
according to the fuel used but is generally 14.7:1 for unleaded petrol; ie,
the air mass must be 14.7 times the
fuel mass.
For propane (C3H8), the stoichiometric ratio is a little higher at 15.6
and so more air is required compared
to unleaded petrol to ensure complete
combustion.
Note that the EGO sensor does not
measure the air-fuel ratio directly.
Instead, it monitors the resultant oxygen (O2) content after combustion
and provides a voltage output to in
dicate whether the mixture is lean,
stoichiometric or rich.
Fuel Mixture Display
The concept behind the SILICON
CHIP Fuel Mixture Display is quite
simple – it monitors the EGO output
signal and, after processing, displays
the results on a bargraph and on a digital readout. This digital readout can
be calibrated to show the air-fuel ratio
for either unleaded petrol or propane.
For petrol, the unit is calibrated to
display air-fuel ratios ranging from
11.8:1 (rich) to 20.6:1 lean, with the
stoichiometric point at 14.7. The
corresponding range for propane is
from 12.7:1 to 21.5:1, with the stoichiometric point at 15.6.
Note, however, that the fuel-air ratio doesn’t remain static while you are
driving. Instead, it fluctuates in a rapid rich-lean-rich-lean sequence as the
engine management computer (EMC)
responds to the EGO sensor’s output.
Put your foot down for acceleration
and you will immediately see that the
mixture is enriched to provide more
power. Conversely, under a trailing
throttle, the air-fuel ratio “leans off”
and again this will immediately be
indicated on the displays.
Under a constant throttle, the air-fuel ratio should quickly settle at a fixed
value. This point is leaner than the
stoichiometric point, to ensure that
emissions are kept low. It’s all made
possible by the ECU which continuously monitors the EGO output and
controls the fuel injectors to maintain
the desired ratio.
What sort of figures are we talking
about? Well, many late-model engines
operate with air-fuel ratios approaching 19.0:1 at constant throttle. As well
as relying on the EGO sensor, mixture
Main Features
•
•
•
•
•
•
•
•
•
•
•
•
•
Suits vehicles with Zirconia EGO probes
Compact size
3-digit LED readout plus 7-LED bargraph display
Dot or bar mode option for bargraph
Air-fuel ratio matched for Bosch LSM11 (0258104002) EGO probe
Indicates air-fuel ratios from 11.8 to 20.6 for petrol
Indicates air-fuel ratios from 12.7 to 21.5 for propane/LPG
Fully lean and fully rich air-fuel indication
Bargraph display follows the non-linear response of the EGO sensor
13 indication levels in dot mode;, 7 levels in bar mode
Fast 220ms update time for bargraph; 440ms for 3-digit display
Automatic display dimming
0-1V display for setting up adjustments
Note: this device is not suitable for use on cars that run on leaded petrol.
If your car doesn’t already have an EGO sensor, you can fit one yourself
but the engine must run on unleaded fuel, propane or LPG in order to use
the Fuel Mixture Display continuously (leaded petrol poisons the sensor).
settings this lean are, in part, made
possible by the use of knock sensors.
These listen for engine knocking and
if it is detected, the ECU retards the
ignition timing until the knocking
ceases.
This allows many engines to run
just below the point of knocking, thus
significantly boosting fuel economy
while cutting emissions.
Basic features
As shown in the photos, the Fuel
Mixture Display is housed in a compact plastic case. Its size and presentation matches that of three previous car
projects – the Speed Alarm described
in November 1999, the Digital Voltmeter in February 2000 and the Digital
Tacho in April 2000.
But the similarities don’t end
there. As with those earlier designs,
this circuit is based on a PIC16F84
microcontroller. This has allowed us
to dramatically shrink the parts count
and also makes the unit incredibly
easy to build.
If you look at those earlier circuits,
you will notice that they are all quite
similar. Most of the hardware modifications involve the input sensor
circuitry. The big difference between
them lies in the software that’s programmed into the PIC chip.
Naturally, we’ve retained the automatic display brightness feature that
was built into the previous designs.
In bright light, the LED displays are
at maximum brilliance so that they
can be easily seen. However, as the
ambient light falls, the displays automatically dim so that they don’t
become distracting.
Another feature of the unit is that
it’s easy to install. There are just
three external connections – two for
power and the third to the existing
EGO sensor.
No EGO sensor?
If your car’s engine runs on leaded
petrol, it won’t have a factory-fitted
EGO sensor. The way around this is
to source a sensor from a wrecker
and install it in the exhaust manifold
yourself.
Note, however, that running leaded
petrol will soon poison the sensor. As
a result, this approach should only be
used for tuning purposes, with the
sensor then removed and the hole
plugged with a bolt of the same thread
for everyday running.
LED displays
OK, let’s see how we have arranged
the LED displays to match the output
from the EGO sensor. The first thing
to realise here is that the output from
the EGO sensor is far from linear.
Fig.1 shows the output voltage
curve from a Bosch zirconium oxide
EGO sensor, plotted against air-fuel
ratios for both unleaded petrol and
SEPTEMBER 2000 55
LED7 is alight for minimum sensor
output.
By contrast, the bar mode has
only seven threshold points. In this
mode, LED4 (the centre LED) covers
the central stoichiometric point for
sensor output voltages ranging from
340-650mV (region D). The remaining
six LEDs are then used for the rich and
lean portions of the display. As the
mixture becomes richer, LEDs3-1 progressively come on. Similarly, as the
mixture leans off, LEDs5-7 come on.
Note that LED4 is on all the time.
This makes the bar mode a little unconventional, since it starts from the
central LED. However, this approach
is perfectly logical.
The advantage of the LED bargraph,
in either dot or bar mode, is that it can
rapidly respond to signal variations
from the EGO sensor. This is handy
because the EGO sensor output can
fluctuate quite rapidly during normal
driving.
By contrast, the 3-digit readout is
set up so that it responds more slowly,
so that it can be read. In normal operation, it gives a direct readout of the
air-fuel ratio. However, ratios that are
less than 11.8:1 or greater than 20.6:1
for petrol are respectively shown as
“r” (for rich) or “L” (for lean).
Alternatively, the digital readout
can be set to show voltages ranging
from 0.00 through to 1.05V instead of
the air-fuel ratio and this is to allow
the unit to be calibrated. This is done
using two trimpots – one to set the
voltage range (span) and the second
to set the minimum voltage that can
be measured (offset).
How the circuit works
Fig.1 the above graph shows the output voltage curve from a Bosch
zirconium oxide EGO sensor, plotted against air-fuel ratios for both
unleaded petrol and propane. Also shown is the response of the bargraph
display as the EGO output varies, for both dot and bar modes.
propane. Also shown are the corresponding Lambda (λ) values which
are calculated by dividing the air-fuel
ratios by the stoichiometric value.
This means that a Lambda of 1 is at
the stoichiometric point.
Fig.1 also shows the corresponding
response of the LED bargraph display
as the EGO output varies, for both dot
and bar modes. First, the dot mode –
this has either one or two LEDs lit at
any time, giving 13 separate display
56 Silicon Chip
points. The stoichiometric point at
600mV is indicated by the central
indicator LED4, which lights over the
range indicated by “G” on the curve.
As the voltage climbs towards the
rich end, both LEDs 3 & 4 light, then
LED 3 lights on its own, then LEDs
2 & 3 together and so on until only
LED 1 is lit at the end of the range (ie,
maximum voltage).
A similar sequence of events occurs
as the mixture leans off, until only
Fig.2 shows the circuit for the Fuel
Mixture Display. IC1 is the PIC micro
controller which forms the basis of
the circuit. It accepts an input from
the EGO sensor via op amp IC2a and
drives the LED displays.
IC2a functions as an inverting comparator. As shown in Fig.2, the signal
from the EGO sensor is applied to its
pin 2 input via a filter circuit consisting of a 1MΩ resistor and a 0.1µF
capacitor. Note that the resistor is
made large to reduce transient loading
on the EGO sensor. In fact, the current
from the EGO sensor must be at less
than 1µA so that its output voltage
(and thus the engine performance)
isn’t affected.
In operation, IC2a compares the
SEPTEMBER 2000 57
Fig.2: the PIC microcontroller (IC1) processes the input signal from the EGO sensor (via IC2a) and drives the 7-segment LED
displays and the LED bargraph. Q6, D1, D2 & REF1 provide a voltage offset for pin 3 of op amp IC2a, while IC2b & LDR1
automatically vary the display brightness, so that they don’t appear too bright at night.
Fig.3: here are the assembly details for the two PC boards. Resistor R1 is
installed if you want the bargraph to operate in bar mode and is left out
of circuit for dot mode operation. Take care to ensure that you don’t get
the transistors mixed up.
sensor voltage at pin 2 with a DC voltage at its pin 3 input. This DC voltage
is derived by applying a pulse width
modulated (PWM) square-wave signal
from the RA3 output of IC1 to an RC
filter/divider circuit.
As a result, pin 1 of IC2a switches
low when ever the voltage on its pin 2
input is greater than the voltage on pin
3. This signal is then fed via a 3.3kΩ
limiting resistor to the RB0 input of
IC1. The resistor limits the current
flow from IC2a when its output swings
high to +12V, while internal clamp
diodes at RB0 limit the voltage on
this pin to 5.6V (ie, 0.6V above the
supply rail).
A-D converter
Among other things, IC1 performs
analog-to-digital (A/D) conversion.
This converts the signal on its RB0
input into a digital value which is
then used to drive the LED displays.
As mentioned above, the output at
58 Silicon Chip
RA3 produces a PWM signal and this
operates at 1953Hz with a wide-ranging duty cycle. A high output from
RA3 is at 5V while a low output is
at 0V. VR2, the 180kΩ resistor and
the 0.1µF capacitor filter this output
to produce a DC voltage, while the
100kΩ and 1kΩ resistors from pin
3 to ground form the bottom of the
voltage divider.
In practice, VR2 is set so that it
divides the RA3 output by 3.9.
This means that if the duty cycle is
50% (ie, a square wave) the average
at RA3 will be 50% of 5V or 2.5V.
As a result, the voltage at pin 3 will
be 2.5/3.9V, or 0.64V. This will vary
either up or down, according to the
duty cycle.
The A-D conversion is as follows:
initially, the RA3 output at pin 2 of
IC1 operates with a 50% duty cycle
and this sets the voltage at pin 3 of
IC2a to 0.64V. At the same time, an
8-bit register inside IC1 has its most
significant bit set high so that its value
is 10000000.
This 50% duty cycle signal is
produced at a frequency of 1953Hz
for about 8ms, after which the comparator output level (pin 1 of IC2a) is
monitored by the RB0 input. Pin 1 of
IC2a will be low if the sensor voltage
at pin 2 is above 0.64V and high if it
is less than this value.
If the sensor voltage is less than
0.64V, the pulse width modulation
(PWM) output at RA3 is reduced to a
25% duty cycle to produce an average
of 1.25V and thus 0.32V on pin 3 of
IC2a. The internal register is now set
to 01000000.
Conversely, if the sensor voltage is
above 0.64V, corresponding to a low
comparator output, the RA3 output
is increased to a 75% duty cycle to
provide an average of 3.75V. The
register is thus set to 11000000, with
the most significant bit indicating the
2.5V 50% duty cycle and the next bit
indicating the 1.25V 25% duty cycle.
Adding the two bits gives us the
3.75V (75%) value which, after division by 3.9, gives 0.96V on the pin 3
input of IC2a.
The comparator level is now
checked again after about 8ms. The
microcontroller then adds or subtracts
a 12.5% duty cycle value (0.625V at
RA3 or 0.16V at pin 3 of IC2a) and
this is then compared with the input
voltage again.
If the sensor voltage is higher than
the PWM waveform, the internal register is now set to X1100000 (where
X = 1 or 0 as determined by the first
operation). Conversely, if the sensor
voltage is lower than the PWM voltage, the register is set at X0100000.
This entire process is repeated
for eight cycles, the microcontroller
adding or subtracting progressively
smaller voltages to pin 3 of IC2a. At
each step, successively lower bits in
the register are set to either 1 or 0 to
obtain an 8-bit A-D conversion.
The A-D conversion has a resolution of 5mV (0.005V) at the least
significant bit. There are also 256
possible values for the 8-bit register, ranging from 00000000 (0) to
11111111 (255). However, in practice
we are limited to a range from about
19 to 231.
That’s because the software requires a certain amount of time to
process the results in IC1 and produce
the next waveform at the RA3 output.
As a result, the measurement range
is from about 95.5mV to 1.16V. However, by applying a slightly negative
offset voltage to the pin 3 input, we
can effectively cancel out the 95.5mV
minimum so that it can be set at 0V.
This then allows the comparator to
measure from 0V to 1.16V - 95.5mV;
ie from 0-1.06V.
Following the A/D conversion, the
8-bit register value is converted to the
value required for the display using
a lookup table. In practice, separate
tables are used for the air-fuel ratio
display and the two modes for the
bargraph. These lookup tables can be
easily modified if required.
Negative offset voltage
The negative offset voltage applied
to pin 3 of IC2a is derived using voltage
reference REF1, diodes D1 & D2 and
transistor Q6. Let’s see how this works.
In operation, Q6 is driven by the
RA4 output of IC1 which incidentally,
also drives switching transistor Q1
which controls the LED bargraph.
When RA4 is low, Q6 is off and so
capacitor C1 (10µF) charges to the
+12V supply via a 1kΩ resistor and
diode D1. Conversely, when RA4
subsequently goes high, Q6 turns on
and connects the positive terminal of
C1 to ground.
As a result, the negative terminal
of C1 goes to -12V and this charges
capacitor C2 via diode D2.
Table 1: Capacitor Codes
Value
IEC Code EIA Code
0.1µF 100n 104
15pF 15p 15
The display board (top) carries the three 7-segment LED displays, the bargraph
and the LDR. It plugs into the microcontroller board above, thus eliminating
wiring connections between the two.
Table 2: Resistor Colour Codes
No.
1
1
1
1
1
2
2
2
1
4
8
1
Value
1MΩ
180kΩ
100kΩ
12kΩ
10kΩ
3.3kΩ
1.8kΩ
1kΩ
1kΩ
680Ω
150Ω
10Ω
4-Band Code (1%)
brown black green brown
brown grey yellow brown
brown black yellow brown
brown red orange brown
brown black orange brown
orange orange red brown
brown grey red brown
brown black red brown
brown black red brown
blue grey brown brown
brown green brown brown
brown black black brown
5-Band Code (1%)
brown black black yellow brown
brown grey black orange brown
brown black black orange brown
brown red black red brown
brown black black red brown
orange orange black brown brown
brown grey black brown brown
brown black black brown brown
brown black black brown brown
blue grey black black brown
brown green black black brown
brown black black gold brown
SEPTEMBER 2000 59
resistor is present, then that input will
be pulled low.
The software reads the inputs to
determine whether they are high or
low and sets the display mode accordingly. It then resets RB1, RB3 & RB4 as
outputs so that data can be presented
to the LED displays.
Display dimming
These two photos show how the two boards are married together, with the pin
headers on the display board plugging directly into the 7-way sockets on the
microcontroller board – see also Fig.4.
This process is repeated at a rapid
rate, so that about -6V is maintained
on the negative terminal of C2. This
voltage is applied via a 3.3kΩ resistor
to REF1 which produces a fixed -2.49V
and this in turn is divided down by a
12kΩ resistor, VR3 and the 1kΩ resistor
to ground to give the required 95.5mV
negative offset.
LED displays
The 7-segment display data from
IC1 appears at outputs RB1-RB7, as
does the data for the LED bargraph.
These outputs directly drive the LED
display segments and the bargraph
LEDs via 150Ω current limiting resistors.
As shown, the corresponding display segments are all tied together. In
addition, the cathodes of the seven
LEDs are each tied to a display segment. In operation, only one 7-segment LED display or the bargraph is
on at any instant but because they are
rapidly switched in sequence, they
appear to be continuously lit.
This technique is called “multi
plexing” and it involves individually
switching outputs RA0-RA4 low and
then high again in sequence to control
60 Silicon Chip
switching transistors Q1-Q4. Q1-Q4
in turn control the LED displays.
For example, when RA0 is switched
low, Q4 turns on and applies power
to the common anode connection of
DISP3. Any low outputs on RB1-RB7
will therefore light the respective
segments in the display. RA0 is then
switched high again and RA1 is
switched low to drive Q3 and DISP2,
after which it’s the turn of RA2 and
RA1.
Display modes
Resistors R1, R2 and R3 are used
to select the various display mode
options. When installed, they respectively tie the RB1, RB3 and RB4
lines low. R1 determines whether the
bargraph operates in bar or dot mode;
R2 sets the display mode to volts
or air-fuel ratio; and R3 determines
whether the air-fuel ratio is for propane or unleaded petrol.
Each time power is applied to the
circuit, the software sets RB1, RB3 &
RB4 as inputs with internal pullup
resistors. Each pullup resistor will
hold its corresponding input pin
high if there is no external resistor
to ground. Conversely, if an external
IC2b is used to control the display
brightness. This op amp is connected
as a voltage follower and drives buffer
transistor Q5 which in turn controls
the voltage on the emitters of the display driver transistors, Q1-Q4.
When the ambient light is high,
LDR1 is low resistance and so the
voltage on pin 5 of IC2b is close to
+5V. This means that the voltage on
Q4’s emitter will also be close to +5V
and so the displays operate at full
brightness.
As the ambient light falls, the LDR’s
resistance increases and so the voltage at pin 5 of IC2b falls. As a result,
Q5’s emitter voltage also falls and so
the displays are driven at reduced
brightness.
At low light levels the LDR’s resistance is very high and the voltage
on pin 5 is determined by VR1. This
trimpot sets the minimum brightness
level.
Clock signals
Clock signals for IC1 are provided
by an internal oscillator circuit and
this operates in conjunction with
4MHz crystal X1, between pins 15 &
16. Also included in the clock circuit
are two 15pF capacitors. These ensure
correct loading so that the oscillator
starts reliably.
In operation, the 4MHz crystal frequency is divided down internally to
produce separate clock signals for the
microcontroller operation and for the
display multiplexing.
Power
Power for the circuit is derived from
the vehicle’s +12V ignition supply.
This is fed in via a 10Ω resistor which,
together with the 47µF and 0.1µF capacitors, provides decoupling. Zener
diode ZD1 is included for transient
protection – it limits any spike voltages to 16V and also protects against
reverse supply connections.
The decoupled supply rail is fed
to REG1 to derive a +5V rail. This is
then filtered and used to power IC1
and the LED displays. IC2 and the
voltage offset circuit are powered
directly from the decoupled +12V
ignition supply.
Software
OK, that completes the circuit
description. In reality, the hardware
only forms half the picture. The other
half is locked up inside the microprocessor which performs all the complicated stuff under software control.
Do you REALLY want to know how
the software works? Do you? We won’t
go into the details here because we
don’t have space. If you must know,
then you’ll find the source code posted on our website.
Construction
You really don’t need to concern
yourself with the software to build
this circuit. Instead, you simply buy
the programmed PIC chip and install
it like any other IC.
Fig.3 shows the assembly details.
This mainly involves building two
PC boards – a microcontroller board
coded 05109001 and a display PC
board coded 05109002. Once assembled, these two board are stacked
together in piggyback fashion using
pin headers and cut down IC sockets.
This technique eliminates inter-board wiring since the connections are automatically made via the
pin headers.
Before starting assembly, check
both boards for shorts between tracks,
open circuits and undrilled holes.
Note particularly that two holes are
required in the display PC board to
provide screwdriver access to trimpots VR1 and VR2 on the processor
board. These holes are located just
below DISP3 and to the left of VR3.
The microcontroller board can be
assembled first. Begin by installing
the wire links, then install the resistors. Table 2 lists the resistor colour
codes, although it’s a good idea to also
check them using a digital multimeter.
Note that the seven 150Ω resistors
are mounted end-on as shown.
Trimpots VR1 & VR2 can go in
next, followed by a socket to accept
IC1 (taking care with its orientation).
IC2 is soldered directly to the board
– install this now, followed by zener
diode ZD1 and transistors Q2-Q5.
Be very careful here, because Q5 is
the odd man out. It’s an NPN BC337
type, whereas Q2-Q3 are all PNP
The whole assembly fits neatly into the smallest available plastic utility box
and matches several previous car projects based on PIC microcontrollers. LDR1
should be mounted so that its face is about 3mm above the LED displays.
BC327s. Mix them up and you’ve got
problems.
Regulator REG1 must be mounted as shown, with its metal tab flat
against the PC board and with its
leads bent at rightangles so that they
pass through the PC board holes.
Make sure that the hole in its metal
tab lines up with the matching hole in
the board, as this has to later accept
a mounting screw.
The capacitors can now be installed. Note that the two electrolytic
capacitors are mounted horizontally,
across the regulator’s leads; ie, their
leads should be bent at right angles
before they are installed. Note also
that these capacitors are polarised,
so be sure to mount them with the
polarity shown.
Crystal X1 mounts horizontally on
the PC board but can go in either way
around. It is secured by soldering a
short length of tinned copper wire to
one end of its metal case and to a PC
pad immediately to the right of Q3.
The three 7-way in-line sockets are
made by cutting two 14-pin IC sockets
into inline strips. Use a sharp knife
or a fine-toothed hacksaw for this job
and clean up the rough edges with a
file before installing them on the PC
board.
Finally, install three PC stakes at
the external wiring positions (sensor,
+12V & GND). Once they’re in, trim
these stakes on the parts side of the
board so that they cannot short against
the display board later on.
Display board assembly
As before, install the wire links
and resistors first but only install R1
if you want the bargraph to operate in
bar mode. This done, install the three
7-segment LED displays with their
decimal points at bottom right. The
LED bargraph can also be installed
at this stage – it mounts with its pin
1 (indicated by the bevelled edge)
towards transistor Q1.
The remaining parts can now all be
installed, noting that D1 and D2 face
in opposite directions. The two 10µF
capacitors are mounted flat against
the PC board, while LDR 1 should be
installed so that its top face is about
3mm above the displays.
The three 7-way pin headers are
installed from the copper side of the
PC board, with their leads just protruding above the top surface. You
will need a fine-tipped iron to solder
them in. It will also be necessary to
slide the plastic spacers along the
pins to allow room for soldering, after
which the spacers can be pushed back
down again.
That’s all we have space for this
month. Next month, we will complete
the assembly and describe how the
unit is installed and calibrated. SC
SEPTEMBER 2000 61
|