This is only a preview of the November 2008 issue of Silicon Chip. You can view 29 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "12V Speed Controller/Lamp Dimmer":
Items relevant to "USB Clock With LCD Readout, Pt.2":
Items relevant to "Wideband Air-Fuel Mixture Display Unit":
Items relevant to "IrDA Interface Board For The DSP Musicolour":
Purchase a printed copy of this issue for $10.00. |
How to add a
wireless infrared
port to the DSP
Musicolour – or in
fact virtually any
microcontroller
project.
Musicolour
IrDA Accessory
By
Mauro Grassi
Most PCs and laptops now offer an IrDA interface to enable
communication without any physical connection. Now you can have
the same facility for the DSP Musicolour – or for virtually any other
microcontroller project.
I
n the June, July and August 2008 issues of SILICON CHIP
we described the DSP Musicolour, an advanced light
show based on the dsPIC30F4011 microcontroller from
Microchip.
We mentioned that the firmware supports a high speed
UART (Universal Asynchronous Receiver Transmitter).
The PC board below (which in fact can replace the September infrared remote control PC board) adds an IrDA
(Infrared Data Association) compatible serial port for the
DSP Musicolour.
This gives you all the features the original remote control
offered but adds a huge amount of additional features via
the serial port of your PC.
Although the firmware in the DSP Musicolour supports a
high speed UART running at up to 1.84Mbps, this interface
will run at the much slower baud
rate of 9.6Kbps, which is the
default baud rate of the DSP
Musicolour.
There is little need for it
to be higher as 9.6Kbps
should be fast enough
for most applications
(if you wish to use a
higher baud rate, you
could connect a wired The component
(upper) side of the
serial port).
IrDA is ideal for PC board is the less
interesting side – IC1 and the
adding a serial port to infrared receiver/transmitter are
a mains-rated circuit mounted on the other (copper) side.
siliconchip.com.au
as the UART is completely isolated. Since it is infrared, it
is also very convenient. Operating distance is not great – the
specification says around 1m (without any obstacles) – but
we found it works over greater distances than that.
Although this circuit was designed specifically for the
DSP Musicolour, it could be adapted so as to add an IrDAcompatible serial port to any microcontroller project. We
give you a recommended circuit to do this.
Because it was designed specifically for the DSP Musicolour, it also includes an infrared remote control receiver,
thus effectively superseding the small infrared remote
control PC board published in the September 2008 issue
of SILICON CHIP.
However, that project is still perfectly valid if you just
want to control the DSP Musicolour using a remote control.
Protocol controller
Essentially, the circuit (shown in Fig.1 overleaf) is little
more than a couple of infrared devices and a dedicated IrDA
standard protocol controller IC from Microchip, the
MCP2140A (IC1).
This IC does most of the hard work
of communicating and setting up the connection
with your PC.
We suspect that
internally, this IC is
nothing more than a PIC
microcontroller with a
custom program.
November 2008 71
47
IRD1
TFDU-4300
6
Vcc
A
14
IREDA
IrDA
Tx/Rx
VL
IREDK
TXD
RXD
GND
SD
10k
1
7
12
6
2
3
2
4
18
5
100nF
CTS
PHACT
Tx
TxIR
RxPD
11
10k
IRD2
(ZD-1952)
13
IC1
MCP2140A
RST
RI
Rx
OSC1
DTR
RTS
CD
DSR
NC
1 RxPD
REF
22 F
16V
8
Vdd
OSC2
2x
470
17
10
TO
MAIN
BOARD
A
LED1
LED2
K
K
CON1
5
8
3
7
7
6
4
1
9
2
8
10
9
16
3
X1 3.6864MHz
15
4
Vss
5
22pF
22pF
3
1
470
IRD2
2
IRD1
LEDS
SC
2008
MUSICOLOUR IRDA BOARD
K
A
1
2
3
4
5
1
6
7
8
3
2
Fig.1: the circuit is very simple, consisting of little more than a couple of infrared devices (IRD1 & 2) plus a dedicated
IrDA standard protocol controller (IC1). CON1 connects to CON3 on the back edge of the DSP Musicolour PC board.
In fact, Microchip provide the IrDA protocol stack source
code as a free download on their website.
laptop motherboards and PDAs. In fact, we used a similar
transceiver in a previous design to add an IrDA port to your
desktop PC (SILICON CHIP December 2001).
Don’t use the MCP2140!
The operation of IRD1 is simple enough. Pin 1 (IREDA) is
Note that the MCP2140 was the original IC in this sethe anode of the internal infrared LED while pin 2 (IREDK)
ries but the MCP2140A is operationally different. The
is the cathode. In normal operation, you connect IREDA to
MCP2140A will not work as a replacement for the MCP2140
the supply rail (in this case around +5V) and leave IREDK
and vice versa. That’s because the MCP2140A works with
disconnected. IREDK can be used externally to turn on
a 3.6864MHz crystal, whereas the MCP2140 works with
the LED but in our case, the LED is switched on and off by
a 7.3728MHz crystal. The two ICs require different input
internal logic.
signals into pin 18, too.
Note that a current limiting resistor is not needed to
Speaking of the 3.6864MHz crystal, it connects to the two
IREDA as the internal circuit of IRD1 limits the current
internal oscillator pins of IC1 (OSC1 and OSC2) to provide
through the LED.
the system clock. A pair of 22pF ceramic capacitors provide
Pins 3 and 4 of IRD1 are the transmit and receive lines
the correct loading for the crystal.
respectively, encoded as RZI (Return to Zero Inverted)
signals. The MCP2140A translates the NRZ (Non Return to
Infrared transceiver IRD1: the Vishay
Zero) encoding at its Tx and Rx pins to RZI signals at its
TFDU4300
TxIR and RxPD pins.
To receive and transmit data over an IrDA link, we use
The IrDA is only half duplex because the standard does not
a Vishay TFDU4300 (IRD1). This is an IrDA compatible
specify any optical isolation between the transmitter
transceiver, consisting of a transmitting LED and a
and receiver. When IRD1 is transmitting through
receiving phototransistor. There is also a small
its internal infrared LED, the receiver will also
amount of logic on the transceiver
turn on, because the phototransistor is biased
as well as an amplifier. Such
into conduction by the infrared light from
transceivers are comthe transmitting LED. The MCP2140A
monly found on
drives the transceiver in half-duplex
mode while presenting a full duplex
interface to the host device (in this case,
the dsPIC30F4011).
Pin 5 is the shutdown pin (SD), which
IC1, IRD1, IRD2 is active high. When high, IRD1 goes into
and the two LEDs are power conservation mode, drawing a very
all mounted on the copper small current (typically down to 0.1μA at
side of the PC board. IC1’s and IRD1’s room temperature).
This is useful for battery powered aplead spacings are very fine– a steady hand
and a fine-tipped soldering iron are essential. plications but in our case, where we are
72 Silicon Chip
siliconchip.com.au
LK4
1
2
LK3
X1
22pF
LK1
CON1
LK2
9
10
22 F
470
10k
22pF
+
47
10k
100nF
470
CS
10111081
470
LK5
(TOP OF BOARD)
IRD1
1
IC1
IRD2
MCP2140A
1
1
LED2
SC
10111081
LED1
Figs.2a and 2b (left)
show both sides of
the PC board, with
matching photos at
right. Note that the
22µF capacitor needs
to be installed flat,
otherwise there would
not be room for the
PC board inside the
DSP Musicolour case.
These diagrams/pics
are reproduced 1:1.
(UNDERSIDE OF BOARD)
supplying power from the Musicolour supply, we ignore
this connection and tie it permanently to ground.
Pin 6 is the supply voltage to IRD1 and pin 7 (VL) selects
the voltage level for the logic. This makes IRD1 customisable
to different logic families with different threshold voltages.
In our case, we connect it to the +5V supply rail. Finally,
pin 8 is the ground connection for IRD1.
The 22μF electrolytic capacitor is used to bypass the supply rail to IRD1 through the 47Ω resistor. The capacitor and
resistor isolate the transceiver from a possibly noisy supply rail, which can interfere with IRD1’s sensitive internal
receiving circuit.
The two 10kΩ resistors form a voltage divider and are
used to split the supply voltage and set the threshold for
the receiving logic level for IC1.
Any level above the voltage at pin 1 of IC1 (RxPD Ref)
is interpreted as a high level. Conversely, any level below
that is interpreted as a low level. This pin therefore sits at
around 2.5V. A 100nF capacitor is used to bypass this rail.
The DSR (Data Set Ready) output of IC1 will go low (thus
turning on LED1 (green)) when a valid connection has been
established with the host. It is locally emulated by IC1 and
can indicate to a microcontroller that IC1 is ready to receive
and transmit data. Thus LED1 indicates that the MCP2140A
has established a valid connection with your PC.
The PHACT (physical activity) output of IC1 (pin 3) is
open collector and will sink current (thus turning on LED2
(red)) when there is a period of inactivity from the receiver
for around 10 seconds. This pin can be pulled up to the supply rail using a resistor (1kΩ will do) and can then control
pin 5 (SD) of IRD1 through an inverter, if desired.
In this configuration, it puts the transceiver in low power
mode after a 10-second timeout. In our case, we use the
output to control LED2 and to indicate to the user that no
signal has been detected for at least 10 seconds. This can be
useful for troubleshooting.
Pin 7 (Tx) and pin 8 (Rx) are the UART transmit and
receive lines while RI (Ring Indicator), CD (Carrier Detect),
DTR (Data Terminal Ready), RTS (Request to Send) are all
part of the serial port handshaking signals. Normally, IC1
will transmit and receive the state of these lines to the PC,
emulating a full serial port.
In our case, we are really only using the raw 3-wire serial
port so we ignore these handshaking lines. We tie the DTR
line to ground, ignore the CTS output of IC1 and connect
RI to Rx. This is done simply to make the layout of the PC
board more compact. In any case, we only care about the Tx
and Rx lines and these connect to the corresponding lines
on the dsPIC30F4011 through CON1.
siliconchip.com.au
However, the RTS input of IC1 (pin13) is used locally to
indicate that the MCP2140A is ready to receive data. We
therefore tie this line permanently to ground.
Finally, pin 4 (/RST) is an active low reset pin and is
tied directly to pin 1 of CON1 (which connects to CON3 of
the DSP Musicolour main board and is the reset line of the
dsPIC30F4011 microcontroller).
The other infrared module (IRD2) is used for the RC5
remote control decoding and is really a separate circuit on
the same PC board.
Pins 3 and 2 provide the supply for IRD2 and pin 1 is the
decoded remote control data, very similar to the remote
control add-on board we described in the September 2008
issue of SILICON CHIP.
A 470Ω resistor is used between the output of IRD2 and
pin 9 of CON1 because pin 9 connects to the RF6 pin of the
dsPIC30F4011 on the DSP Musicolour main board. Because
this pin can sometimes function as an output, the resistor is
used to limit the current into the data output pin of IRD2.
Construction
This is a simple PC board that should take a matter of
minutes to build. Fig.2 shows the parts layout.
The Musicolour IrDA PC board is coded 10111081
and measures 61mm x 20mm. Inspect the board for any
hairline cracks or unintended shorts before beginning
the assembly.
If you are satisfied that the PC board is good, begin by
installing the six wire links.
Fig.3: oscilloscope screen grab showing the NRZ encoding
for a typical RS232 signal at the PHY.
November 2008 73
The IrdA board is sandwiched between the DSP
Musicolour display board and the red acrylic front panel,
with a piece of non-conductive foam holding it in place.
Here’s what it looks like from above – in this photo you
can mostly see the black foam. The connecting cable
curves around the edge of the display PC board.
Once that is done, install the six resistors. The resistor
colour codes are shown in the colour code table but you
can check them with a DMM too.
After soldering these, you can solder in the capacitors.
Start with the two ceramic capacitors near the crystal,
then install the small monolithic. Finally, install the larger
electrolytic capacitor, which must be oriented correctly, as
shown on the component overlay.
Solder in the crystal so that it sits flush with the PC board.
The top layer components except the IDC header should
now look like that in the PC board top layer photograph.
Now turn the board over to the bottom layer (where the
tracks are). There are two SMD (surface mount devices)
on the bottom layer, namely the MCP2140A (IC1) and the
TFDU4300 (IRD1).
You will need a magnifying lamp (or glass with good
light), a fine-tipped soldering iron and a steady hand. You
should start with IC1 because it is of relatively large pitch.
Place it on its pads, making sure it is oriented correctly.
Once it is in place, solder pin 18 by applying heat and
a little solder. Once that is done, solder pins 8 and 9 (diagonally opposite pin 18).
The IC should then be properly anchored and not able to
move. Proceed to solder the remaining 15 pins. The result
should be as shown in the photograph.
Now comes the hardest part! You need to solder in the
IrDA transceiver, which has a finer pitch. Place it on its
pads and hold it in place while applying heat and a very
small amount of solder to pin 1.
You then solder in pin 8 in the same way, before soldering in the remaining pins. Apply heat and solder each pin
quickly before moving on to the next pin. Do not apply too
much heat as that can damage the plastic case as well as
the integrated circuit itself.
Don’t worry if you get solder bridges between adjacent
pins, as these can be removed by using solder wick. Carefully inspect your soldering, preferably using an illuminated
magnifier or loupe and if you find any bridges, remove them.
Refer to the article on soldering SMD components on page
22 of the March 2008 SILICON CHIP for more details.
Now solder in the infrared receiver module IRD2. You
should aim for around 7mm of lead, which will allow you
to bend the module down 90° once it has been soldered,
so that it sits flush with the PC board (as we have shown
in the close-up photo).
The two LEDs are similarly bent down 90° after soldering. Make sure that they are oriented correctly.
The last thing to do is to solder in the 10-way IDC rightangled header. Again, check for solder bridges once it is
soldered in place.
You can then connect the Musicolour IrDA board to the
DSP Musicolour’s main board using the 10-way ribbon
Fig.4: a screen shot from Windows’ device manager
showing the ircomm2k driver installed and recognised
correctly.
Fig.5: screen shot showing Realterm in action
communicating with the DSP Musicolour.
Soldering the SMD ICs
74 Silicon Chip
siliconchip.com.au
From the front, without any labelling on the acrylic sheet
you can easily see the three main components (the two
IRDs and the controller chip)
The opposite end of the ribbon cable connects to the
same socket on the rear of the PC board as used in the
September 2008 article.
cable. CON1 connects to CON3 on the DSP Musicolour
main board, in exactly the same way as described in the
article in the September 2008 issue (pages 72-75).
We explained how to make a 26-way ribbon cable connecting the main board to the display board in the July
2008 issue (page 26 under Ribbon Cable Assembly). The
10-way ribbon cable used to connect the remote control
board is made in the same way.
Your IrDA Board is now complete and ready for mounting in the DSP Musicolour front panel.
It is a free download from www.ircomm2k.de/English/
index.html or via a link on the SILICON CHIP website (www.
siliconchip.com.au).
Follow the installation instructions. Note that your PC
must have an IrDA port installed. This is commonly found
on laptop computers and PDAs (but not all laptops will
have an infrared port).
Most modern desktop motherboards also have supporting
circuitry for it but will probably lack the optical transceiver.
Refer to December 2001 SILICON CHIP if you want to add an
IrDA port to your desktop PC.
Disconnect power!
The first thing to do is disconnect power from the DSP
Musicolour – pull the IEC plug out of its socket to make
absolutely sure. Then, and only then, open the case.
Do not proceed unless you are absolutely sure you know
what you are doing. Don’t be tempted to connect power
while the case is open – it is too dangerous.
Where it sits
The IrDA PC board fits between the red acrylic front
panel and the display PC board. A piece of foam holds it
in place and also insulates it from the components on the
display board.
This is not an ideal mounting solution . . . but it is just
about the only one! Because this board is an add-on, it was
not catered for in the original DSP Musicolour design. But
we think it’s a practical addition and we’ve made the only
mounting decision possible.
Again, we have shown a close-up photo to show how
it goes in. You can then close the case again by screwing
it shut.
Using the IrDA board with the
DSP Musicolour
This add-on board gives the DSP Musicolour a wireless
serial port you can use to communicate with a PC. It also
allows the DSP Musicolour to be operated using an RC5
remote control, in the same manner as explained in the
September 2008 of SILICON CHIP (pages 72-75). You can
define the remote control codes as explained in that article.
Software for Windows:
the IRCOMM2K driver
Before communicating with the IrDA board, you will
need to install a software driver implementing the IrCOMM
protocol on Windows 2000 and XP.
siliconchip.com.au
Using the IrDA serial port
Once you download the zipped ircomm2k driver, extract the files and run setup.exe. The install program will
prompt you for the serial port number to install the virtual
IR port. Choose a port number (say COM5) that will not
interfere with any other (physical) serial ports implemented
on your PC.
You should then disable the “Wireless Image Transfer” in
Windows. Go to Control Panel > Wireless Link and in the
image transfer tab, unclick the box selecting “Use Wireless
Parts List –
Musicolour IrDA Accessory
1 PC board, coded 10111081, 63mm x 21mm
1 3.6864MHz PC board mounting crystal (X1)
1 10-way PC board mounting IDC male connector
1 10-way ribbon cable, approx. 250mm long fitted
with female line sockets
Semiconductors
1 MCP2140A
1 TFDU-4300 infrared transmit/receive module
1 Infrared receiver (eg Jaycar ZD-1952)
1 3mm green LED (LED1)
1 3mm red LED (LED2)
Capacitors
1 22μF 16V electrolytic
1 100nF ceramic
2 22pF ceramic
Resistors (0.25W, 1%)
1 47Ω
3 470Ω 2 10kΩ
November 2008 75
Link to transfer images from a digital
camera”. This needs to be disabled because the Windows service interferes
with the ircomm2k driver.
Once that is done, you should reboot
Windows. If the driver is installed
correctly, you should be able to see
it under Control Panel > System >
Device Manager > Ports COM and
LPT > Virtual IR COM Port (COM5),
as shown in Fig.4.
Installing Realterm
The final thing to do is to use a
terminal program to communicate
with the Musicolour IrDA board. You
can use Windows’ hyperterminal if
you wish, available under Start >
Accessories > Communications >
Hyperterminal.
Another good program to use is the
freely available realterm. Download it
from http://realterm.sourceforge.net/
Once that is installed, you can
establish a link with the Musicolour
IrDA board using COM5 (or whatever
number for the virtual IR port you
chose in the installation step above).
You should set the encoding to 8
bits, 1 stop bit, no parity, 9.6Kbps.
As soon as you open Realterm and
start typing characters, the green LED
(LED1) on the IrDA board will light,
indicating that a valid connection has
been established.
Remember that you need to position
your PC or laptop so that its infrared
transceiver is in the line of sight of
IRD1 and within 1m or so.
The characters you type will then
be sent via the infrared link to the
Musicolour IrDA board and onto
the UART on the main board of the
Musicolour (ie, on the dsPIC30F4011
microcontroller). A typical screen shot
is shown in Fig.5.
In the DSP Musicolour menu system, you can go to the CONSOLE >
COM submenu. There the DSP Musicolour will display the received characters from the serial port and echo
back the same character. You should
do this to test that the IrDA board is
working correctly.
As you type your characters in Realterm, you should see them appear
on the dot matrix display of the DSP
Musicolour.
How to upgrade the firmware
of the DSP Musicolour
If there are some aspects of the
DSP Musicolour’s firmware which
76 Silicon Chip
you’d like to change – and you have
the knowlege to do so – it can can be
upgraded using this infrared port.
Using Realterm, you can send a hex
file to the DSP Musicolour to force it
to reconfigure its flash memory using its RTSP server. To do this, go to
the ADVANCED > Write Mode menu
and set it to 6 (thus allowing writing
of the flash memory). Then go to the
ADVANCED > Software Upgrade
submenu. Once you enter that mode,
the dot matrix display will go blank.
The DSP Musicolour will send
a string to your Realterm window
through the infrared link. You can then
use realterm to send a hex file to the
DSP Musicolour which will reprogram
itself and reset.
You should set the line delay to
40ms or higher. You then select the
hex file you want to send and click
send. Realterm will send each line
and wait for the set line delay before
sending another line.
If manually sending hex file lines,
you must send the :00000001FF (end
of file) line to indicate to the DSP
Musicolour that programming is finished. Once the EOF (end of file) line
is received by the RTSP server, the
DSP Musicolour will reboot after 10
seconds and the new firmware version
will be operational.
SC
How to modify the PC board to add an infrared
serial port to a microcontroller project
As we mentioned before, this PC board
was designed to interface with the DSP
Musicolour main board. But it can easily
be modified to add a serial port to your
next microcontroller project.
The modified circuit diagram below
shows a typical application. The levels at
CON1 are only TTL levels, adequate for interfacing directly to most microcontrollers
implementing a UART.
Note that if you wish to interface the
modified board directly to a PC and
need true RS232 voltage levels, you will
need to add a MAX232 or similar IC to
translate the TTL levels at CON1 to true
IRD1
TFDU-4300
22 F
16V
6
Vcc
47
IREDA
VL
IREDK
TXD
RXD
GND
SD
1
4 RST
10k
7
6
2
3
2
4
18
5
100nF
3
SC
10k
13
5
6
7
CON1
DB9F
RS232
(TTL LEVEL)
PHACT 3
IC1
MCP2140A
DSR
CTS
Tx
CD
RI
Rx
DTR
TxIR
RxPD
OSC1
RTS
OSC2
Vss
5
4
IRD1
2008
NC
Vdd
1 RxPD
REF
8
2
+5V DC
INPUT
14
IrDA
Tx/Rx
1
RS232 levels (this is not shown in the
circuit diagram).
The host (ie, the microcontroller) should
only send data to the MCP2140A when CTS
(Clear To Send) is low.
On the other hand, the host should
drive DTR (Data Terminal Ready) low
when it is ready to receive data from the
MCP2140A.
The host can then send and receive
data from the MCP2140A through the Tx
and Rx pins (encoded as NRZ) ultimately
to the connected IrDA-enabled PC or PDA
(confusingly this is also a host, ie, the
IrDA host!).
10
12
7
17
9
8
11
16
6
3
9
X1 3.6864MHz
4
5
8
1
2
7
15
22pF
22pF
8
MODIFIED IRDA CIRCUIT
Use this modified circuit to add a wireless serial port to virtually any
microcontroller project. Unlike the circuit used specifically to interface to the
DSP Musicolour main board, this circuit emulates the full serial port rather
than just the Rx and Tx signals. This can be used for handshaking between
the microcontroller and IC1.
siliconchip.com.au
|