This is only a preview of the November 2012 issue of Silicon Chip. You can view 22 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 "High-Power Class-D Audio Amplifier, Pt.1":
Items relevant to "High-Energy Ignition System for Cars, Pt.1":
Items relevant to "LED Musicolour: Light Up Your Music, Pt.2":
Items relevant to "Hacking A Mini Wireless Webserver, Pt.1":
Purchase a printed copy of this issue for $10.00. |
Light up your music with the . . .
LE D
MUSICOL OUR
Pt.2: By NICHOLAS VINEN
The new LED Musicolour makes building a
spectacular light and music show easier than
ever. In this second and final instalment, we
explain how to build and test the unit and
also detail how you can control it.
W
E’LL GET onto the construction
of the LED Musicolour shortly.
Before we do, let’s quickly look at a
few more design details.
One aspect of the unit’s operation
that we didn’t mention in Pt.1 is the
automatic gain control (AGC). This
applies when you are feeding audio
into the unit via the audio line input
socket (CON11). The problem is that
line level signal amplitude can be quite
38 Silicon Chip
variable and we don’t want the lights to
be driven dimly simply because your
signal source has a low peak voltage.
To solve this, we constantly monitor
the peak voltage at the audio inputs
and apply an asymmetrical low-pass
(smoothing) function to it. The output
of this function remains close to the
long-term peak of the audio signal,
even though the amplitude won’t be
constant. We do this by allowing the
detected peak voltage value to increase
rapidly but only decrease slowly.
Given this detected peak amplitude,
we can then “normalise” the audio
data by computing a gain value which
is the inverse of this peak amplitude,
ie, the lower the amplitude, the higher
the gain. This gain is applied before the
Fast Fourier Transform (FFT) function
is applied to the audio data. The output of the FFT then gives a consistent
brightness level over a range of input
signal amplitudes from around 500mV
RMS up to a little over 2V RMS.
When we describe the configuration
options later, you will see that there are
a few options which control the rate
at which the AGC level changes and
the maximum gain setting available.
We’ve chosen defaults that work well
siliconchip.com.au
siliconchip.com.au
No.
2
2
3
3
5
1
6
2
1
19
1
Value
1MΩ
120kΩ
100kΩ
47kΩ
10kΩ
4.7kΩ
1kΩ
470Ω
220Ω
100Ω
10Ω
T
1k
4004
100
100
100
100
4.7k
47k
100
10F 100nF
100nF
10
220
IC2
WM8759
S
1k
1M
100
100pF
10k
+
CON12
OUTPUT
LM3940IT-3.3
Q10
BC327 100F
+
100
1M
+
R
LED1
47k
A
IRD1
Fig.3: install the parts on the PCB as shown in this diagram, starting with the
SMD components. The off-board LED strips are connected to pin headers CON1CON8 via matching header sockets. Note that infrared receiver IRD1 is installed
upside down (see text and photo).
bridges between the pins. If there are,
use solder wick to clean them up.
That’s best done by first adding a little
liquid flux paste (no-clean type) along
both rows of pins and then removing
any excess solder using the solder
wick. You can clean up the flux residue
with isopropyl alcohol if you like.
Note that for each of Q1-Q8, two
pairs of pins share a single, larger
pad. These are the two Mosfet drains.
Obviously you don’t have to worry
Table 1: Resistor Colour Codes
o
o
o
o
o
o
o
o
o
o
o
o
CON13
SD CARD
SOCKET
100nF
12101161
+
+
S
220F
10F
C 2012
ruolocisuM DEL
10F
100F
100F
LED Musicolour
REG2
10F
+
+
100nF
10F
100nF
+
BAT85
220F
33pF
IC1 dsPIC33FJ128GP802
47k
BAT85
T
10nF
8MHz
C
+
BAT85
CON11
INPUT
10nF
100nF
BAT85
100pF
R
1k
10k
D2–D5
X1
100F
2102
100F
Building the main PCB is relatively
straightforward and should take just
a few hours. Fig.3 shows the parts
layout. The board is coded 16110121
and measures 103 x 118mm.
The 11 SMD components are mount
ed first, ie, the eight dual Mosfets
(Q1-Q8), audio DAC IC2, the 10µF
ceramic capacitor for IC1 and the SD
card socket (CON13).
Start with Mosfets Q1-Q8, which are
in 8-pin SOIC packages. In each case,
the pin 1 dot goes towards the lefthand
side of the PCB. Place a small amount
of solder on one pad, line up the IC and
slide it into place while heating that
solder. If it isn’t positioned correctly
on its pads, reheat the solder and reposition it. Make sure it’s sitting flat on
the board, then solder the remaining
pins. Finally, add some more solder
to the first pin.
That done, check that there are no
100
100
470
33pF
100nF
Construction
100
100
IC3 74HC393
10k
100k
120k
10k
120k
100k
100nF 100nF
IC5 74HC595
470
D1
LOW ESR
220F 25V
+
IC4
LM358
100nF
1k
100nF
F1: 10A
+
1k
100nF
Q1
REG1
7805
10k
CON10
CON9
CON1
Q2
Q3
16110121
IC6 74HC595
CON2
+
BC547
Q9
CON3
+
100nF
CON4
Q4
Q5
100
100
100
100
CON5
Q6
Q7
100
1k
100k
100
Q8
Throughout these articles we have
generally referred to the memory card
as an “SD card”. There are actually
several different types of SD card.
These days, most cards sold are actually SDHC (high capacity) cards in the
range of about 4GB-32GB. We have
successfully tested the largest of these
cards in the LED Musicolour.
It should also support the older
MMC cards although they are basically
obsolete now. We haven’t tested SDXC
(64GB+) cards but in theory, they
should work too as they still support
the 1-wire SPI interface we are using to
communicate with the memory card.
CON6
CON7
100
CON8
100
Memory cards
+
in most circumstances so you won’t
normally need to change these.
4-Band Code (1%)
brown black green brown
brown red yellow brown
brown black yellow brown
yellow violet orange brown
brown black orange brown
yellow violet red brown
brown black red brown
yellow violet brown brown
red red brown brown
brown black brown brown
brown black black brown
about these being bridged although
you should check that the two drains
are not accidentally shorted.
Fit the rest of the SMD parts using
the same method, with the exception
Table 2: Capacitor Codes
Value µF Value IEC Code EIA Code
100nF 0.1µF
100n
104
10nF 0.01µF 10n
103
100pF NA
100p
101
33pF
NA
33p
33
5-Band Code (1%)
brown black black yellow brown
brown red black orange brown
brown black black orange brown
yellow violet black red brown
brown black black red brown
yellow violet black brown brown
brown black black brown brown
yellow violet black black brown
red red black black brown
brown black black black brown
brown black black gold brown
November 2012 39
The fully-assembled PCB is shown above, while the photo at right shows how it fits inside
the specified plastic case. Note the small heatsink fitted to regulator REG1.
These two photos show the mounting details for the infrared receiver (IRD1). It
must be mounted upside down (so that its lens lines up with the adjacent LED),
with its leads run down the back of its body.
of the SD card holder. This has two
plastic posts which go into holes on
the PCB, holding it in position. You
then solder the larger mounting tabs,
followed by the signal pins. There
are 15 in all; remove and discard the
plastic insert before soldering those
inside the socket.
Through-hole parts
Now mount the resistors, checking
each value with a DMM first. You can
refer to the colour code table but the
multimeter is more reliable. Follow
with diode D1 (1N4004) and then the
four smaller Schottky diodes, D2-D5.
In each case, ensure that the cathode
stripe is orientated as shown.
40 Silicon Chip
Solder crystal X1 in place next, then
fit the IC sockets or, if you are not using
a socket at any location, the IC itself.
It’s a good idea to use a socket for IC1
but the rest are optional. Either way,
make sure the pin 1 notches are all
orientated towards the righthand side
of the PCB, as shown on the overlay.
Next, bend REG2’s leads down
through 90° about 7mm from its tab,
then use an M3 x 6mm machine screw,
shakeproof washer and nut to fasten
it to the board. Do the screw up tight,
then solder and trim the leads.
That done, install the two 3.5mm
stereo jack sockets. These must sit
flush against the PCB and must be
correctly aligned with its edge. Follow
with the two small signal transistors,
taking care not to get them mixed up.
Bend their leads with small pliers to
suit the pad spacing on the board.
Pin headers CON1-CON8 can now
go in. If you can’t get 8-pin dual row
right-angle pin headers, make them
from longer, snappable headers. Do
this carefully using pliers and file off
any burrs. Check that each header
fits through the hole in the rear panel
before soldering it to the PCB. When
doing so, take care that the projecting
pins are parallel to the surface of the
PCB and at right-angles to the edge.
If one of the headers won’t fit
through the rear panel, a few strokes
with a needle file will generally take off
enough plastic to fix it. This is easier
to do before the header is soldered to
the board. It’s also a good idea to check
the alignment of each header once you
have soldered a couple of its pins.
With the pin headers in place, you
can then mount CON9 and CON10,
again checking that they are aligned
correctly to fit through the rear panel
hole. Follow with the two fuse clips;
push them down all the way onto the
PCB and check that the end-stops are
on the outside.
The MKT and ceramic capacitors
go in next, in the locations shown on
the overlay diagram. Follow with the
siliconchip.com.au
the screw firmly before soldering and
trimming REG1’s leads.
The PCB assembly can now be
completed by fitting the 10A fuse and
plugging the ICs into their sockets.
Make sure that the pin 1 notch or dot
of each IC goes towards the righthand
side of the PCB – see Fig.3.
Putting it in the case
Before fitting the PCB into the case,
first you must cut off or file down the
four inner plastic posts in the base, ie,
the ones which don’t correspond with
the PCB corner mounting holes. That
done, push the rear panel onto the PCB
connectors until it sits against the edge
of the board. It should be a tight fit.
If it won’t go, carefully use a needle
file to slightly enlarge the offending
cut-out and try again.
With the rear panel in place, you
can then unscrew the nuts for the two
3.5mm stereo sockets and slip the front
panel on. It should fit easily but again,
if it doesn’t, a little filing should fix it.
Check that LED1 and infrared receiver
IRD1 are properly aligned with their
holes and if not, adjust them. Once the
panel is in place, refit the two nuts to
the sockets to hold it in place.
You can now slip the whole assembly down into the channels in
the bottom of the case and attach the
board to the integral stand-offs using
four self-tapping screws.
electrolytic capacitors, ensuring that
in each case, the longer lead goes into
the hole marked with a “+” on the
overlay diagram.
That done, bend the green LED’s
leads down 2mm from its lens so that
when fitted, its anode (longer lead)
will go towards the right. Solder it in
place with the horizontal portion of
the leads 3mm above the PCB. Don’t
trim the leads too short in case you
need to adjust it later.
Infrared receiver
IRD1 is installed in an unusual manner – basically upside-down, so that
the centre of its lens is aligned with
the other front panel connectors and
the LED. This means the leads run
down the back of the receiver and the
top of the housing sits on the surface
of the PCB.
We used a plastic-encapsulated type
but some infrared receivers have a
metal shield. Because the leads run
near the body of the device and besiliconchip.com.au
cause of the exposed pads on the PCB,
you will have to place an insulating
layer (eg, electrical tape) over the back
and top side of the receiver.
There’s a bit of a trap here because
you might expect that this is unnecessary for IR receivers which have a
plastic case. In fact, many of these use
a conductive type of plastic (for shielding) so you should put some insulation
along the rear and top of these as well.
Make sure the body can’t make contact
with the leads or PCB pads. If it does,
the receiver won’t work.
Once you’re ready, bend the leads
through 180°, against the insulation
layer on the rear of the receiver, then
push it down all the way onto the PCB
and solder it in place. The accompanying photos show how we did it.
Now bend regulator REG1’s leads
down through 90° in a similar manner
as for REG2. This device is then fastened to the PCB along with a mini-U
heatsink using an M3 x 10mm machine
screw nut and flat washer. Tighten
Testing
It’s best to test the unit initially
without the LED strips plugged in.
You can use a 7.5-24V DC plugpack
if you have one handy. Alternatively,
use the 12-24V power supply you will
be using later.
Plug in the supply and switch on.
Check that LED1 lights immediately.
If it doesn’t, switch off and check
for faults (make sure IC1 has been
programmed correctly). If all is well,
measure the outputs of REG1 and
REG2. Connect the negative lead of
a DMM to the tab of either regulator
and then, with the board orientated
as in Fig.3, measure the voltage on
the top pin of REG1 and the lefthand
pin of REG2. You should get readings
in the range of 4.8-5.2V for REG1 and
3.2-3.4V for REG2.
If you plan to use an infrared remote
control, you can point a universal remote set for a common Philips device
code (TV, VCR, etc) and press some
buttons. The green LED should flash
November 2012 41
Table 1 – Infrared Remote Control Commands
Button
Command
Description
Play
Stop
Pause
Down arrow
Up arrow
Right arrow
play
stop
pause
next_folder
prev_folder
next_file
Left arrow
prev_file
Channel +
Channel Volume +
Volume Mute
Fast forward
Rewind
0-9
Power
Record
next_mode
prev_mode
volup
voldn
mute
forward
back
0-9
reset
order
Starts or resumes playback
Stops playback. Pressing it twice resets the unit.
Pauses or resumes playback
Play first file in next folder
Play first file in previous folder
Play next file in this folder (will skip to next folder on last file)
Play last file in this folder (will skip to previous folder on
first file)
Changes light display mode; see Table 2
Changes light display mode; see Table 2
Increases volume in ~1dB steps (default is 0dB)
Decreases volume in ~1dB steps (minimum is about -30dB)
Toggles mute mode
Skip ahead 10 seconds
Skip back 10 seconds
Goes to a specific light display mode; see Table 2
Resets device to initial settings
Cycles file order through sorted shuffle and directory (see text)
Table 2 – Light Display Modes
Mode
0
1
2
3
4
5
6
7
8
9
Description
16 frequency bands, 40Hz-4kHz, combining both channels (default)
Two sets of 8 frequency bands, 40Hz-4kHz, one for each channel
16 frequency bands, 40-750Hz, combining both channels
16 frequency bands, 750Hz-4kHz, combining both channels
16 frequency bands, 40Hz-4kHz, left channel only
16 frequency bands, 40Hz-4kHz, right channel only
16 frequency bands, 40-750Hz, left channel only
16 frequency bands, 750Hz-4kHz, left channel only
16 frequency bands, 40-750Hz, right channel only
16 frequency bands, 750Hz-4kHz, right channel only
in response. If not, try a different code
and failing that, check that the left and
right pins on the infrared receiver are
not shorted to ground (possibly via
the case). In the quiescent state, these
pins should both measure at least 3V.
If you have an SD card, copy a
44.1kHz or 48kHz 16-bit stereo WAV
file to its root folder and plug it in.
The green LED should flash a few
times and if you now connect the LED
Musicolour’s line output to a stereo
amplifier, you should hear the audio
file being played back. Remove the SD
card when you have finished.
You can also test the audio input.
It’s simply a matter of connecting it to
a signal source such as a DVD player,
MP3 player or computer sound card
and again feeding the output into a
stereo amplifier.
42 Silicon Chip
Finally, with no SD card inserted
and nothing plugged into the audio
input or output jacks, plug in one or
more LED strips (it’s OK to do this
while the unit is running). Within 30s
of switching on, the unit should go
into a test mode where the LED strips
fade up and down in brightness, in a
pattern moving from output 1 through
to output 16 and then repeating.
You can use this test mode to verify
that all the LED outputs are working
properly and that you have the strips
connected in the right sequence. When
you do, the light should appear to
move smoothly from one side of the
display to the other.
If it all checks out, you can put the
lid on the case. If any of the tests fail,
switch off and check the PCB carefully for faults. Inspect the SMD and
through-hole solder joints and verify
that the correct components are installed in each location. Check also
that all polarised components (diodes,
electrolytic capacitors, ICs) are the
right way around.
Wiring the LED strips
You may be able to purchase LED
strips with 4-pin female connectors
already attached but many strips come
with bare wires or just pads on the
end of the flexible PCB. In this case
you will need to connect a length of
2-way or 4-way cable with a pin header
at the end.
The easiest way is to buy pre-made
cables with 4-pin female headers at
each end and chop them in half. These
are available from various online
retailers such as Australian Robotics (http://australianrobotics.com.au
– SKU PRT-10364) or Seeed (www.
seeedstudio.com – SKU CAB104C4O).
It is possible to crimp your own connectors but this is a fiddly task without
a specialised crimping tool. The plugs
are available from element14 (eg,
Cat. 865620 & 1022220) and Futurlec
(HDCONNS4 & HDPINF).
Using it
At this stage, you can plug everything in, turn it on, sit back and watch.
However, you may want to do some
additional configuration or learn how
to use the remote control commands.
If you are going to use a universal
infrared remote, the Jaycar AR1726
should be set to TV code 102 and the
AR1723 to code 0348. The Altronics
A1012 should be set to TV code 156.
Other universal remotes should work
but you may have to try multiple
Philips TV codes before you find the
right one.
Refer to Table 1 to see which button
does what. Note that the IR command
codes can be changed – see below.
Play, stop, pause, mute, fast forward/rewind and volume up/down are
all self-explanatory. If you only want
to play a few audio files, you can place
them all in the SD card’s root folder
or a sub-folder and then simply use
the left and right arrow buttons (next
and previous file commands) to skip
between them.
However, given the high capacities
of SD cards that are available today
(64GB or more), you can put a lot of
WAV files onto one card and skipping
through them individually can be a
siliconchip.com.au
The 16-channel outputs from the unit are connected to the coloured
LED strings via 4-way pin headers (two pins for the positive rail and
two for the switched negative rail).
chore. So you can instead organise
them into separate folders.
The next and previous file commands will still skip through the
whole lot but you can also use the
Up and Down arrows on the remote
to skip to the previous or next folder
respectively. That way, you can quickly
locate the folder with the file(s) that
you want to play back and then use
the Left and Right arrows to select the
desired file. Each folder can contain
one CD’s worth of audio files or you
can organise them however you want
(by genre, by performer, etc).
SILICON
CHIP
Normally, the order in which files
and folders are played is alphabetical.
You can change this to random (shuffle) or directory order (the order the file
entries are stored on the card). This is
done either by pressing the Record button on the remote control or with the
configuration file, as explained below.
Lighting modes
The lighting modes available are
shown in Table 2. The default is mode
0. In this mode, the audio data from
the left and right channels is mixed
to form a mono signal and this is then
LED Musicolour
Audio
Input
Audio
Output
Memory Card
+ +
-
On/Ack
SILICON
CHIP
12V/24V DC
-
split up into 16 frequency bands, more
or less equally spaced over the six or so
octaves from 40Hz to 4kHz. The audio
energy in each band then determines
the brightness of the corresponding
LED strip, where LEDs1 correspond
to the lowest band (~0-40Hz) and
LEDs16 correspond to the highest band
(~3.5-4kHz).
With mode 1, the difference is that
the channels are processed separately
and are used to drive LEDs1-LEDs8
(left) and LEDs9-LEDs16 (right). Each
band therefore covers a larger range
of frequencies.
Fig.4: the front & rear
panel designs for
the LED Musicolour.
Cutting the plastic endpanels provided with
the case is very difficult
given the number and
shape of the cut-outs so
we are offering premade PCB panels with
screen-printed labels
(see parts list in Pt.1).
12V/24V LED Outputs
15
13
11
9
7
5
3
1
+ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - +
10A
siliconchip.com.au
<3A
+ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - +
16
14
12
10
8
6
4
2
November 2012 43
Table 3 – Configuration Commands
Setting
Valid Options
Description
mode
spectrum attack
spectrum decay
min brightness
default playback order
default volume
start playback automatically
default repeat all
agc filter coefficient
0-9
0-255
0-255
0-255
sorted,shuffle,directory
0-100%
yes,no,true,false
yes,no,true,false
0-65535
agc max error
0-65535
agc max
agc delta limit
0-65535
0-65535
remote code <command>
RC5(0x????)
infrared logging
on,off
Which light display mode the unit starts up in (default=0)
If set below 255, limits the rate at which LED brightness can increase (default=255)
If set below 255, limits the rate at which LED brightness can decrease (default=255)
Brightness level below which a strip remains off (default=8)
Which order WAV files and folders are processed (default=sorted)
The initial sound output volume (default=100%)
If yes/true, playback starts immediately
If yes/true, when the last file is finished playing, it starts again with the first (default=yes)
AGC low-pass filter coefficient, lower values give slower gain changes (default=16)
Amount by which AGC output is allowed to deviate from nominal before gain changes
(default=256)
Maximum allowable AGC gain, multiplied by 4096 (default=16384, ie, gain of four)
Maximum change in AGC gain in a single step (default=4)
Changes the 16-bit RC5 code assigned to a given command; number can be decimal
or hexadecimal as shown. See Table 1 for command names.
If set to on, valid RC5 remote control codes detected are written to a log file on the
SD card (default=off)
the configuration file. For example, if
you want to simulate a “peak hold”
spectrum analyser, you can set the
spectrum decay setting low (say, to 8).
This means that a LED strip driven at
full brightness will stay on for 256 ÷
8 = 32 window periods or about 1.5
seconds. You can play around with
the attack and decay settings to see if
you prefer the effect achieved.
As you can see from the table, there
are quite a few settings although many
of them are provided for people who
really want to tweak the way the unit
works. Most of the settings can simply
be left at their defaults.
This view shows how the LED strips are wired to the 4-way header sockets.
The two outer leads go to the positive rail while the inner leads go to the
negative rail, so the socket can be plugged into a header either way around.
Modes 2-9 are similar to modes 0
and 1 but are intended for use when
you have more than one LED Musicolour unit. For two units, you feed them
the same audio and then use either
modes 2 & 3, with each unit processing half the frequency bands, or modes
4 & 5, with each unit processing one
channel. With four units, set them to
modes 6-9.
Of course, if you prefer the way one
of these other modes looks with a single Musicolour, there’s nothing stopping you from using it that way too.
Configuration file
So that you don’t have to change
the settings with the remote control
44 Silicon Chip
each time you power the unit on, you
can record them in a configuration
file in the root folder of the SD card.
This works even if you don’t want to
use the SD card to play back audio; if
you don’t put any WAV files on the
card, the unit will instead utilise its
audio input, just as if there was no
card inserted.
This file must be called “LED Musicolour.cfg” and contains one line per
setting. Each line starts with the name
of that setting, then has an equals sign
(“=”) and then the value. The options
are shown in Table 3. Any settings not
specified remain at the default value.
There are some options to control
parameters that you can only set using
SD card bootloader
In case of bugs in the firmware, we
have incorporated a “bootloader”. This
checks for the presence of a certain
HEX file in the root folder of the SD
card when power is first applied. If it
exists and its contents differ from the
micro’s flash memory, the bootloader
re-flashes the micro.
During this process, LED1 flashes.
From then on, the microcontroller will
run using the new firmware from that
HEX file.
The file must be called “LED Musicolour.hex”. If we release an updated
version of the firmware, it will probably have a different file name so you
will need to rename it after copying
it to the memory card. Once the unit
has successfully been re-flashed, you
should delete the file from the SD card.
SC
That’s it; enjoy the show!
siliconchip.com.au
|