This is only a preview of the June 2016 issue of Silicon Chip. You can view 42 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. Items relevant to "Stereo Audio Level/VU Meter: Add Bling To HiFi System":
Items relevant to "Arduino-Based Cooling System Monitor":
Items relevant to "Hotel Safe Alarm For Travellers":
Items relevant to "Budget Senator 2-Way Loudspeaker System, Pt.2":
Purchase a printed copy of this issue for $10.00. |
Add bling to your hifi amplifier!
Pt.1: By Nicholas Vinen
100dB Stereo LED
Audio Level/VU Meter
Give your hifi system WOW factor with this spectacular stereo
VU meter. It uses 80 high-brightness SMD LEDs to give any stereo
amplifier/mixer a highly colourful dual-bargraph display which
simultaneously shows the average audio signal level plus peak
levels. And it can display signal ranges up to a whopping 100dB.
Y
EARS AGO, some big and expensive stereo power amplifiers sported large dual VU meters to indicate
the power levels in both channels. But
while they looked quite impressive,
they were a bit of a gimmick since their
analog meter movements could only
display signal averages. They certainly
weren’t fast enough to display the peak
signal levels which would have been
a big advantage.
And of course, professional audio
mixing desks also typically have VU
metering but these days it is usually
based on LED arrays which show average and peak signal levels, just like
this new SILICON CHIP design!
The SILICON CHIP Stereo LED VU Meter uses no less than 80 high-brightness
SMD LEDs to give a dual bargraph dis32 Silicon Chip
play of the average audio signal level,
with dots indicating the peak levels. It
can be configured to display a dynamic
range between 40dB and 100dB, depending on your application. It’s suitable for monitoring line level signals
or power amplifier outputs.
Whether or not you actually need to
add this meter to a piece of equipment,
once you see it in action, you’ll want to
fit it in anyway! We’ve put a video of it
operating at the following URL so you
can see for yourself: www.siliconchip.
com.au/Videos/StereoVUMeter
If you are a keen hifi enthusiast, this
VU meter can show you how much
headroom you have from your audio
amplifier, ie, it can show how many
more decibels it is capable of delivering before clipping and this is indi-
cated with the peak dot display.
It can also be used when recording
or mixing, to ensure that the incoming audio signal(s) are consistent with
each other and none of them are going
to overload and cause excessive distortion or loss of dynamic range.
One important feature of an audio
level meter is that it should update
relatively fast, so you can see the dynamic nature of the signal, but not so
fast that your eye can’t track it. Traditional “VU Meters” were designed
with a response time of 300ms (to
99%), to give a reasonable impression
of signal loudness but also because the
needle could only move so fast.
Since this meter uses digital technology, it can show the peak and average level simultaneously and the peak
siliconchip.com.au
+3.3V
LEFT
INPUT
CON1
+1.65V
x 23
AN9
x 23
RC7
AN2
22k
RC8
RC6
AN0
RC5
RC4
AN11
+3.3V
RC3
RC2
RIGHT
INPUT
CON2
VR1
BRIGHTNESS
+1.65V
RC1
RC0
(HPF)
(HPF)
22k
LPF
x 23
AN1
VDD
(8 MODE LEDs TOTAL)
+3.3V
+3.3V
A
LED81
A
λ LED82
40dB
A
λ LED84
80dB
K
+3.3V
A
λ LED83
60dB
K
+3.3V
λ
100dB
K
S1
RB3
RA7
RB4
RA10
RB5
RB12
RB6
RA9
RB10
RB7
RB11
K
RB2
RB8
RB9
λ
λ
λ
λ
LED3
λ
λ
λ
λ
LED2
λ
λ
λ
λ
λ
λ
λ
λ
A7
A6
A5
A4
A3
A2
A1
A
(80 LEDs
TOTAL
IN MATRIX)
AN3
22k
LED4
A8
IC1
PIC32
AN10
x 23
LED34
LPF
A10
A9
LED33
22k
RC9
LED32
(HPF)
LED31
10-BIT
ANALOGTO-DIGITAL
CONVERTER
(HPF)
LED1
A
K
K
D
Q1
K1
K2
G
D
S
Q2
K3
K4
K5
K6
K7
G
D
S
G
Q3
D
S
K8
G
S
S2
Fig.1: a simplified circuit showing how the Stereo VU Meter works. The audio signals (left & right channels) first pass
through a high-pass filter/attenuator, followed by an active low-pass filter and two gain stages. The signals before and
after the gain stages are then fed to microcontroller IC1 which does the peak and average calculations, then drives a
multiplexed LED display using outputs RB2-RB9 to control eight cathode-driving Mosfets (Q1-Q8) and outputs RC0RC9 to drive the LED anodes directly.
level can have a fast rise time and a
slow fall time. The fast rise-time allows the circuit to “catch” those very
fast and short peaks, while the slow
fall time allows you to better see them
when they occur.
For purists, we’ve implemented a
VU-style meter mode so you can stick
with the traditional 300ms rise/fall
time averaging if that is what you want.
The two bargraphs, one for each stereo channel, consist of 40 individual
LEDs. With a dynamic range of 40dB,
that means that each LED lights for a
1dB increase in signal level. If you select the 60dB range, that gives 1.5dB/
LED; the 80dB range gives 2dB/LED;
and the 100dB range, 2.5dB/LED.
These are SMD LEDs with rectangular lenses roughly 2mm square – and
they are incredibly bright pin-points.
An on-board pot can be set reduce the
brightness for a darker room!
We’ve used a green/yellow/amber/
red colour scheme. The colour shifts
simply give a warning that you are approaching the clipping level.
A pushbutton can select one of four
siliconchip.com.au
full-scale signal levels: -10dBV, 0dBV,
+4dBu or +7dBV. Different equipment
will have different line levels and one
of these will suit most devices: -10dBV
(316mV RMS) for some battery-powered consumer equipment such as
iPods and mobile phones, 0dBV (1V
RMS) for other consumer equipment,
+4dBu (1.228V RMS) for some professional gear and +7dBV (2.24V RMS)
for CD, DVD and Blu-ray players and
some other equipment.
You can make fine or coarse adjustments to these levels or set your own
levels based on reference signals fed
into the unit.
The unit runs from a 12-15V DC supply so it can be powered from a small
plugpack, 12V lead-acid battery or a
low-voltage internal rail in an amplifier or similar equipment. It only draws
about 50-150mA when operating, depending on the LED brightness setting.
The PCB includes RCA input sockets and a DC socket for power, so it can
be used in its own case with a clear lid
or incorporated into another piece of
equipment and hard-wired in place.
The metering circuit’s signal-tonoise ratio is good enough to allow you
to use the 100dB range with a +7dBV
reference level and use the whole
range of the device. The 100dB range
can also be used with a lower reference level but you will need to use
the noise nulling feature to get a blank
display with no signal. This feature
is especially useful to subtract source
noise (eg, from the driving equipment)
from the display when operating in the
higher dynamic range settings.
Other features include: software
adjustments to cancel out variation
in brightness between different colour LEDs; peak+average, peak-only
and average-only modes; non-volatile
mode and calibration settings; and
mode indicator LEDs (see specifications panel for more details).
Principle of operation
Fig.1 is a simplified circuit diagram
which gives an overview of the operation of the unit. It’s based on 32-bit
microcontroller IC1 which operates
at 40MHz and incorporates a 10-bit
June 2016 33
Features & Specifications
•
•
Display: two rows of 40 SMD 3216 (1206 imperial) LEDs
Input signal: up to 2.33V RMS (+7.36dBV) or higher with changed resistors (eg,
to suit power amplifier outputs)
•
•
•
Frequency response: 5Hz-20kHz, -3dB (see Fig.2)
•
Meter range: selectable 40dB, 60dB, 80dB or 100dB (1dB/LED, 1.5dB/LED,
2dB/LED or 2.5dB/LED)
•
Reference level: selectable -10dBV (316mV RMS), 0dBV (1V RMS), 4dBu
(1.228V RMS), 7dBV (2.24V RMS) or custom levels (per-channel)
•
•
Power supply: 12-15V DC, ~50-150mA
•
•
Inputs: RCA sockets for signals, 2.1mm or 2.5mm ID DC socket for power
Input impedance: approximately 37kΩ
Modes: peak+average (dot/bar), average only (bar), peak only (bar), VU-style
(peak+average or average only)
Brightness adjustment: 10-100% via potentiometer (onboard trimpot or chassismounted)
Other features: LED brightness matching for different colour LEDs in display, external/internal noise nulling, peak/average calculation period adjustment, supply reverse polarity protection
analog-to-digital converter (ADC) with
an input multiplexer. Seven of the
analog inputs are used.
The two 40-LED bar displays (80
LEDs in total) are multiplexed in eight
groups, each group of 10 sharing a
common cathode which is driven by
one of eight N-channel Mosfets Q1-Q8,
which are in turn controlled by the
microcontroller’s outputs RB2-RB9.
The LED anodes are driven directly by
outputs RC0-RC9. Only a 4x4 portion
of the 8x10 LED matrix is shown but
you can see the general arrangement.
The eight indicator LEDs (LEDs8188, four shown in Fig.1) are driven
directly at their cathodes from eight
microcontroller outputs. The anodes
connect to the 3.3V supply via currentlimiting resistors.
Actually, there are no current-limiting resistors for the matrixed LEDs, as
such. Instead, their current is limited
by the internal impedance of the transistors which drive the micro’s output
pins, in combination with a softwarelimited on-time/duty cycle.
This results in a current drive of
around 1.2mA/LED at full brightness,
for a total LED bar current of around
100mA. Since this is split between 10
anode drive pins, that means around
10mA per pin. (IC1 has an “Absolute
Maximum” rating of 15mA/pin and an
overall limit of 200mA).
The analog signals are fed into
CON1 & CON2 at left. The circuit is
34 Silicon Chip
designed for line level signals with a
maximum level ranging from around
316mV RMS (-10dBV) up to 2.33V
RMS (+7.35dBV), to suit most consumer equipment and also some professional audio gear. The input divider
resistors can be changed to allow much
higher signal amplitudes, eg, to suit the
outputs of a power amplifier. Further
adjustments in full-scale level can be
made using the pushbutton interface.
The signals are AC-coupled and attenuated to no more than 1.16V RMS
(3.3V peak-to-peak) using a resistive
divider. This AC coupling serves as
a high-pass filter (HPF) to remove DC
and very low frequency signals (<5Hz).
Note that there is another HPF at the
ADC inputs of IC1.
There is also an active low-pass
3-pole filter inserted immediately after the resistive divider, built around
a dual op amp (for both channels) with
a -3dB point of 20kHz. It provides a fast
roll-off, with around 20dB of attenuation by 40kHz and also incorporates
RF filtering. The overall effect of the
low-pass and high-pass filtering on the
frequency response is shown in Fig.2.
Analog-to-digital conversion
The signals from the output of the
low-pass filters are fed directly to a pair
of analog inputs on IC1. These signals
are also amplified by 23 times and the
amplified signal is fed to another pair
of analog inputs. This signal is further
amplified by another 23 times (ie, 529
times total) and fed to a third pair of
analog inputs. The seventh analog input is used to sense the position of the
brightness pot.
The micro samples all seven inputs,
with the six signal inputs sampled
continuously at around 40kHz and the
brightness pot sampled every millisecond or so. For each channel, the software uses whichever signal gives the
most accurate reading, ie, the unamplified input for higher level signals and
one of the amplified inputs for lower
level signals. This greatly improves its
dynamic range, given that it only has
a 10-bit ADC.
A perfectly noiseless 10-bit ADC
would give a dynamic range of around
20log10(210) = 60dB. CD-quality audio
uses 16 bits and has a dynamic range
of 20log10(216) = 96dB, so it is desirable for our VU meter to have a similar
dynamic range.
We could have used an external
ADC however these mostly come in
fine-pitch SMD packages and can be a
little expensive. Instead, we have used
the two gain stages described above,
in combination with software input
switching depending on signal level,
to effectively provide the extra bits
needed to achieve a 100dB dynamic
range while only using the existing
10-bit ADC.
Two momentary pushbuttons, S1
and S2, are used to configured the unit.
These can be used to change a variety
of settings such as the meter range,
reference level, peak/averaging mode,
level calibration, brightness calibration and so on. When pressed, S1 pulls
input RB10 low while S2 pulls RB11
low. These are held high by internal
pull-up resistors which are enabled by
the firmware.
In essence, the circuit concept is
relatively simple but a lot of the work,
including the peak and RMS calculations, averaging, display multiplexing
and so on are done by IC1’s firmware.
Full circuit description
The full circuit diagram for the Stereo VU Meter is shown in Fig.3. The
left and right channel input circuitry
is identical so we will describe the left
channel only, with part numbers for
the right channel in brackets.
From CON1 (CON2), the signal is
AC-coupled via a 2.2µF ceramic capacitor and DC biased to +5.6V via a
22kΩ resistor. The 5.6V rail is half the
siliconchip.com.au
11.2V op amp supply, allowing the signal to swing symmetrically between
the op amp supply rails (ie, between
0V and 11.2V).
This 22kΩ bias resistor forms a divider in combination with the input
series resistor, attenuating the input
signal by half while keeping the input
impedance relatively high at around
37kΩ. As explained later, these resistor values can be changed to allow the
unit to handle higher signal levels.
As stated earlier, the 2.2µF capacitor
and 22kΩ series resistor form a highpass filter for the input signal. Further
high-pass filtering is also performed
by the software.
Dual SMD Schottky diode D2 (D3)
clips the input signal, should it go
below ground or above the 11.2V op
amp supply rail. The BAT54S has a
low forward voltage of around 0.3V,
so it will conduct before the junctions
in the op amp's inputs.
Low-pass filter
The following active 3-pole lowpass filter is built around an NE5532D
low-noise op amp IC2a (IC2b). The
first section of this filter, consisting of
a 3.9kΩ series resistor and 680pF capacitor, also serves to attenuate much
higher frequency signals (eg, AM radio) which may have been picked up
by the signal leads.
This filter is a special case of the
Sallen-Key active low-pass filter (see
www.beis.de/Elektronik/Filter/Act3PoleLP.html) which gives a -18dB/
octave roll-off using a single active
device (in this case, an op amp). The
values were chosen carefully, to give
a near-flat bandpass response (ie, Butterworth characteristic) using E24-series resistors and E12-series capacitors
(see Fig.2).
Note that the 3.9kΩ resistor was
chosen with the 11kΩ impedance of
the preceding divider being taken into
account. In other words, the resistance between the input and the 680pF
capacitor should be 14.9kΩ; the two
22kΩ resistors are effectively in parallel when considering the impedance
feeding the RC filter, hence we subtracted 11kΩ from 14.9kΩ to get 3.9kΩ.
The filtered output from pin 1 of
IC2a (pin 7 of IC2b) is fed to analog input AN0 (AN1) of microcontroller IC1
via a 2.2µF capacitor and 1kΩ series
resistor. This resistor, in combination
with dual Schottky diode D4 (D7), prevents the voltage at the micro’s input
siliconchip.com.au
Fig.2: frequency response for the analog portion of the circuitry. The steep (-18dB/
octave) roll-off of the low-pass filter can be seen, with virtually no attenuation below
15kHz, -3dB at 20kHz, -10dB at 30kHz and around -20dB at 40kHz (not visible). The
bass roll-off is from two passive high-pass RC filters and gives a -3dB point of 5Hz
and -10dB at around 1.6Hz.
from going below -0.3V or above +3.6V.
In addition, a 22kΩ resistor provides
a DC bias of 1.65V, ie, the halfway
point of the micro’s 3.3V supply. This
keeps the signal within the ADC’s input range of 0-3.3V for input signals
of up to 2.33V RMS (keeping in mind
the 2:1 input attenuation).
While the micro has internal clamp
diodes to protect its inputs and it might
seem like D4 & D7 are overkill, we discovered an interesting “feature” of the
PIC32 series – if you drive an analog
input pin beyond its supply rails, even
within its input current rating, the
chip may reset! Hence these clamp
diodes are mandatory and as before,
Schottky diodes are used because they
will conduct before the IC’s internal
semiconductor junctions.
Gain stages
IC3a (IC3b) and IC4a (IC4b) are both
configured as non-inverting amplifiers
with a gain of 23, set by the ratio of
the 22kΩ and 1kΩ feedback resistors.
A 100pF capacitor across the 22kΩ
resistor rolls off its frequency response,
reducing high-frequency noise gain
and making the whole circuit quieter.
To achieve the 100dB dynamic range
relative to 7dBV (2.24V RMS), we need
less than 22.4µV RMS input-referred
noise throughout the entire system.
That is why we’re using NE5532 lownoise op amps.
The total gain of the system from the
input to analog input AN9 (AN10) is
0.5 x 23 x 23 = 264.5 times. A -100dB
(2.24µV) input signal will thus be amplified to 6mV RMS. The 10-bit ADC
can sense voltage steps of 3.3V ÷ 1024
= 3.2mV. So this level of signal can be
(just) measured by IC1.
Driving the LEDs
Driving the 80 LEDs in the VU meter
takes up a total of 18 output pins. Each
bar of 40 LEDs is broken up into four
groups of 10 and the cathodes of the
LEDs in each group are tied together.
These cathodes are driven by one of
logic-level Mosfets Q1-Q8 which are
in turn driven from microcontroller
outputs RB2-RB9 (pins 23, 24, 33, 4144 and 1 of IC1 respectively). Because
these Mosfets have such a small gate
charge, no extra circuitry is required.
Each Mosfet is switched on in turn for
around 1.6ms.
When Q1 is switched on (ie, pin 23
of IC1 [RB2] is high), LED1-LED10 can
be lit when their respective anodes are
driven high. The anodes are driven by
outputs RC0-RC9 of micro IC1 (pins
25-27, 36-38 & 2-4 respectively).
June 2016 35
+11.2V
+11.2V
100nF
X7R
D2
BAT54S
LEFT
INPUT
CON1
100nF
X7R
+3.3V
X7R
2
22k
3
16V
X7R
1nF
680pF
50V
C0G
50V
C0G
22k
8
3
1
IC2a
2
20k
22k
3.9k
8
3
1
2.2µF
2
4
22k
22k
100pF
100pF
50V C0G
50V C0G
1k
D4 BAT54S 1k
3
IC2, IC3, IC4: NE5532D
5
1
22k
1k
+3.3V
2
1nF
50V
C0G
5
5
7
IC2b
6
20k
22k
50V
C0G
22k
+5.6V
2
1
+1.65V
2
3
680pF
D5 BAT54S
+5.6V
D3
BAT54S
3.9k
1k
2.2µF
3
3
+11.2V
16V
X7R
1k
22k
2.2µF
22k
2
1
4
2.2µF
50V
C0G
1
2.2µF
2
D6 BAT54S
1
IC4a
100pF
+5.6V
22k
8
3
1
IC3a
4
+1.65V
RIGHT
INPUT
CON2
100nF
7
IC3b
6
6
D9 BAT54S
7
IC4b
2.2µF
100pF
50V
C0G
22k
100pF
100pF
50V C0G
50V C0G
1k
22k
2.2µF
22k
+1.65V
1k
D7 BAT54S 1k
+5.6V
22k
1k
2.2µF
3
D8 BAT54S
+5.6V
2
1
+1.65V
22k
1k
+5.6V
1
2
1
3
3
2
+3.3V
+3.3V
VR1
10k
4x1k
A
A
+11.2V
8
2.2µF
5
16V
X7R
IN
OUT
REG2
MIC5201YM
ADJ
EN
GND NC NC NC
3 4 6 7
1
1.5k
2
10Ω
A
1k
2.2µF
16V
X7R
12k
A
+5.6V
K
LED81
λ
60dB
λ
80dB
+
D1
SS14
TPV+
6.3V
X5R
K
4x1k
A
A
K
33Ω 1W
q
CON3
TPG1
2.2µF
16V
X7R
TP3.3V
REG1
MCP1703-3302E/DB
1
IN
OUT
GND GND
2
4
A
A
+3.3V
3
LED85
λ
-10dBV
3.9k
LED86
LED87
λ
0dBV
λ
7dBV
K
K
K
+1.65V
6.3V
X5R
47µF
6.3V
X5R
BZX84-C5V6
SS14
SC
λ
4dBu
LED88
K
10µF
3.9k
2016
K
K
A
12VDC
POWER
λ
100dB
K
47µF
ZD1
BZX84 A
C5V6
λ
40dB
LED82
LED83
LED84
DIGITAL STEREO AUDIO LEVEL/VU METER
K
A
K
A
(NC)
Fig.3: full circuit for the Stereo VU Meter. This shows the full 80-LED matrix at right, along with the power supply and
details of the analog circuitry. Dual Schottky diodes D2 & D3, in combination with the 22kΩ series resistors, protect IC2
from excessive input signal levels while D4-D9 (with 1kΩ series resistors) prevent IC1’s internal input clamp diodes
36 Silicon Chip
siliconchip.com.au
RIGHT CHANNEL
LEFT CHANNEL
RPC6/PMA1/RC6
RPC5/PMA3/RC5
RPC4/PMA4/RC4
RPC3/RC3
AN8/RPC2/RC2
AN7/RPC1/RC1
AN6/RPC0/RC0
RS529
14
RS23
22
RS1
20
5
A10
4
A9
3
A8
2
A7
38
A6
37
A5
36
A4
27
A3
26
A2
25
A1
AN10/RB14/RPB14
LED7
λ
λ
λ
λ
λ
λ
λ
λ
λ
λ
λ
λ
LED4
λ
λ
λ
λ
LED3
λ
λ
λ
λ
LED2
λ
λ
λ
λ
λ
λ
λ
2
AN1/VREFq/RA1
8
5
CON4
A
S1
AN11/RB13/RPB13
LED1
S2
A
23
K1
24
K2
33
K3
PGED3/RPB5/PMD7/RB5 41
K4
42
K5
43
K6
44
K7
1
K8
AN4/RPB2/RB2
AN5/RPB3/RB3
35
SOSCI/RPB4/RB4
RA7/PMA7/TCK
RA10/PMA10/TMS/PGED4
RB12/PMD0/AN12
PGEC3/RPB6/PMD6/RB6
RPB7/PMD5/RB7
RA9/TDI/RPA9/PMA9
RPB8/PMD4/RB8
RPB9/SDA1/PMD3/RB9
34
32
31
30
λ
LED78
λ
λ
λ
λ
LED77
λ
λ
λ
λ
LED76
λ
λ
λ
λ
LED75
λ
λ
λ
λ
LED74
λ
λ
λ
λ
LED73
λ
λ
λ
λ
LED72
λ
λ
K
λ
λ
LED79
K
G
A
A
λ
λ
K
LED71
K
Q1
D
S
G
Q2
D
S
G
Q3
D
S
G
Q4
D
S
G
RA4/SOSCO/RPA4
Q5
D
S
Q6
RA8/TDO/RPA8/PMA8
G
RA3/OSC2/CLKO/RPA3
VCAP
RA2/OSC1/CLKI/RPA2
AVSS
16
D2qD9: BAT54S
3
1
λ
K
D
10
λ
A
λ
4
9
TPG1
12
λ
LED40
3
IC1
PIC32MX170
PIC3
2MX170
qF256D
13
λ
LED80
1
RB11/RPB11/PMD1/PGEC2
11
λ
ICSP
RB10/RPB10/PMD2/PGED2
BR
λ
λ
λ
18
AN3/RPB1/RB1/PGEC1
TPBR
λ
LED50
RPC7/PMA0/RC7
λ
LED39
LED49
RPC8/PMA5/RC8
K
LED8
λ
LED38
LED48
RPC9/PMA6/RC9
AN0/VREF+/RA0
λ
λ
LED37
LED47
19
MCLR
AN9/RB15/RPB15
AN2/RPB0/RB0/PGED1
λ
λ
K
LED31
LED41
LS1
X7R
40
VDD
28
VDD
λ
LED6
21
17
AVDD
LED9
LED5
15
X7R
A
10k
100nF
K
A
λ
LED36
LED46
100nF
X7R
LS23
λ
λ
K
100nF
LS529
λ
LED35
LED45
10Ω
λ
LED34
LED44
LED10
A
LED33
LED43
A
LED32
LED42
+3.3V
2
VSS
6
VSS
29
VSS
39
REG2, IC2qIC4
8
7
6.3V
X5R
4
1
G
10µF
CATHODE
BAND
A
D
S
Q7
D
S
G
Q1-Q8: 2N7002P
LEDS
K
D
G
S
Q8
S
MCP1703T-3302E/DB
4 (GND)
(IN) 1
(GND) 2 3 (OUT)
from conducting, depending on the signal applied. Also shown in more detail on this diagram are the three different
signal bias levels of 0V (GND), 1.65V (half supply for 3.3V) and 5.6V (half supply for 11.2V). The amplified and filtered
input signals are fed to microcontroller IC1 which drives the LED bargraphs via Mosfets Q1-Q8.
siliconchip.com.au
June 2016 37
Simulating VU Meter Response
The adjacent photo shows an original
VU meter. According to Wikipedia: “The
original VU meter is a passive electromechanical device, namely a 200µA DC
d’Arsonval movement ammeter fed from
a full-wave copper-oxide rectifier mounted
within the meter case. The mass of the
needle causes a relatively slow response,
which in effect integrates the signal, with a rise time of 300ms. 0 VU is equal to
+4dBu, or 1.228V RMS across a 600-ohm load . . .”
The SILICON CHIP Stereo LED VU Meter does not attempt to exactly replicate the
operation of a VU meter. For example, the copper-oxide rectifier causes a VU meter
to be inaccurate for low-level signals and thus makes a reading below -20dB difficult. We’re still using proper RMS calculations and showing readings on a range of
at least 40dB (depending on the range setting of the unit).
However, we have been able to implement a simulation of the ballistic properties of
the VU meter needle in our software. When a 1kHz sinewave is applied to a standard VU
meter which had previously had no signal applied, it should reach 99% of the final reading in 300ms and have an ultimate overshoot of between 1% and 1.5% of the reading.
We’ve achieved this with a simple needle inertia simulation that tracks the needle
position and velocity along with a target position (based on the current RMS reading), an acceleration coefficient and a damping coefficient. These two coefficients
were tuned to achieve the required response, as stated above.
The cathodes of LEDs81-88 are driven by microcontroller outputs RA9,
RB12, RA10, RA7, RA8, RA3, RA2 and
RA4 respectively (pins 35, 10, 12, 13,
32, 31, 30 and 34). The 1kΩ currentlimiting resistors result in a drive of
around 0.5mA each.
Controls
Tactile pushbutton switch S1 is used
to cycle through the available meter
ranges (and performs other functions
when pressed and held or pressed
in combination with S2). Similarly,
switch S2 cycles through the four different reference levels. Their associated input pins, RB10 and RB11 (pins
8 & 9), are also used for programming
and debugging IC1. There is no conflict
as long as neither switch is pressed
when the in-circuit serial programming (ICSP) tool plugged into CON5
is being used.
Brightness pot VR1 forms a voltage
divider across the 3.3V supply and
the voltage at its wiper is sensed via
analog input AN11 (pin 11) of IC1. The
brightness is controlled by adjusting
the LED matrix anode drive period.
Power supply
The power supply is relatively simple and uses only linear regulators but
its design is critical to achieve the stat38 Silicon Chip
ed performance. 12-15V DC is applied
to socket CON3, or else wired directly
between TPV+ and TPG1.
Schottky diode D1 provides reverse
polarity protection and drops less than
0.4V. The 11.6-14.6V DC at its cathode
is fed to two resistors. One is a 33Ω 1W
SMD type which connects to the input
of 3.3V low drop-out (LDO) regulator
REG1. This is in a relatively large SOT223 4-pin package that is soldered to
a considerable copper area which includes thermal vias to conduct heat to
the back of the board.
With a 14.5V input, 3.3V output
and maximum load of 125mA, these
components dissipate (14.5V – 3.3V)
x 0.125A = 1.4W. Around 0.5W will
be dissipated in the resistor with the
remaining 0.9W in the regulator, hence
the copper plane heatsinking on both
sides along with thermal vias under
the regulator package.
SMD multi-layer ceramic capacitors
are used bypass the input and filter the
output of REG1. As well as supplying
the microcontroller and LEDs, the 3.3V
output flows through a pair of seriesconnected 3.9kΩ resistors to generate
the 1.65V rail, which is bypassed with
a 47µF capacitor. This is important
since the varying current demand on
the 3.3V rail as LEDs are switched
causes ripple and we don’t want this
to couple into the input signal path.
The 11.6-14.6V at the cathode of D1
also flows to adjustable low dropout
regulator REG2 (MIC5201). The 10Ω
series resistor forms a low-pass filter
in combination with its 2.2µF input
bypass capacitor to reduce the amount
of ripple reaching REG2. It also causes
a voltage drop of up to 0.25V.
REG2’s output is set at 11.15V (nominal) by the 12kΩ and 1.5kΩ resistors.
REG2’s minimum input voltage is
around 11.6V – 0.25V = 11.35V. With
a load current of only 25mA, REG2’s
dropout voltage is less than 150mV, so
it should stay in regulation. This is important since REG2 exists to eliminate
ripple on the op amp supplies; even
with a 100dB CMRR (common mode
rejection ratio), several hundred millivolts of ripple can have a significant
impact on the overall signal-to-noise
ratio of the system.
The 5.6V half-supply reference for
the op amps is derived from the 11.2V
supply with a 1kΩ resistor and 5.6V
zener diode ZD1, which is bypassed
with another 47µF capacitor. This further attenuates any ripple which may
make it through the regulator.
Microcontroller IC1 has three 100nF
ceramic supply bypass capacitors,
with its AVCC supply filtered by one
of these in combination with a 10Ω
series resistor. A 10µF ceramic capacitor between pin 7 (VCAP) and ground
provides an output filter for its internal
2.5V core regulator, while a 10kΩ pullup between the 3.3V rail and pin 18
(MCLR-bar) prevents spurious resets.
PCB layout
The PCB design is crucially important to achieve the desired performance level. The relatively compact
PCB means that the switched LED
supply lines inevitably run somewhat
near the front end and the tiny amount
of signal that couples in is picked up
and amplified by the op amps. This
is mostly ignored by the software (as
explained later) but it does make the
noise level in the left channel slightly
worse than the right (but still below
-100dB) due to its greater proximity
to the LEDs.
The most critical part of the layout,
as is typical, is the ground track routing. While all points connected to
ground in the circuit must be joined
together, there are a large number of
ways this could be achieved, many of
which would cause digitally switched
siliconchip.com.au
currents to cause voltage shifts across
different parts of the analog front-end,
ruining the performance.
The grounds for input sockets CON1
& CON2, regulators REG1 & REG2 (and
their output filter capacitors but NOT
input bypass capacitors) and the bottom end of the two half-rail bias generators are connected together, then
brought back to pin 16 of IC1 (AGND).
This pin is also used as the negative
reference voltage for the ADC. This
routing means that the analog grounds
and half-supply rails have very little
AC voltage between them, as little current flows through these tracks and
that which does is linearly proportional to the input signal.
AGND is connected to GND within
IC1, and also by tracks running under
it, so ultimately these pins all connect
to GND. The op amp negative supply
pins and their bypass capacitors are
connected back to the ground pin of
REG2 and the more-or-less constant
supply current flows from there back
to AGND and on to the main ground
network.
Firmware operation
While the software is conceptually
simple, it has quite a few modes and
features. Its three main tasks are to
continually sample the analog inputs,
perform the average and peak calculations based on the results and drive the
multiplexed LED display. The first and
last are “real time” tasks so they are
interrupt driven, with priority given
to the LED multiplexing, as any delays could cause the display to flicker.
The LED multiplexing is achieved
using three of the five 16-bit timers
internal to IC1: Timer1, Timer2 and
Timer3. IC1 runs at 40MHz, in order to
perform the required calculations fast
enough to provide a rapid display update (around 40 updates per second).
Timer1 is set up to trigger an interrupt every 65,536 (216) clock cycles,
ie, every 65,536 ÷ 40MHz = 1.6384ms.
Since there are eight cathodes to cycle
through, this gives a display refresh
rate of 76Hz.
When this interrupt is triggered,
the code branches to the Timer1 interrupt handler, which switches the
LED anode drive outputs (RC0-RC11)
low, then cycles the next Mosfet drive
output (RB2-RB9) high. It then calculates which anodes to drive to light
the appropriate LEDs and brings some
combination of RC0-RC11 high.
siliconchip.com.au
Parts List
1 double-sided PCB, code
01104161, 177 x 75.5mm
1 white switched PCB-mount RCA
socket (CON1)
1 red switched PCB-mount RCA
socket (CON2)
1 PCB-mount switched DC socket,
2.1 or 2.5mm inner diameter
(CON3)
1 5-pin header, 2.54mm pitch (optional, to program IC1) (CON4)
2 PCB-mount mini tactile switches
(S1,S2) (Jaycar SP0611)
1 10kΩ SMD trimpot, TC33X type
(VR1) (element14 1689863)
5 PC stakes (optional; see text)
1 12-15V DC 150mA+ power
supply
Semiconductors
1 PIC32MX150F128D-I/PT or
PIC32MX170F256D-I/PT 32-bit
microcontroller programmed
with 0110416A.hex, TQFP-44
(IC1)
3 NE5532D dual low-noise op
amps, SOIC-8 (IC2-IC4)
1 MCP1703-3302E 16V in,
3.3V out, 250mA low-dropout
regulator, SOT-223 (REG1)
1 MIC5201YM 20V, 200mA
adjustable low-dropout
regulator, SOIC-8 (REG2)
8 2N7002P logic-level N-channel
Mosfets, SOT-23 (Q1-Q8)
1 BZX84C5V6 5.6V 1/4W zener
diode, SOT-23 (ZD1)
1 30V 1A Schottky diode, SMA/
DO-214AC or Mini2 SMD
package (D1)
8 BAT54S dual series Schottky
diodes, SOT-23 (D2-D9)
60 high-brightness green SMD
3216/1206 LEDs (LED1-30,
LED41-70)
8 high-brightness yellow SMD
3216/1206 LEDs (LED31-34,
LED71-74)
8 high-brightness amber SMD
3216/1206 LEDs (LED35-38,
LED75-78)
4 high-brightness red SMD
3216/1206 LEDs (LED3940,LED79-80)
If the brightness trimpot is set at a
level below 100%, before the interrupt
handler completes, it enables Timer3
and sets it for a value proportional to
8 high-brightness blue SMD
3216/1206 LEDs (LED81-88)
Capacitors (SMD 2012/0805 unless
specified)
2 47µF 6.3V X5R 2012/0805 or
3216/1206
2 10µF 6.3V X5R 2012/0805 or
3216/1206
11 2.2µF 16V X5R
6 100nF 50V X7R
2 1nF 50V C0G
2 680pF 50V C0G
6 100pF 50V C0G
Resistors (SMD 2012/0805, 1%
0.125W unless specified)
2 22kΩ or 22.1kΩ 1% 0.5W
3216/1206
14 22kΩ
4 3.9kΩ
2 20kΩ
1 1.5kΩ
1 12kΩ
19 1kΩ
1 10kΩ
1 33Ω 5% 1W 6331/2512
2 10Ω
Optional parts
Tapped spacers and M3 machine
screws for mounting, shielded
cable and twin-lead for hard wiring,
case with clear lid
Optional laser-cut case
1 set 3mm clear acrylic pieces
1 small tube acrylic glue (solventbased)
4 M3 x 10mm machine screws
2 M3 x 12mm tapped Nylon
spacers
4 M3 shakeproof washers
Where to buy parts
The PCB, programmed microcon
troller, case pieces & red/white RCA
sockets are available separately
from the SILICON CHIP Online Shop.
We’re also offering a set of parts
containing all the SMDs except for
the microcontroller & LEDs. Sets
of 10 red, amber, yellow, green or
blue high-brightness 3216-size SMD
LEDs with diffused lenses are available separately, so that constructors
can choose their own colours.
the brightness. When the interrupt
handler for Timer 3 is subsequently
triggered, RC0-RC11 are brought low,
cutting off the LED drive to reduce the
June 2016 39
Handling Higher Amplitude Signals
As presented, the circuit is designed to accept sinewave signals up to 2.33V RMS
(6.6V peak-to-peak or 3.3V peak). Signals above this level will cause D2 & D3 to conduct and the meter will simply show a full -scale reading but no damage should occur.
This is not sufficient to monitor the outputs of a power amplifier. Some equipment
may also produce line-level signals above 2.33V RMS. In this case, it’s simply a matter of changing the input divider so that, with the maximum input signal level, the
resulting voltage does not exceed 3.3V peak-to-peak. The parallel combination of the
two divider resistors should be kept to 11kΩ. This means that the “lower” leg resistor
will need to be reduced in value, probably to somewhere in the range of 11-15kΩ.
Consider a power amplifier like our Ultra-LD Mk.4 (August-October 2015) which
can deliver 135W into 8Ω or 200W into 4Ω. This requires an output voltage of √(135
x 8) = 33V RMS or 93V peak-to-peak (33V x 2.828). For 200W into 4Ω, the output
will be √(200 x 4) = 28.3V RMS. So the meter would need to handle 33V RMS to
monitor the outputs directly.
This means a divider ratio of at least 93V ÷ 3.3V = 28.2 is required. We set the
bottom leg to 11kΩ (ie, the resistor from the 5.6V rail) since the other resistor value
will be much larger and have negligible contribution to the divider’s output impedance. The other resistor will then need to be at least 11kΩ x (28.2 – 1) = 300kΩ. This
happens to be an E24 value; if it wasn’t, we would have chosen the next higher value.
The parallel resistance is 1 ÷ [(1 ÷ 11kΩ) + (1 ÷ 300kΩ)] = 10.6kΩ, which is close
enough to 11kΩ.
This new divider reduces the input levels by 23dB compared to the original design,
so the +7dBV setting is in reality now +30dBV, which would indicate full amplifier
power into 8Ω. Note that the other reference levels will be effectively increased by
the same amount.
average display brightness. Both interrupt priorities are set to level four, the
highest used.
An error in the silicon?
This multiplexing method works
very well, giving a stable and bright
display. At least, it did until we enabled the ADC. Even with ADC interrupts disabled, it caused the LED display to flicker.
We couldn’t understand why, since
the timer period should not be affected by the operation of the ADC and
the flickering occurred even without
enabling interrupts for the ADC unit
at any location in the code. So why
should the ADC interfere with the
multiplexing?
We got a clue by examining the
Mosfet drive signals for Q1-Q8 using
an oscilloscope. Periodically, one of
the Mosfet gate drive pulses would
be extremely short; rather than the
expected 1.6384ms, it measured something like 50μs, appearing as just a
spike on the screen. Following that occurrence, the next pulse for that same
Mosfet would occur about 11.5ms
later, or roughly seven timer periods,
rather than the expected 13.1ms (eight
timer periods).
40 Silicon Chip
This pointed to the possibility that,
having completed the Timer1 interrupt
handler, the processor would sometimes immediately re-enter it and thus
the code would then assume some time
had passed and switch to the next multiplexed bank of LEDs prematurely.
For some reason, this occurred only
when the ADC was enabled and active.
We can’t figure out how the software
could have caused this, since when
the ADC is in auto-sampling mode,
with interrupts disabled, it operates
autonomously.
Simple solution
In the end, we came up with a simple solution: we set Timer2 to the same
time base and period as Timer1. When
the Timer1 interrupt handler is about
to exit, it resets Timer2. At the start
of the Timer1 interrupt handler, we
check the value of the Timer2 counter.
If it’s less than half the expected value,
indicating that the Timer1 interrupt
should not have occurred yet, we exit
the interrupt handler without doing
anything. This allows us to ignore the
occasional spurious event.
Our guess as to the nature of this
problem is that an implementation bug
in this series of PIC32s causes some in-
terrupt handlers to re-triggered upon
exit if something else is going on in
the chip simultaneously.
A “gotcha”
Another issue we ran into is that the
display also started flickering when we
added the code to update the states of
LEDs81-88. Unlike the previous issue,
this turned out to be our fault. LED86
is driven by output RB12 which is on
the same port as the pins driving Mosfets Q1-Q8 (ie, RB2-RB9).
The code to update the state of
LED86 read:
LATBbits.LATB12 = !(Sensitivity == 1);
This looks like an atomic operation,
setting the bit LATB12 which controls
the state of output RB12. However, it
is actually a read-modify-write operation, ie, the value of special register LATB is transferred to a general
purpose register, the value of bit 12 is
changed and the result is then transferred back to the special register.
But if the Timer1 interrupt handler
is triggered in the middle of this procedure, it may change the value of special
register LATB. When the special register is written back later by the above
code, that overrides the change made
by the interrupt handler.
One possible solution is to temporarily disable interrupts while updating LATB12 but that’s clumsy. The
elegant solution is to take advantage
of the special set/clear/toggle registers
available for all the GPIO registers (and
many others) on this chip, ie:
if( Sensitivity == 1 )
LATBCLR = 1<<12;
else
LATBSET = 1<<12;
These operations are atomic, ie,
can’t be interrupted. If an interrupt
handler is triggered simultaneously, it
will be executed either before or after
the clear/set operation, eliminating
the flicker.
Analog computations
As explained earlier, the input signals (left & right channels) are applied
to six different analog inputs: two with
an overall gain of one half, two with
a gain of 11.5 times and two with a
gain of 264.5 times. However, rather
than switch between sampling these
different inputs depending on signal
level, we simply sample all six, all the
time. The code in the ADC conversion
siliconchip.com.au
We used green, yellow, amber and red LEDs in the bargraphs but you can
change these to suit your requirements. Pt.2 next month has the assembly
details. Note: prototype board shown.
complete interrupt handler routine decides which to use, depending on the
values returned.
If the value from the input amplified by 264.5 times is very near either
rail (ie, the conversion result is very
close to either zero or 1023), the value
from the 11.5 times amplified input is
used instead, multiplied by 23 so that
it has the same scale as readings from
the other input. If that lower-gain input is also found to be very near either
rail, the value from the third, attenuated input is kept instead, multiplied
by 529 (23 x 23). The result is then
stored in one of two 1024-entry stereo
buffers for later analysis, to keep the
interrupt handler routine quick so it
won’t interfere with LED multiplexing.
The micro’s peripheral clock is set to
run at half the rate of the main clock, ie,
20MHz. The ADC clock input divider
is set to a factor of two, giving 10MHz.
Each conversion takes 12 cycles, plus
eight cycles for the sample-and-hold
buffer to stabilise, for a total of 20 cycles each (10MHz ÷ [20 x 6] = 83.3kHz).
We average each pair of sample values
to reduce system noise, resulting in a
final sampling rate of 41.6kHz, sufficient for measuring signal frequencies
up to 20.8kHz (the Nyquist limit).
Once a sample buffer is full, the
code’s main loop calculates the average of all values and subtracts it from
the sample values to remove any DC
offset or low-frequency signals which
have not been rejected by the analog
filter. It then computes the RMS and
peak values for each channel.
The resulting RMS values are then
stored and averaged over a configurable number of 1024-sample intervals,
so that it varies smoothly. Similarly,
the highest peak values across multiple 1024-sample buffers are computed.
These RMS and peak values are converted into decibels using a logarithmic calculation, taking into account
the current range and reference level
selection. The display is then updated
to show the peak and/or average results (depending on the display mode).
Other functions
Button presses are sensed using a
pin change interrupt and debounced
using Timer4 (S1) or Timer5 (S2).
When a press is detected, the interrupt
handler sets a flag and the main loop
updates the mode and then saves the
new setting to flash memory. These
saved settings are automatically loaded each time the unit is powered up.
Long presses (>0.5s) have a different effect compared to short presses
and this is determined by when the
associated timer rolls over. As well
as using these buttons to change the
display range and reference level,
Issues Getting Dog-Eared?
LED Colours
In our prototype, we used 30 green
LEDs at the left end of each bargraph,
followed by four yellow, four amber
and two red. This is a purely aesthetic
choice. You could make them all the
same colour (eg, blue), or use a different combination than we did.
While brightness matching between different colours is generally
good enough, the software allows
you to provide some drive compensation to reduce the difference in apparent brightness between different
colour LEDs.
We also decided to make LEDs8188 blue, in contrast to LEDs1-80 and
the parts list reflects our choices.
various combinations can be used to
change settings, to be described next
month in Pt.2.
Noise nulling is implemented by
storing the left and right channel RMS
and peak values when S1 is held down,
both in RAM and flash memory. These
are subtracted from subsequent readings, with the RMS noise figure being
subtracted in an RMS manner.
That’s all we have space for this
month. Next month we’ll get onto the
PCB construction, testing, operation
SC
and fitting the unit into a case.
Keep your copies safe
with our handy binders
Order now from www.siliconchip.com.au/Shop/4 or call (02) 9939 3295 and quote your credit
card number. *See website for overseas prices.
siliconchip.com.au
June 2016 41
|