This is only a preview of the December 2008 issue of Silicon Chip. You can view 29 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 "Versatile Car Scrolling Display, Pt.1":
Items relevant to "Build A Brownout Protector":
Items relevant to "Simple Voltage Switch For Car Sensors":
Purchase a printed copy of this issue for $10.00. |
Monitor, display and
log up to six sensors
and display up to 10
readings!
Pt.1: By MAURO GRASSI
Multi-Purpose
Car Scrolling Display
This project started out as a digital dashboard display but has
grown and can be used in any measurement or data logging
application where you have 9-12V DC available. It can monitor
up to six signals and display up to 10 computed values in a
scrolling or static readout on a 7 x 15 dot matrix LED display.
S
O WHAT’S A SCROLLING DISPLAY? You really need a short
video to show what this project does.
The readout continually “scrolls” from
left to right, displaying one, two and
up to 10 computed values from up to
six different signals. Each value is pre28 Silicon Chip
ceded by its description, such as battery voltage, temperature, duty cycle
and so on. If you want to focus on one
reading, pressing the sole pushbutton
will make the display static.
Anyway, let’s just give a sample of
what this project can do:
•
Measure Engine Temperature – have
a relay switch on above a preset temp
erature.
• Measure Fuel Injector Duty – have
a relay switch if the duty cycle is too
high or too low.
• Measure Engine RPM – have a relay
siliconchip.com.au
BATTERY SENSE
Pin 1 of CON1
7 x 15 DOT
MATRIX DISPLAY
LDR SENSE
Pin 13 of CON6
VIA CON6
SIX
ADC
INPUTS
FOUR
ANALOG/
RESISTANCE
INPUTS
CON3
TWO
FREQUENCY/
DUTY CYCLE
INPUTS
CON2
S1 Pin 7 of CON6
(PUSHBUTTON)
PIC
18F4550
MICRO
CONTROLLER
TWO
CCP
INPUTS
USB
PORT
TWO
RELAYS/
BUZZERS
CON4
TWO
DIGITAL
OUTPUTS
Fig.1: block diagram of the Car Scrolling Display. A PIC 18F4550 microcontroller is at the
heart of the project. It processes various inputs, drives the dot matrix display, manages the
USB connection and drives the two outputs.
switch on at a preset RPM
(perhaps to indicate when
to change gear).
• Measure Throttle Position and Delta Throttle
Position – if the accelerator
pedal is pressed too abruptly, a relay can be made to
switch on this condition.
• Measure Speed – have a
relay switch if the speed is
too high or too low.
• Measure Fuel Tank Level
as a percentage of full tank – have a
relay switch on or off if the level is too
high or too low.
• Measure Battery Voltage – have a
relay switch on if the voltage is too
high or too low.
• Measure Air/Fuel Ratio – have a
relay switch on if the mixture is too
rich or too lean.
• Measure Cabin Temperature –
switch on a fan via a relay if it is too
high.
• Measure almost any signal coming
from the ECU.
So pick any six of the above possibilities and that is what this project
could do in your car. But that is just
for applications involving cars. In
reality, this project can be used anywhere where a DC supply from 9-12V
is available or you have a computer
with a USB port. It accepts voltage,
resistance, frequency or duty cycle
inputs and has two digital outputs for
switching on limit conditions. We will
siliconchip.com.au
bet that you can think up lots more
potential applications.
The project itself uses two PC boards
stacked with red Perspex on top.
The top (display) board has a group
of three 7 x 5 dot matrix displays, a
USB port and a single pushbutton.
The main (lower) PC board has the
microcontroller and all the supporting
circuitry for the connections and the
optional output connections to relays
or buzzers.
To build and set it up, you will need
a laptop or desktop computer with a
spare USB port. You will use Windows-based software (downloadable
from www.siliconchip.com.au) to set
the measurement functions, calibrate
the sensors and do data logging.
The LED display can be dimmed
(either automatically by sensing the
ambient light level or manually) and
you can select the scrolling speed of
the display, as well as the names of the
measurements and their units. In static
mode, the LED readout can display
up to four digits. It can also be turned
off using the front panel pushbutton.
The two output channels can drive
external 12V relays directly and can be
programmed to respond to maximum
and minimum settings for any of the
measured variables. Alternatively, the
outputs could drive buzzers to give an
audible indication that signals have
exceeded their programmed limits.
You can choose different sounding buzzers to indicate maximum or
minimum conditions, when using
two different buzzers. Or you can use
only one buzzer and the maximum
and minimum limits are indicated by
different sequences of beeps.
When you only need a visible indication of a limit condition, there
are visible cues (a flashing display
for a minimum condition and an
inverted display for a maximum
condition) on the LED display when
in static mode.
So there are many uses for this
display and it’s really up to you as to
how you set it up.
User operation
User operation of the Car Scrolling
Display has been kept deliberately
simple. There is just one pushbutton
on the front panel (S1), a momentary
SPST switch. The firmware recognises
a short press and a long press. A short
press is anything less than about a
second, while a long press is anything
more than that.
There are three display modes. You
switch to the next display mode by
holding S1 pressed for more than a
second, ie, by making a long press.
The first is the Scrolling Mode
where only the selected reading is
continuously displayed as a scrolling
string. In this mode, pressing S1 for
less than a second (ie, a short press)
will take you to the next reading, and
that will then scroll continuously.
After you have scrolled to the last
December 2008 29
The unit is built on two PC boards – a main board and a display board. These are stacked
together, along with a red Perspex panel for the dot matrix displays (assembly details next
month). Note that the boards shown are prototypes and the final versions are slightly different.
reading, making a short press will turn
the display off. The sequence can then
be repeated.
The second display mode is the Static
Mode. In this mode, the selected reading is displayed without scrolling. You
can make a short press to go to the next
reading. Again, making a short press after
the last reading turns the display off. The
sequence then repeats again.
The third and last display mode is
the All Scrolling Mode. In this mode,
all readings are displayed as a scrolling
string. The string then repeats continuously. Pressing S1 while in this mode
takes you to the first display mode
again and the whole sequence repeats
from there.
In both scrolling modes, the name
of the variable, the value and the unit
are displayed as a scrolling string.
In Static Mode, up to four digits are
displayed at once.
In Static Mode, a maximum condition is indicated by the display flashing every second or so between normal
and reverse modes, ie, all the normally
lit dots become unlit, and vice versa –
Fig.5. This is a very dramatic mode to
indicate a problem condition. A minimum condition, on the other hand,
30 Silicon Chip
is indicated by a flashing reading. As
indicated, these visual cues are only
available in Static Mode.
Note that the Battery Voltage is always displayed first. For each of the
displayed variables, you select the
variable number and the value index
to display. You also set the order in
which they are displayed.
Remember that you can change all
settings and perform the required calibration using a laptop and a USB cable.
Electrical signals in cars
To get a good understanding of the
signals used in cars, you will need to
refer to the SILICON CHIP publication
“Performance Electronics for Cars”.
This has a range of useful electronic
projects for cars and also explains
how to intercept the signals from your
car’s ECU.
All modern cars have an ECU (Electronic Control Unit) that manages the
ignition timing and fuel injection.
Almost all electrical sensors in your
car produce a voltage or vary their DC
resistance, depending on the quantity
being measured, or produce a digital
signal (varying the frequency or duty
cycle) to indicate the reading.
Different sensors have different voltage ranges. For example, a narrowband
air/fuel sensor may have an output in
the 0-1V range, whereas a tachometer
sensor output may be a square wave
at 5V with the frequency of the signal
proportional to the engine’s RPM.
By contrast, a fuel injector signal
is digital (12V amplitude), with the
positive period (ie, the time the signal
is at a high level) normally proportional to the time the injectors are firing. Alternatively, it may be inverted,
with the negative period indicating
the firing of the injectors. Since all
calibration is done in software, either
negative or positive duty cycles can
be monitored.
This project will accept all of these
types of signals and with software
calibration via the USB port, it is easy
to adapt to a wide range of different
sensors.
How it works
The block diagram of Fig.1 shows the
main features of the circuit. As you can
see, a microcontroller is the heart of
the project and it drives the dot matrix
displays, manages the USB connection
and drives the two outputs.
siliconchip.com.au
Fig.3 shows the circuit of the main
board while Fig.4 shows the circuitry
of the display board. In Fig.3, IC1 is the
PIC18F4550 microcontroller and there
are four multi-way terminal blocks.
CON1 (4-way) provides the connections to the battery or DC supply.
The 12V input from the car’s battery is
passed through a 10Ω 1W resistor and a
reverse polarity protection diode (D1).
The 10Ω resistor will normally drop
around 2V since the circuit typically
draws around 200mA, depending on
the display brightness and the number
of lit pixels.
A 16V zener diode (ZD1) clamps
the input voltage in case of transients. This is necessary to protect
both the input supply bypass capacitor (470μF, 25V) and the 3-terminal low-dropout regulator REG1
(a LM2940-5).
The entire circuit runs from the +5V
rail output by REG1. This supply rail
is bypassed by a 47μF 16V capacitor
and the 100nF monolithic capacitors
near the microcontroller and the other
logic ICs.
CON2 (4-way) accepts the two
identical frequency/duty cycle inputs.
Considering pin 2 of CON2, for example, the signal is applied to the base
of NPN BC337 transistor Q19 through
a 33kΩ resistor. The 10kΩ resistor to
ground sets the switching threshold to
around +2.6V. That is, the transistor
switches on when the signal input
is above +2.6V and switches off for
voltages below that.
Diode D5 clips any negative voltage
excursions of the signal to the base of
the transistor to around -0.6V.
The collector output of the transistor
is pulled up by a 10kΩ resistor and is
fed to the CCP1 (Capture/Compare) input (pin 17) of IC1 via a low-pass filter
composed of a 1kΩ resistor and a 10nF
capacitor. This low-pass filter removes
potentially noisy signal transitions.
The frequency and duty cycle of the
input signal is measured by capturing
the value of an internal timer run from
the microcontroller’s system clock
(12MHz). It counts how many system
clock ticks occur when the signal is
low and when the signal is high.
TYPICAL DISPLAY READOUTS
siliconchip.com.au
The counter is 24 bits wide. For
example, when applying a 40% duty
cycle rectangular wave at 100Hz, we
will obtain the following counter
values:
CHigh = 48,000 and CLow = 72,000
In other words, the internal timer
running from 12MHz counts up to
48,000 in the time that the signal is
high and up to 72,000 in the time the
signal is low.
From these two values, the firmware
calculates the frequency and duty
cycle as follows:
Freq = 12,000,000/(CHigh+CLow); and
Positive Duty Cycle = 100CHigh/(CHigh+CLow)
Voltage/resistance inputs
The four voltage/resistance inputs
are connected to the 6-way connector
CON3.
Each analog input passes through
a voltage divider consisting of 22kΩ
and 10kΩ resistors and bypassed by
a 100nF capacitor. Each resulting
voltage is then digitised by the microcontroller using the onboard ADC
(analog-to-digital converter) which has
10 bits of resolution and whose full
range is from 0-5V.
The division factor from the 22kΩ
and 10kΩ resistors is 3.2 which means
that the analog inputs have a full range
of 0-16V, suitable for most applications in a car or any vehicle with a
12V battery.
Any voltages above 16V will not
be correctly read (ie, readings will
plateau), because the input protection
diodes on the ADC inputs of IC1 will
begin to conduct. The high series input
impedance will ensure that the input
Fig.2: these diagrams illustrate some
of the readouts that can be scrolled
across the three 7 x 5 dot matrix
displays. The battery and ambient
light functions are built in, while all
other functions are set-up by the user
via a PC program.
December 2008 31
+5V
100nF
100nF
11
32
Vdd
Vdd
AN5
10k
1k
CON2
FQ1
FQ2
GND
33k
2
C
B
K
3
10k
1
E
D5
Q19
BC337
17
47 µF
16V
1k
CCP1
RE2
RE1
100nF
8
10k
10
9
10nF
D7
MCLR/Vpp
K
1
A
A
+5V
PGD/RB7
PGC/RB6
10k
1k
33k
B
K
10k
C
E
D6
Q18
BC337
16
IC1
PIC18F4550
10nF
RA4
RB5
RB4
RB3
RB2
RB1
CON3
AN3
AN2
AN1
AN0
GND
1
2
RB0
4 x 22k
5
3
4
4
3
5
2
6
RD7
AN3
RD6
AN2
RD5
AN1
RD4
AN0
RC7
RC6
10k
100nF 10k
100nF 10k
100nF 10k
100nF
RD2
RD0
D+
D–
RC0
13
X1
20MHz
22pF
RD1
OSC1
AN4
RD3
14
22pF
OSC2
VUSB
Vss
12
SC
2008
CAR SCROLLING DISPLAY
39
CCP2
A
+5V
40
Vss
31
6
38
37
36
35
34
33
30
29
28
27
26
25
21
19
24
23
15
20
7
22
18
1 µF
16V
1 µF
16V
10k
MAIN BOARD
Fig.3: the main board circuitry. PIC microcontroller IC1 accepts the various analog and frequency input signals,
processes these signals and then drives the separate display board via connector CON6.
itself is not damaged.
The downside of having a large
dividing factor of 3.2 (16V = 5V x 3.2)
is that you lose resolution in the ADC
conversion. Since the ADC is 10 bits
32 Silicon Chip
or 1024 levels, we obtain a value of
16V/1024 or about 16mV sensitivity.
While this is plenty for most applications, you can increase the sensitivity of the input if you know in advance
that your sensor has a nominal output
much lower than 16V. This involves
changing the 22kΩ resistor on the corresponding analog input.
The following equation is used
siliconchip.com.au
D1
REG1 LM2940-5
OUT
K
IN
GND
A
10 Ω 1W
+12V
100nF
A
56k
ZD1
16V
1W
2
1
(BATTERY SENSE)
CON4
A
1k
C
B
2
A
Vpp
GND
6
1k
C
B
AUX
4
PGD
5
PGC
RLY1
1
D3
Vdd
3
RLY2
3
2
K
K
(ICSP)
1
4
D2
Q16
BC337
E
+5V
4
3
K
470 µF
25V
CON1
E
Q17
BC337
220 µF
50V
TO CON7
ON DISPLAY
BOARD
CON5
CON6
+5V
6
24
23
1
2
3
4
5
7
22
8
9
10
11
12
14
21
26
20
16
25
27
13
17
K
D4
A
1.5k
A
18
19
GND
K
D1-D3: 1N4004
BC337
A
B
E
A
to get an approximate value for the
resistor:
R = 2000V - 10,000
where V is the maximum voltage range
required (>5V) and R will be the new
siliconchip.com.au
GND
K
ZD1
C
LM2940-5
IN
K
GND
Oxygen sensor loading
Although the ADC inputs of IC1
have a high input impedance, the load
on the analog inputs will be the sum
of the 22kΩ (or your replaced value)
resistor and the 10kΩ resistor, ie, 32kΩ
(or 10,000 + R).
While this loading is high enough to
result in very small current draw from
most sensors in your car, you should be
aware that typical narrowband oxygen
sensors do not tolerate more than about
10μA current load. Since the ECU will
have its own current load, we should
aim to draw no more than about 1μA
extra from such a sensor.
This means that if you wish to connect an oxygen sensor to this project,
you should omit or remove the 10kΩ
resistor to ground on the corresponding analog input. The result will be
that the loading will then be the series
impedance of the 22kΩ resistor and
the high input impedance of IC1’s
ADC input.
The resulting extra current should
be less than 1μA since the ADC inputs
have a typical leakage current of just
500nA. Note that there will also be
negligible transient loading due the
100nF capacitor.
Additional input channels
15
D4-D6: 1N5819
D7: 1N4148
sensitivity will be about 6mV and the
resistor value will be 2kΩ.
Since all calibration is done in soft
ware, you only need to replace the
22kΩ resistor corresponding to your
analog channel to improve the accuracy for that channel. The software
does not need to be changed, as the
values will be correct for your new
divider when you perform the next
calibration.
OUT
resistor value (ie, to replace the existing 22kΩ resistor).
The resulting sensitivity will be
approximately the value of V in mV
(millivolts); eg, if V = 6, then the
There are two additional analog
channels used. One is used to measure
the battery voltage at pin 1 of CON1.
It has its own 56kΩ and 10kΩ voltage
divider and 100nF bypass capacitor.
The other analog channel is used
to monitor a voltage divider on the
display board consisting of a light dependent resistor (LDR1) and an 82kΩ
resistor. The analog signal is at pin 13
of CON6 and is used to measure the
ambient light level, to vary the brightness of the LED display.
CON4 is used to connect the relays
and/or buzzers used for the limit
conditions.
Each digital output from the microcontroller is applied to the base of an
December 2008 33
CON7
3.3
+5V
Q1
6
470F
16V
B
15 x 680
1
Q2
E
Q7
E
B
C
+5V
E
B
C
Q8
Q15
E
B
C
B
C
E
C
2
3
4
21
5
22
23
9
24
10
25
26
8
27
C1-C15
1
17
16
20
19
12
1k
12
11
13
Sin
16
1
16
Vdd
Q0
Q1
Q2
Q3
MR
14
CK
C15
9
100nF
10
14
C7
+5V
G
11
SER
C8
4
C2
C1
USB TYPE B
SOCKET
1
2
3
3
IC2 Q4 4
74HC595
5
4
Q5
6
Q6
7
Q7
9
So
LCK
SRCK
OE
15
2
15
12
LED ARRAY 3
B
+5V
E
C
Q1 – Q15: BC327
11
6
Vss
10
7
LDR
13
LED ARRAY 2
13
5
8
LED ARRAY 1
14
LDR1
S1
IC3: ULN2003
8
S1
7
82k
1k
GND
15,18
SC
2008
CAR SCROLLING DISPLAY
DISPLAY BOARD
Fig.4: the Display Board circuit. It uses a 74HC595 shift register (IC2) to drive the rows of the three dot-matrix LED
arrays via a ULN2003 Darlington array (IC3). Transistors Q1-Q15 switch the display columns.
NPN BC337 transistor (Q16 or Q17)
via a 1kΩ resistor. Each transistor is
configured as a switch, to drive the coil
of the relay or a 12V buzzer. Diodes
D2 & D3 clip any back-EMF spikes
generated when the relays switch off,
while the 220μF 50V capacitor is used
for bypassing.
The microcontroller (IC1) runs from
a 20MHz crystal and the two 22pF
ceramic capacitors provide the correct
loading. The 1kΩ resistor from the 5V
34 Silicon Chip
rail is used to pull up the MCLR-bar
input (pin 1) of the microcontroller
(this is the active low reset input). The
microcontroller is reset by internal
POR (power on reset) circuitry.
CON5 is optional unless you fancy
doing your own programming using
the PicKit2 programmer from Microchip. We used this during development of this project. You will not
normally need to use this connector.
There is one further sub-circuit
on the main board, consisting of a
Schottky diode D4 and two resistors
(10kΩ and 1.5kΩ). Pin 17 of the 27-pin
connector CON7 is the VUSB rail (ie,
positive power from the USB port on
the display board).
This will be around +5V when a
USB cable is connected and 0V otherwise. This input passes through the
voltage divider consisting of 1.5kΩ and
10kΩ resistors. The division factor is
thus 1.15 meaning that pin 22 of IC1
siliconchip.com.au
will be at around 4.3V when a USB cable is connected and at 0V otherwise.
This pin is configured as a digital
input (bit 3 of PORT D) which allows
the firmware to detect when a USB
cable is connected or disconnected.
Schottky diode D4 allows the circuit
to be powered directly from the USB
port and connects directly to the +5V
rail. In the worst case, the VUSB line
will be at +4.75V (5V ±5% is what the
USB standard specifies) and so the
+5V rail can be as low as +4.5V when
powered directly from the USB port.
D4 also protects against reverse
polarity and prevents current flow
into the USB port when the circuit is
powered from a 12V battery or power
supply.
Because the +5V rail can be substantially lower than +5V when powered
from the USB port, you MUST perform
any calibration with the full 12V input
from the car battery. The actual voltage of the +5V rail will affect the ADC
readings from the analog channels
because it is the positive reference
for the ADC conversion. This will be
explained in the calibration instructions, next month.
Display circuit
Microcontroller IC1 controls the
display via 27-pin connector CON6,
which plugs into CON7 on the display
board – see Fig.4. Fifteen of these lines
control BC327 PNP transistors to drive
the columns of the LED display.
The display board consists of three
dot matrix LED modules, a 74HC595
shift register (IC2) and a ULN2003
Darlington driver (IC3). The display
is multiplexed, meaning that only
one column is lit at any one time. The
brightness of the display is varied by
changing the duty cycle of the column
driving signals. The display refresh
frequency is around 150Hz.
IC2 is an 8-bit shift register and the
seven least significant bits (Q0-Q6)
are used to drive the seven rows of
the display. The microcontroller uses
three lines – SER (data input), G-bar
(output enable) and CK (clock) – to
load each row value into IC2.
The G-bar (enable) line forces all
outputs of the shift register to go
tri-state. This effectively blanks the
display. This is done by the microcontroller when the display is being
refreshed or when the shift register is
being loaded. The time that the display
is disabled is so short it is impercepsiliconchip.com.au
Main Features & Specifications
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Can be powered from 9-12V DC or from a USB port (5V).
Two Frequency/Duty Cycle Inputs with frequency up to 10kHz.
Positive Duty Cycle Range: 0-100%.
Four Voltage/Resistance Inputs Plus Battery Voltage (the latter has its
own channel).
Voltage Range: 0-16V (greater or smaller ranges possible by changing
one resistor).
Sensitivity with 16V scale: approx. 16mV.
Best Sensitivity: approx. 5mV (requires changing one resistor and
recalibrating using the supplied PC software).
Two output channels to drive external relays or buzzers.
Up to 10 displayed variables.
Averaging or direct acquisition mode for each variable.
Screen dimming on ambient light with adjustable sensitivity and
selectable minimum brightness.
7 x 15 dot matrix LED display (scrolling or static display).
Static display of up to 4 digits (floating point)
Selectable scrolling speed.
On screen limit warnings for each variable in the static display mode.
Software calibration using polynomial interpolation.
Persistent settings stored in non-volatile memory.
Easily load and store previous settings to file on your computer.
Easily load and store different calibration point files on your computer.
All settings changeable using the USB port and PC host program.
Data logging via the USB port; selectable variable update frequency
from 0.1-8Hz; can collect 1000s of samples to a PC’s hard drive.
tible. The SER (data) line feeds the
data into the shift register and is also
controlled by a simple digital output
of the microcontroller.
The seven bits from the shift register
are used as inputs to the ULN2003
Darlington array (IC3). The ULN2003
can sink up to 500mA in total between
its seven outputs.
Note that there are no current limiting resistors to the displays. Instead,
we rely on the beta limiting of the
transistors via the 680Ω base drive
resistors. We found that even smallvalue limiting resistors markedly
decreased the perceived brightness of
the LED display.
However, we have included a 3.3Ω
current-limiting resistor on the supply
rail to the entire display board. Because the display can draw substantial
currents (up to around 300mA peak),
thereby affecting the +5V rail used
for the positive reference to the ADC
system, the firmware also turns off
the display when digitising the analog
Fig.5: in-range measurements appear
as shown at left, while out-of-range
measurements alternate between
normal and reversed mode (top right)
when above maximum or flash on and
off when below minimum.
inputs. This happens too quickly to be
perceptible.
An additional digital input on IC1 is
used for pushbutton switch S1. It will
be high when S1 is pressed and low
otherwise. The signal is fed via CON6
at pin 7 and the switch is de-bounced
by the software.
The USB type B socket is on the
display board and the four connections
are fed to the main board via CON6.
That completes the circuit description. Next month we give the full
constructional details and set-up proSC
cedure, as well as the parts list.
December 2008 35
|