This is only a preview of the June 2008 issue of Silicon Chip. You can view 34 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 "DSP Musicolour Light Show":
Items relevant to "USB Power Injector For External Hard Drives":
Items relevant to "Balanced/Unbalanced Converter For Audio Signals":
Purchase a printed copy of this issue for $10.00. |
Run your own disco light
show with the
PT.1: By MAURO GRASSI
DSP Musicolour
This DSP Musicolour accepts audio input signals and drives
coloured lights “in tune” with the music. Its four output
channels respond to different audio frequency bands and
the brightness of the lights is in direct proportion to the
amplitude of the frequency components. A dot-matrix LED
menu display is featured on the front panel and this also
functions as a spectrum analyser or VU meter.
I
N PRESENTING THIS brand new
project, we are reviving a name
which became synonymous with party
light shows in the 1970s and 1980s.
Long time readers will be familiar
with the “Musicolour” light shows
which were presented in “Electronics
Australia”, the last one being the Musicolour IV in the August 1981 issue.
SILICON CHIP magazine followed the
same theme with the Discolight project
in the July & August 1988 issues and
produced a 12V version called the
30 Silicon Chip
“Lightshow” in the January & February
1998 issues.
All of these projects were analog designs based on op amps and logic ICs.
The audio was passed through different pass-band filters for each channel
and the filtered outputs were used to
drive either phase-controlled Triacs in
the Musicolour and Discolight circuits
or power Mosfets in switchmode in the
case of the 12V Lightshow.
The logic ICs were used in the Discolight and 12V Lightshow to produce
the chaser modes, which were alternating patterns controlling the output
channels in the absence of an audio
input. These chaser modes meant
that you could have pleasing lighting
effects without any music.
Two decades on from the Discolight
we now present the brand new DSP
Musicolour, a full digital design using
DSP (digital signal processing). It is
based on a single DSP microcontroller
to produce a comprehensive list of
features that were simply not possible
siliconchip.com.au
This photo and the photo on the facing page show the completed DSP Musicolour boards fitted to the case. The
displays have been lit by temporarily powering the Display Board using an external DC supply.
with previous analog designs.
The DSP Musicolour operates from
230-240VAC or 115-120VAC mains
(detecting the 50Hz or 60Hz mains
frequency automatically) and drives
four channels of incandescent lights.
The total power output rating is 2400W
for the 230-240VAC 10A version and
1600W for the 115-120VAC 15A version. For the 240VAC version, each
channel is rated at 800W maximum
(as long as total power is less than
2400W). For the 120V version, each
channel is rated at 400W.
By making the design suitable for
both 230-240VAC and 115-120VAC
50/60Hz mains supplies, we are ensuring that the DSP Musicolour can be
built in any part of the world without
modifications, apart from changing
the power transformer’s primary connections.
Incidentally, since February 23rd
2000, Australia’s mains supply has
been nominally 230VAC, with a
normal range from -6% to +10%, ie,
216-253V (AS60038-2000). In practice though, supply authorities try to
maintain the range at between 225V
and 253V.
Operating features
Pictured in this article is the prototype DSP Musicolour without its
front or rear panels. The photos show
the quite complex vertical PC board
which accommodates a 7x15 (rows
siliconchip.com.au
x columns) dot-matrix LED display,
an array of illuminated pushbuttons
and three potentiometers. By contrast,
the main PC board is larger but not as
packed with components. It carries
the microcontroller and the 240VAC
Triac circuitry.
The pushbuttons are used to navigate through the menus which are
displayed on the dot-matrix display.
This display can also be switched to
function as a spectrum analyser or as
a VU meter, or can be used to display
“screen saver” patterns.
One potentiometer on the front
panel is used to vary the screen brightness, screen refresh rate, the frequency
band, the gain and the quiescent current of each output channel, among
other settings. Another two potentiometers are used to independently
control the input sensitivity of each
channel. It is then possible to mix
the two channels in software before
processing the audio data or to select
either channel independently as the
audio input.
The back panel carries an IEC male
mains socket (with an inbuilt mains
switch and fuse) plus four 3-pin
240VAC sockets for the four output
channels (these are used to connect the
lights). It also carries a 4-way speaker
terminal block to accept two audio
input channels, an optional connector
for an external microphone and an optional 10-way IDC connector that can
be used to update the firmware (more
on this in a later article).
Block diagram
The block diagram of the DSP Musicolour is shown in Fig.1. As can be
seen, there are three audio input channels. Two audio channels come from
the 4-way speaker terminal block on
the back panel while the third channel
is for an onboard electret microphone
or an optional external microphone.
The two audio channels pass
through the front panel potentiometers and are then fed into independent
AC-coupled inverting amplifiers. The
output of each amplifier is then fed to
a dsPIC microcontroller at inputs AN1
& AN2 and are converted to digital
signals by onboard ADCs (analog-todigital converters).
Similarly, the microphone signal is
fed to an AC-coupled inverting amplifier and the output again connected
to the microcontroller, this time at
AN3. Note that the optional third audio input for connecting an external
microphone is mixed with the output
of the onboard electret microphone.
The two audio channels are independent and as mentioned earlier, have
separate sensitivity controls. They can
be optionally mixed in software in
different proportions (selectable balance). So there are three distinct audio
channels: the two audio channels and
the microphone channel.
June 2008 31
MAINS
OUTLETS
POTENTIOMETERS
OPTO COUPLED
PHASE CONTROL
TRIAC
15 x 7 DOT
MATRIX DISPLAY
OP
AMP
AUDIO
CHANNEL
INPUTS
AN1
OP
AMP
MIC
INPUT
AN2
AN3
ADC
INPUTS
dsPIC
30F4011
DSP MICRO
CONTROLLER
OP
AMP
OC1
OPTO COUPLED
PHASE CONTROL
TRIAC
OC2
OC3
OC4
OPTO COUPLED
PHASE CONTROL
TRIAC
INT0
ZERO
CROSSING
DETECTOR
FROM TRANSFORMER
SECONDARY
OPTO COUPLED
PHASE CONTROL
TRIAC
7 x USER INPUT
SWITCHES AND
POTENTIOMETER
ACTIVE
NEUTRAL
Fig.1: the block diagram of the DSP Musicolour. The audio inputs are digitised and processed using a dsPIC micro
controller to produce control signals for four frequency bands. The dsPIC then phase controls four optocoupled
Triac output stages to power the mains outlets.
As stated previously, the audio
channels are converted to digital format by onboard ADCs in the dsPIC microcontroller. These are each sampled
at around 48kHz (slightly higher than
double the highest audible frequency)
in order to avoid aliasing.
Next, the resulting digital time
domain data is transformed to the
frequency domain using an FFT (Fast
Fourier Transform) algorithm. The
result is a list of amplitudes for the frequency components of the audio input
signal. The computed frequency amplitudes are then used to drive the four
output channels via phase-controlled
Triacs in the output stages. These Triacs are driven via optocouplers which
ensure full mains isolation for the low
voltage sections of the circuit.
As may be apparent from the description so far, there are no op amp
filters so the frequency bands for each
channel are user-selectable. Furthermore, different arithmetic operations
can be applied to the digitised audio
data to amplify or attenuate it.
This means that each input channel is effectively post-amplified in
software. Moreover, the various input
channels can be selected and mixed in
software with different weighting. In
previous designs, the switching was
32 Silicon Chip
accomplished using a toggle switch.
Providing the chaser modes is also
much easier with a digital design.
Again, it’s all done in the software and
no extra circuitry is involved.
Circuit operation
Let’s now look in more detail at
the circuit operation of the DSP Musicolour.
Figs.2-4 show the full circuit details. It’s based on microcontroller
IC1, a dsPIC30F4011 from Microchip.
This combines most of the common
peripherals of a PIC with a high-performance RISC (reduced instruction
set computer) processing core that
has instructions optimised for digital
signal processing (DSP).
The Microchip dsPIC series of microcontrollers incorporate DSP features like MAC (multiply accumulate),
variable bit shifting, bit reversed addressing modes, dual data fetching
(multiple operands), high-precision
arithmetic operations (including fractional hardware divide and multiply)
and multiple 40-bit accumulators.
All DSP instructions are single cycle,
meaning the dsPIC series is surprisingly powerful, with throughputs in
the tens of MIPS (millions of instructions per second).
In this design, IC1 runs off an internal system clock operating at about
29MHz. Among other things, it’s
responsible for digitising the audio
inputs, processing the audio inputs
(including computing the FFT), synchronising with the mains frequency
and implementing real-time phase
control, driving the multiplexed
LED display and responding to key
presses. The operation of the software
is explained in greater detail later in
this article.
The output stages of the DSP Musicolour are virtually identical to those
in the Discolight but have been uprated
using heavy-duty BTA41-600B Triacs.
These are isolated-tab Triacs rated at
600V, with continuous current ratings
of up to 40A and a surge current rating
of close to 400A.
This high surge-current rating is
necessary in order for the Triacs to
withstand the large fault currents
which can occur if a 150W floodlight
blows its filament. This is a particular problem if the floodlight is facing
upwards. In that case, the broken
filament can flail around and short
to the adjacent filament support. The
resulting arc continues until the stem
fuse inside the lamp blows.
In addition, the software programm
siliconchip.com.au
ed into the dsPIC has a facility to set
the filament preheat current of each
output channel. This helps minimise
surge currents to protect the lamps.
Note that the four Triacs, which
are housed in TOP3 packages, are
mounted in pairs on the main board
and each pair share a heatsink. These
heatsinks are necessary, as the Triacs
will get hot during normal operation,
even if each channel is only rated at
800W.
Each Triac is triggered by the dsPIC
via a MOC3021 optocoupler (OPTO1OPTO4), to ensure full mains isolation
from the low voltage part of the circuit.
As shown, IC1’s “output compare”
pins (OC1-OC4) are used to drive the
internal LEDs of the optocouplers
which then switch on the Triacs until
the next zero crossing of the mains
waveform.
Following the Triacs, each channel
output has a filter network consisting
of a 100mH inductor (rated at 5A) and
a 0.1mF 250VAC capacitor, to reduce
EMI. As can be seen, the mains Active
is connected to the A2 terminal of each
Triac and is switched through to the
mains output sockets via the 100mH
inductors – see Fig.3. The outputs
are then fed to screw terminal blocks
CON4 & CON5 on the main board.
Audio inputs
As shown in Figs.2 & 4, the two
audio channels are fed in via pins 2 &
4 of CON2 and are attenuated by two
270W resistors. These resistors ensure
proper attenuation of the incoming
signals, which are derived from the
loudspeaker outputs of an amplifier.
From there, the signals are fed to
pins 5 & 6 of connector CON1 and then
to pins 5 & 6 of CON7 on the display
board (CON1 & CON7 are connected
via a 26-way flat-ribbon cable). The
audio signals are then further attenuated using potentiometers VR1 & VR3
on the display board and fed back to
pins 4 & 3 of CON1 on the main board.
These pots set the input sensitivity for
the audio channels.
Link LK4 is optional and allows
the two audio channels to be mixed
together via the 270W input resistors.
It’s normally left out of circuit.
The outputs of VR1 & VR2 (at pins
3 & 4 of CON1) are AC-coupled to op
amps IC2a & IC2d via 68nF capacitors
and 33kW series resistors. These two
op amps are wired in inverting mode
and operate with a gain of 0.3 as set
siliconchip.com.au
Main Features
•
•
Full digital design using a DSP microcontroller (dsPIC)
•
•
Four phase-controlled output channels (8-bit resolution)
•
•
•
Zero voltage switching of Triacs for minimum RF interference
•
•
•
•
•
•
•
•
Selectable filament preheat current for each output channel
•
•
•
Software-controlled input selection with software mixing
Powered from 230-240VAC or 115-120VAC mains with auto-detection of
mains frequency
Optocoupled Triac triggering for complete isolation of control circuitry
from output circuitry
Four mains outputs rated at 800W each (240VAC) or 400W (120VAC)
Selectable gain plus selectable minimum and maximum frequencies for
each output channel
Persistent software settings
Self-diagnostics
Chaser modes
Direct stereo inputs for audio modulation of lights
Microphone input/third channel input for audio modulation of lights
7x15 pixel dot-matrix LED display for menus
Dot-matrix display can function as a spectrum analyser, screen saver or
VU meter
Adaptive potentiometer control for software settings
Optional provision for ICSP (in-circuit serial programming)
by their 10kW feedback resistors and
33kW input resistors (ie, 10kW/33kW
= 0.3).
Because the circuit operates from
a single +5V supply rail, the noninverting inputs of IC2a, IC2d and IC2c
(pins 3, 12 & 10 respectively) must all
be biased to half supply (Vcc/2). This
is achieved using op amp IC2b. Two
10kW resistors are wired as a voltage
divider to derive a 2.5V reference and
this is fed to pin 5 of IC2b which is
connected as a voltage follower. IC2b’s
pin 7 output then provides the Vcc/2
(ie, 2.5V) rail to bias the remaining
op amps.
IC2c is used to amplify the signal
coming from the on-board electret
microphone. It’s also wired as an inverting amplifier but operates with a
gain of 30. As before, the signal is fed
to the op amp via a 68nF capacitor and
3.3kW resistor.
Power for the electret microphone is
derived from the +5V rail via 1kW and
4.7kW resistors, while a 47mF capacitor
filters this supply.
In addition, the signal from an external microphone can be fed to IC2c
via pin 3 of CON2. In that case, the
signals from the two microphones will
be mixed and applied to IC2c.
The outputs of op amps IC2a, IC2d &
IC2c are connected to the ADC inputs
of microcontroller IC1 (AN1, AN2 &
AN3). Another ADC channel (AN0) is
used to read the value of potentiometer VR3 which is also on the display
board. This 10kW linear potentiometer
is used to change settings.
Resetting the micro
Each time power is applied to the
circuit, the MCLR-bar (reset) input
of IC1 is pulled high (ie, towards
the +5V rail) via diode D8 and a 1kW
resistor. This releases the reset on
the dsPIC30F4011 so that it can start
operating.
Note that pulling the MCLR-bar
input low resets the microcontroller
but this is not used in this circuit.
Instead, an internal POR (power on
reset) circuit resets the microcontroller
when power is first applied.
Diode D8 is included because the
MCLR-bar line connects to 10-way
IDC connector CON3. This connector
is optional and is included to allow
ICSP (in circuit serial programming).
June 2008 33
CON1
+5V
11
13
100nF
14
40
100nF
AVdd
15
16
CN
28
17
SER
38
19
CK2
21
G
23
CK1
26
S7
24
S6
22
S5
20
S4
18
S3
10
S1
8
S2
12
AN0
V12
3
V22
6
V13
5
V23
68nF
3
1k
MCLR
RF6
PGC
PGD
RF0
RF1
270
1W
26
25
30
29
12
IC2a
5
1
AN3
OC3
4
OC1
AN2
OC2
RE4
IC2d
RE5
14
22
19
23
18
34
33
A
LED8
4 R AUDIO
68nF
3 MIC
5
K
1k
1
3.3k
47 F
16V
4.7k
100k
3
470
AN1
9
68nF
ELECTRET
MIC
LK6*
1k
13
2 L AUDIO
24
IC1
dsPIC30F4011
10k
33k
270
1W
1
LK5*
OC4
68nF
1
D8
K
10k
33k
LK4*
2
A
32
Vdd
CN17
2
25
CON2
21
Vdd
SFR
37 RE1
36
RE2
35
RE3
15
RC13
14
RC15
10
RB8
9
RB7
8
RB6
6
RB4
7
RB5
2
AN0
9
4
11
Vdd
10
IC2c
INT0
8
AVss
39
+
Vss
12
Vss
17
1k
Vss
20
31
+5V
100nF
10k
5
10k
47 F
16V
6
* NOTE: IN THE DEFAULT CONFIGURATION, LK4
AND LK6 ARE OMITTED AND LK5 IS INSTALLED
4
IC2b
7
+2.5V
D8 -D10: 1N4148
11
A
K
D11-D14: 1N4004
SC
2008
DSP MUSICOLOUR
MAIN BOARD
A
LM317T
K
OUT
ADJ
OUT
IN
Fig.2: the Main Board circuit. Microcontroller IC1 accepts audio inputs from op amps IC2a, IC2d & IC2c, processes the
signal and drives the four Triac output stages via optocouplers OPTO1-OPTO4. It also drives the Display Board via
CON1 and processes the inputs from the various controls on this board.
Since the MCLR-bar pin is multiplexed
with the programming voltage (Vpp)
for ICSP and because the typical level
used is around +13V (much higher
than +5V), D8 is reverse biased during
34 Silicon Chip
ICSP and thus protects the circuit from
over-voltage.
LED8 is used as a “normal function”
indicator for the microcontroller and
is normally lit. It may also be used by
future software versions to indicate
runtime errors in the program. The
470W resistor limits the LED current
to about 10mA. Note that this LED is
mounted on the main board and is not
siliconchip.com.au
680
6
1
OPTO2
MOC3021
+5V
2
CON3
5
A2
G
4
A1
TRIAC3
BTA41-600B
100nF
250VAC
CON4
220
100 H
1
9
680
2
10
6
1
6
OPTO4
MOC3021
7
8
2
3
A2
TRIAC4
BTA41-600B
G
4
100nF
250VAC
A1
220
4
100 H
680
6
1
OPTO1
MOC3021
A2
TRIAC1
BTA41-600B
2
G
4
100nF
250VAC
A1
CON5
220
100 H
680
6
1
OPTO3
MOC3021
A2
TRIAC2
BTA41-600B
2
G
4
100nF
250VAC
A1
220
100 H
270 1W
NOTE: ALL WIRING AND PARTS
IN THIS SHADED AREA OPERATE
AT MAINS POTENTIAL.
CONTACT COULD BE FATAL!
K
D10
A
5.6nF
D11– D14
A
D9
A
K
OUT
K
IN
ADJ
100
470 F
120V
7.5V
REG1 LM317T
+5V
T1
K
4700 F
16V
A
K
A
A K
0V
0V
LK1 LK2 LK3
FOR 240V, FIT LK2 ONLY
FOR 120V FIT LK1 AND
LK3 ONLY
120V
7.5V
0V
0V
100
1 F
16V
LED8
30VA
CON6
100
N
BTA41-600B
100
FUSED MALE
IEC SOCKET
WITH SWITCH
K
A
A1
visible with the case lid on.
LK5 & LK6 are used to set IC1 so
that it operates according to the audio
input mode set using LK4 (more on
this in a future article). The default
siliconchip.com.au
A
A2
G
* FUSE F1 RATING:
10A FOR 240V,
15A FOR 120V
configuration is to omit LK4 & LK6
and install LK5.
Display board circuit
Now let’s take a look at the display
F1*
MAINS IN
E
board circuit (Fig.5). It’s based on
three 74HC595 shift registers (IC3-IC5)
which are used to drive the 7x15 dotmatrix LED display in multiplexed
fashion. This display is actually made
June 2008 35
CON4
MAINS OUTPUT SOCKETS
A
N
E
N
A
E
CON5
N
A
E
N
A
E
MAINS
EARTH
MAINS
NEUTRAL
Fig.3: the switched Active lines
from CON4 & CON5 are connected
to the mains outlet sockets as
shown here.
up using three separate 7x5 dot-matrix
red LED modules (Kingbright TA1211EWA, distributed by Tenrod).
IC3 & IC4 are cascaded to form a
combined 16-bit shift register. This is
controlled by the CK2 (clock), G-bar
(enable) and SER (data) lines coming
from microcontroller IC1. By using
these three lines, any 16-bit value can
be loaded into the shift register.
In operation, the 16-bit shift register
drives the 15 columns (ie, the anodes)
of the 7x15 dot matrix display. The remaining column output, at pin 7 of IC4,
is used to drive transistors Q16-Q22.
These in turn drive LEDs1-7 which
are inside the tactile switches (S1-S7).
In greater detail, the first 15 bits of
the combined shift register drive PNP
transistors Q1-Q15 (all BC327s) via
470W resistors. These transistors are
necessary to provide the high currents
required to obtain a display that is
bright enough. Because the display
LEFT AMPLIFIER
OUTPUT
RIGHT AMPLIFIER
OUTPUT
+
–
is multiplexed, each LED is only
switched on very briefly and therefore
must be driven quite hard.
Note that there are no series resistors
to limit the current. That’s because
the switching occurs very briefly and
this limits the currents and protects
the display modules. In addition, the
cathodes are driven by a ULN2003
Darlington array (IC6) and this also
limits the total peak currents.
The Darlington transistors inside
IC6 are driven by the remaining shift
register (IC5). This is controlled in
a similar way to the 16-bit register
and is clocked using the CK1 (clock)
line from the microcontroller. The
G-bar (enable) and SER (data) lines
are shared with the other two shift
register ICs.
Using a separate clock ensures that
IC5 can be controlled independently
of the two cascaded shift registers.
IC5 thus functions as an independent 8-bit shift register and is used to
drive the seven rows (R0-R6) of the
dot matrix display via IC6. The extra
bit is not used.
The seven rows of the display are
all cathodes and the ULN2003 (IC6)
is necessary to provide the required
current drive. In operation, this device can sink up to 500mA for each
of its seven outputs. It’s also used to
drive the “extra” row formed by the
seven LEDs inside the tactile switches
(LED1-LED7) – ie, IC6 drives the cathodes of LEDs1-7, while pin 7 of IC4
switches their anodes.
During the display update period,
the microcontroller sends the G-bar
(enable) line high and this forces
all the shift register outputs to also
go high. This effectively blanks the
display but this blanking interval is
so short that it is imperceptible. The
SER (data) line feeds the data from the
microcontroller into the shift registers
during this blanking period.
Note that because the display is
multiplexed, the microcontroller can
control the 7x15 dot-matrix display
CON2
2
+
4
–
3
OPTIONAL
EXTERNAL
MIC INPUT
36 Silicon Chip
5
1
Fig.4: the left & right
audio input signals
are derived from the
speaker terminals of an
amplifier and fed in via
connector CON2. The
external microphone
input is optional.
and LEDs1-7 using just four digital
outputs, ie, CK1, CK2, G-bar & SER.
Switches S1-S7 are all pushbutton
momentary-contact types. These
switches are used to change the operating modes and drive the menus (more
on this next month).
In practice, each switch is connected
to a separate microcontroller input (via
CON1 & CON7) and these seven inputs
are all normally pulled high (ie, to
+5V) by 1kW resistors. The other side
of each switch is connected to ground
and the switch contacts are debounced
by the software.
Diodes D1-D7 and their associated
1kW pull-up resistor form a 7-input
AND gate. Its output (at the anodes)
connects to the CN17 (pin 28) input of
the microcontroller. This input is used
to trigger an interrupt when it changes
state and is used by the software to
respond to switch presses.
Power supply
Now let’s go back to Fig.2 and describe the power supply.
As shown, power for the low-voltage
side of the circuit is derived using a
30VA mains transformer with dual
primary and secondary windings.
The two primary windings are either
connected in series or in parallel, depending on the mains voltage (either
240VAC or 120VAC, respectively).
For a 240V AC supply, LK2 is fitted to connect the primary windings
in series. Alternatively, for a 120VAC
mains supply, LK1 & LK3 are fitted
to connect the windings in parallel.
The selected links are soldered to the
main PC board, before the transformer
is installed.
The incoming mains voltage is fed
in by a fused male IEC socket. For
230-240VAC mains, this fuse should
be rated at 10A while for 115-120V
mains, it should be rated at 15A.
The two 7.5VAC secondary windings are connected in parallel and feed
a bridge rectifier comprised of diodes
D11-D14 which are standard 1N4004
types. The rectified output of the
bridge is then filtered using a 4700mF
capacitor and fed to an LM317T
variable-voltage regulator (REG1) to
derive a regulated +5V rail.
This +5V rail is used to power the
low-voltage section of the circuit,
including the op amps, the microcontroller and all the display circuitry.
An LM317T was used instead of the
common 7805 +5V fixed regulator
siliconchip.com.au
CON7
Q1
+5V
11,13,14
9,12
AN0
100nF
VR3
10
16
Vdd
Q0
Q1
Q2
Q3
MR
1F
16V
17
SER
14
19
CK2
12
Sin
47F
16V
100nF
B
B
B
C
Q9
+5V
E
Q15
E
B
C
E
B
C
C
1
2
3
4
IC3
Q4
74HC595
5
10
12
11
G
13
1k
7 x 470
R6
R5
R4
R3
R2
R1
R0
+5V
9
100nF
16
Vdd
Q0
Q1
Q2
Q3
MR
14
12
11
13
Sin
16
1
10
15
1
2
3
3
IC5 Q4 4
74HC595
5
4
Q5
6
Q6
7
Q7
9
So
LCK
SRCK
OE
15
2
LED ARRAY 1
VR1
LED ARRAY 3
+5V
470
13
12
5
B
B
IC6: ULN2003
B
B
B
LED4 K
Q22
E
B
C
A
E
B
C
A
LED3 K
470
Q21
E
C
A
470
Q20
E
C
A
LED2 K
470
Q19
E
C
A
LED1 K
470
Q18
E
C
A
10
7
470
Q17
E
11
6
470
Q16
6 V13
4 V12
LED ARRAY 2
14
Vss
8
C14
14
21
16
Vdd
15
Q0
1
Q1
2
Q2
3
Q3
Sin
IC4 Q4 4
74HC595
5
Q5
6
LCK
Q6
7
Q7
SRCK
9
So
OE
Vss
8
MR
8
C7
Vss
C8
SRCK
OE
C1
11
C0
Q5
6
Q6
7
Q7
9
So
LCK
13
23
CK1
Q8
E
C
8 x 470
15
Q2
E
LED5 K
C
A
LED6 K
LED7 K
8
2 V11
5 V23
3 V22
1 V21
15,16
10
8
18
20
22
24
26
1k
VR2
LED1 INSIDE S1,
ETC
CN
A
A
D1
K
S1
S2
S3
A
A
K
K
A
D4
D3
D2
K
A
K
A
K
K
S4
S5
S6
S7
7 x 1k
25
D1 – D7: 1N4148
A
SC
2008
D7
D6
D5
DSP MUSICOLOUR
S1
S2
S3
S4
S5
S6
S7
K
B
DISPLAY BOARD
E
C
Q1 – Q22: BC327
Fig.5: the Display Board circuit uses three 74HC595 shift registers (IC3-IC5) to drive the dot-matrix LED displays and
the LEDs inside the switches in multiplexed fashion. These shift registers are driven by the dsPIC microcontroller via
CON7 using just four digital outputs. Switches S1-S7 select the various operating and display modes.
siliconchip.com.au
June 2008 37
Note: all the parts on the
heatsink side of the Main Board
operate at mains potential (ie,
240VAC). Contact could be lethal
– see Fig.2 & warning panel!
because it can supply greater current
(up to 1.5A).
The four 100W resistors set the
output voltage from the regulator according to the formula:
VOUT = 1.25 x (1 + R2/R1)
where R1 is the resistance between the
OUT & ADJ terminals and R2 is the
resistance between the ADJ terminal
and ground.
In this case, R1 = 100W and R2 =
300W, so VOUT = 1.25 x (1 + 300/100)
= 5V
In practice, slight manufacturing
variations mean that the 1.25 factor
How The Software Works
The software is responsible for most
of the Musicolour’s functions and uses
various interrupts to accomplish time
critical tasks.
For example, the multiplexed LED
display is driven by the microcontroller
using a periodic interrupt based on an
internal timer. This allows the display
refresh rate to be set by the software.
Each time the timer expires, an interrupt
occurs and display data is sent to the
display driving hardware.
The display is “multiplexed”, meaning
that only one column of seven LEDs is lit
at any one time. The seven LEDs inside
the tactile switches effectively form the
16th column of the display. The “dead
38 Silicon Chip
time” between screen refreshes can
also be programmed and this effectively
controls the perceived brightness of the
display.
Pressing any of the seven tactile
switches (S1-S7) also triggers an interrupt. The software then debounces the
switch and adds the key press to an
internal queue implemented as a FIFO
(first in, first out). This ensures that there
are no missed key presses due to software latencies.
Digitising the audio
The microcontroller is also responsible
for digitising the four analog input channels. Three of these are audio inputs
can be anywhere between 1.2 and
1.3. Because of this, the PC board has
been designed so that there are three
resistors in series between ADJ and
GND terminals. This allows REG1’s
output to be fine-tuned by changing
one or more resistor values, to obtain
a supply rail that’s very close to +5V.
Note, however, that this fine-tuning
will not be necessary unless you plan
to use the optional 10-way header
(CON3) for in-circuit programming
coming from the op amp circuits, while
the fourth is used to read the setting of
potentiometer VR3. This latter value is
used to change various settings, according to the menu selected.
Note that when changing a value with
this potentiometer, the value will only
begin to change when the potentio
meter’s setting matches the current
value of the setting that’s being changed.
This gives the potentiometer a kind of
“memory”.
The analog-to-digital conversion of
the four input channels is automatically
handled by the ADC subsystem within
the microcontroller (IC1). Each channel
is sampled at around 48kHz.
Most of the data produced is ignored
and only one audio stream (or a mixed
stream) is actually stored in an internal
buffer. An interrupt is generated when-
siliconchip.com.au
These photos show the assembled Main Board and Display Board modules. The
construction details are in next month’s issue (note: boards are shown slightly
smaller than actual size).
(and then only if the output voltage
isn’t close to +5V).
Zero-crossing detection
As well as driving the bridge rectifier, one side of the transformer’s
secondary winding is also fed to pin
17 of IC1 via 270W and 1kW resistors.
Diodes D9 & D10 clip the positive and
negative excursions of this AC signal
to +5.6V and -0.6V respectively, to prevent damage to the microcontroller’s
INT0 input. In addition, the signal is
bypassed using a 5.6nF capacitor to
filter any noise on the line. This capacitor changes the phase of the signal
slightly but this effect is corrected by
the software.
ever the internal ADC system buffer (16
bytes) is full. The firmware then stores
only the relevant channel data in an internal buffer. This happens after any mixing,
amplifying or averaging is performed on
the audio data.
The FFT (Fast Fourier Transform) is
computed in real time without loss of
samples. This is accomplished by the
software using double buffering.
While the FFT is being computed on
the data stored in an internal buffer, another internal buffer is being filled by the
interrupt servicing the ADC subsystem.
When the FFT is finished on the active
buffer, it is then computed on the other
buffer. In this manner, the two buffers
are alternately filled and then processed
by the FFT.
Note that the microcontroller runs at
close to 30MIPs using its internal clock
siliconchip.com.au
In operation, the microcontroller
uses the clipped AC signal to detect
the zero crossings of the mains waveform. This is necessary in order to
correctly drive the Triacs using phase
control and to minimise the interference caused by the Triacs switching
the mains.
Basically, the INT0 (pin 17) input
of the microcontroller functions as
an edge-triggered external interrupt
source. This is used by the software
to phase control the four output channels.
That’s all we have space for this
month. Next month, we’ll describe
the assembly of the PC boards and the
SC
internal wiring.
source. This is fast enough to compute
the FFT on the audio channels without
loss of samples.
Phase control
The frequency domain data output
by the FFT is used to drive the Triacs
using phase control. For each output
channel, an 8-bit brightness level is
computed from the frequency domain
data, depending on the settings for its
frequency band.
An interrupt is used to detect the
zero crossings of the mains waveform.
When the zero crossing is detected, the
microcontroller sets the triggering period
for each of the four “output compare”
(OC1-OC4) channels. When each period
expires, the microcontroller emits a short
pulse at each output compare pin.
These OC pulses turn on their cor-
Warning!
All the parts in the red shaded area on the
Main Board circuit diagram (Fig.2) operate at
mains potential (ie, 240VAC) and contact with
any of these parts could be FATAL.
These parts include the PC tracks, the optocouplers (OPTO1-4), the Triacs, the 100m
100mH
inductors, the 680W
680 W resistors, the 100nF
250VAC capacitors, screw terminal blocks
CON4-CON6, the transformer primary and the
wiring to the mains input and output sockets.
DO NOT TOUCH any of these parts unless the
power cord is unplugged from the mains supply. DO NOT CONNECT this device to the mains
unless it is fully enclosed in the specified case.
This project is not for the inexperienced.
Do not build it unless you know exactly
what you are doing and are completely
familiar with mains wiring practices and construction techniques.
responding Triacs until the next zero
crossing of the mains waveform. The
earlier in the half-cycle that each Triac is
triggered, the greater the power delivered
to its load.
The effective power varies according
to the area under the mains waveform
from the trigger point in each half cycle.
This relationship is not linear and so an
internal correction factor is calculated by
the microcontroller to make the channel
responses linear.
The microcontroller also adjusts the
triggering periods of the output channels
according to their quiescent current settings (ie, the user can set the “off” level
for each output channel). Most lamps
will respond better with a small current
flowing through them at all times, so that
they glow faintly in the “off” state. This will
also increase lamp life.
June 2008 39
|