This is only a preview of the April 2014 issue of Silicon Chip. You can view 27 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 "40V Switchmode Bench Power Supply, Pt.1":
Items relevant to "USB-To-RS232C Serial Interface":
Items relevant to "A Rubidium Frequency Standard For A Song":
Purchase a printed copy of this issue for $10.00. |
USB/RS-232C
By
JIM
ROWE
Want to connect an older test instrument or PC peripheral fitted with
a ‘legacy’ serial RS-232C interface to your late-model PC or laptop?
That is a real problem with today’s PCs which only provide USB ports.
Here is the solution: build this very small USB to RS-232C serial interface.
M
any readers have test instruments, GPS receiver
modules, Rubidium oscillators or PC peripherals
which work very well but they can pose a problem when it comes to hooking them up to a current-model
desktop or laptop PC.
That’s because many older instruments and devices were
fitted with what is now known as a ‘legacy’ serial RS-232C
interface, while most recent PCs are only provided with
USB ports.
Yes, we know you can purchase cheap USB to RS-232C
interface adaptors. But many of these don’t work very
well – or don’t work at all – with older equipment with
RS-232C interfaces. Also, many of these gizmos are not
compatible with Windows VCP (virtual com port) drivers
and need to have a custom driver installed – which is often
a problem in itself.
Cheap, not nasty!
That’s why we’ve come up with this new interface, which
can be built up at very low cost. Total cost, including the
PCB, should be about $32 or less. And you should be able
to assemble it in just a few hours.
All of the parts, including the input and output connectors, fit on a PCB which measures only 76 x 46mm. It fits
neatly into the smallest jiffy box currently available – the
UB5 size, measuring 83 x 54 x 31mm.
About the circuit
The complete circuit of the interface, shown in Fig.1,
56 Silicon Chip
uses just two chips and not much else. At its heart is IC1, a
Microchip MCP2200 ‘USB-UART Protocol Converter’ chip,
which seems to be rather similar to a PIC18F14K50 micro
but is hard-wired to perform USB/serial and serial/USB
conversion. On the serial side it’s coupled to the inverters
inside a 74HC14 hex Schmitt trigger inverter device (IC2),
acting as serial drivers and receivers.
Where’s MAX?
And no, we have not coupled the MCP2200 to a MAX3232
or MAX3222 multi-channel RS-232C driver/receiver device
– to give the circuit ‘full spec’ bipolar RS-232C compatibility. Our first prototype did use that approach but we
found that it would not operate reliably with a number
of instruments and devices. These turned out to have a
serial interface which provided only ‘unipolar’ 0V/+5V
signal swings.
This was done (a) to save money and (b) because just
about all of the serial ports on earlier PCs would interface
quite reliably with these signals, even though they were
nominally designed to provide and accept bipolar signal
swings, ie, signal swings meeting the full RS-232C specification, which specified from -5V to -15V for a mark or ‘1’,
and from +5V to +15V for a space or ‘0’.
So after quite a bit of testing and experimentation we
decided to replace the MAX3222 driver/receiver device
with the 74HC14 shown in Fig.1. It effectively goes back
to the old unipolar ‘watered down RS-232C’ configuration
but we have found it to work reliably with all of the ‘legacy’
siliconchip.com.au
INTERFACE
serial ports we’ve been able to try it with, including those
with ‘true RS-232C’ ports as well as those with the ‘watered
down’ approach.
We can’t guarantee that it will work reliably with ALL
equipment fitted with a ‘true RS-232C’ port, because there
may be some gear out there with a finicky RS-232C driver/
receiver chip which won’t recognise unipolar signals.
But we suspect these are few and far between, especially
these days.
It’s also worth noting that while the original ‘full spec’
bipolar signals were designed to give reliable operation over
quite long cables (up to at least 15m long), the unipolar
0V/+5V signals of this interface won’t be capable of anything like this. But since this interface is intended mainly
to connect ‘legacy’ instruments and equipment to a nearby
PC, this shouldn’t be a problem.
Returning to the circuit of Fig.1, you can see that four of
the inverters inside IC2 are used as drivers, two in parallel
for the transmit data (TxD) line and the other two in parallel
for the Ready-to-Send (RTS) handshaking line. The remaining two inverters are used as receivers, for the Receive data
(RxD) line and the Clear to Send (CTS) handshaking line.
So what’s the purpose of the 1kseries resistors in
those ‘receive’ signal lines, and also for diodes D1-D4?
These components are included to allow the inputs of the
‘receiver’ inverters inside IC2 to handle both true-RS232C
bipolar swing signals as well as unipolar signals. The 1k
resistors limit the current flow, while the diodes ensure that
the inverter inputs are ‘clamped’ to a maximum DC input
level of +5.6V and a minimum level of -0.6V.
The circuitry around IC1 is quite straightforward. Pins
18 and 19 are the USB data lines and these connect directly
to pins 2 & 3 of USB connector CON1.
Pins 2 & 3 of IC1 are the input and output pins for its
internal clock oscillator which runs at 12MHz as a result
of connecting crystal X1 and the 33pF and 15pF capacitors. The oscillator runs at 12MHz because it connects
to an internal PLL (phase-locked loop) which effectively
multiplies the clock by four, to achieve the 48MHz needed
by its USB 2.0 interface engine.
Pin 17 of IC1 is its VUSB pin, which needs to be provided
with a 470nF bypass capacitor for correct USB enumeration. Pins 5 & 6 are configured in this application to drive
LEDs 1 & 2, which blink to indicate activity on the serial
RxD and TxD lines.
By the way, the MCP2200 is configured from your PC,
using a small (freeware) configuration utility. This can be
used to configure the MCP2200 in terms of baud rate, data
format and so on. We’ll describe this in detail later.
No external power is needed for the circuit as it is
powered from your PC itself, via the USB cable and pin 1
of connector CON1. Typical current drain varies between
about 18mA and 29mA, depending on the data being sent
and received; well within the 100mA limit.
Construction
As you can see from the photos and the overlay diagram
of Fig.2, all of the components used in the interface are
+5V
10F
+5V
Rx LED
10k
TANT
LED1
100nF
USB TYPE B
CON1
1
4
2
3
18
RST
VDD
470
19 D+
GP6/RxLED
14
15
2
X1 12MHz
33pF
1
GP5
9
3
15pF
K
4
D–
8
A
GP4
GP3
GP7/TxLED
GP0/SSPND
IC1
MCP2200
GP2
GP1/USBCFG
OSC1
CTS
RxD
TxD
RTS
VUSB
OSC2
Vss
20
A
100nF
Tx LED
LED2
K
A
A
D3
K
14
470
7
K
MMC
D1
VDD
8
9
CTS
6
5
RxD
1k
6
5
16
K
IC2
74HC14
13
1
3
10
11
17
470nF
MMC
CON2
K
D4
2
12
1k
DE-9M
PLUG
D2
1
A
A
6
4
11
10
13
12
2
7
TxD
8
9
RTS
Vss
3
4
5
7
SC
2014
usb TO RS-232c SERIAL INTERFACE
Fig.1: just two ICs and a handful of other components make up the interface.
siliconchip.com.au
D1–D4: 1N4148
A
K
K
A
LEDS
April 2014 57
narrow solder-wick (pressed against the pins concerned
using the tip of your soldering iron).
All of the remaining components are through-hole
parts, which can be fixed to the PCB in the usual way. Fit
the resistors first, followed by the capacitors, taking care
with the polarity of the 10F tantalum, which is the only
polarised capacitor.
Then fit crystal X1, followed by diodes D1-D4 – using
the diagram Fig.2 to guide you regarding their polarity.
Next fit IC2, the pins of which can be either soldered
directly to the pads under the PCB or plugged into a 14-pin
DIL socket soldered into the PCB. Then both CON1 and
CON2 can be fitted, noting that each connector is held onto
the PCB via a pair of lugs which are soldered to the copper underneath in addition to the actual connection pins.
The final components to be added are LED1 and LED2,
which are mounted vertically above the PCB with their
leads left at almost full length, so the underside of each
LED body is about 16mm above the top surface of the PCB.
Make sure you fit the green LED in the correct position
for LED1 and the red LED in the LED2 position, and also
make sure that they are both orientated with their longer
anode lead to the right (towards CON2) as shown in Fig.2.
It’s housed in a small jiffy box, small enough to fit in the
palm of your hand. There’s no battery as it is powered from
the USB port that it’s connected to.
mounted on the top of a small double-sided PCB coded
07103141 and measuring 76 x 46mm. This has USB connector CON1 at one end and serial connector CON2 at the other.
The complete PCB assembly fits snugly into a UB5 jiffy
box. It is used upside-down: the PCB is attached to the ‘lid’
of the box (which becomes the base), using four 15mm long
M3 machine screws with four 6mm long untapped spacers
and four M3 nuts to hold the PCB in place. The two activity
LEDs protrude through matching 3mm holes in the ‘base’
of the box, which becomes its top.
There is only one SMD component in the project (IC1),
which comes in a 20-pin SOIC package. I suggest that you
solder this to the top of the PCB before any of the other
components, as this makes it easier.
You can hold it in position using a pair of spring-loaded,
self closing tweezers or similar while you spot-solder diagonally separated pins (like pins 1 and 11, or 10 and 20) to
their pads on the PCB. Then the tweezers can be removed
to give you clear access while you solder the rest of the
pins on each side.
If you do create an accidental solder bridge between
adjacent pins, it’s usually easy to remove the bridge using
107103141
4130170
USB/SERIAL
LA
IRES/BSU
EINTERFACE
CAFRETNI
4CTx
102014
2 C 100nF
LED2
470nF
4
IC1
58 Silicon Chip
3
2
470
15pF
100nF
X1
+
12MHz
TANT
33pF
10F
IC2 74HC14
1
1
10k
5
4
MCP2200
1
4148
A
A
LED1
Rx
1k
4148
TYPE B
2
470
USB
3
20
CON1
1
CON2
9
8
7
6
DE-9M
Box drilling
Your PCB assembly should now be complete, ready for
mounting to the box lid. But first you’ll need to prepare
both the box and its lid, by drilling and cutting the various
holes shown in Fig.3.
There are eight holes in all - four in the lid for mounting
the PCB, two in the ‘base’ of the box for the two activity
LEDs, and a rectangular hole at each end for access to connectors CON1 and CON2.
Assembly
After you have drilled and cut all of the holes and finally
removed any burrs, you should be ready to mount the PCB
assembly inside the lid. This involves passing the four
15mm long M3 screws up through the holes in the lid,
and fitting each one with an untapped 6mm long spacer.
The PCB assembly can then be lowered into position
with the ends of the screws passing through the matching
holes near each corner of the PCB. Then four shake-proof
washers and M3 nuts can be fitted to the screws to hold
the PCB in position.
If you’d like to give your Interface a ‘front panel’ like
the one you can see in our photographs (mainly to identify
LED1 and LED2), we have prepared the artwork which
can be downloaded from siliconchip.com.au. This can be
printed and then laminated in a plastic sleeve for protection
Fig.2 (left):
the component overlay,
with a
matching
same-size
photograph
at right.
1k
4148
4148
siliconchip.com.au
and finally cut to shape and attached to the outer surface
of the base of the box (which becomes the top) using thin
double-sided cellulose tape.
The box can then be up-ended and lowered down over
the PCB-and-lid assembly, orientated so that the end with
the longer rectangular cut-out is at the CON2 end of the
PCB. Make sure that the two LEDs pass up and just protrude
through their matching holes. Then the four small selftapping screws supplied with the UB5 box can be used to
fasten the box and lid together, to complete the assembly.
You may also want to attach four small adhesive rubber
or plastic feet to the lid/underside of the Interface, to ensure
that the screw heads don’t scratch any surface it’s placed on.
Parts List –
USB/RS232C Interface
1 UB5 jiffy box, 83 x 54 x 31mm
1 PCB code 07103141, 76 x 46mm
1 12.00MHz crystal, HL-49U/US (X1)
1 USB type B connector, PC-mounting (CON1)
1 DE-9 male connector, PC-mounting (CON2)
4 15mm long M3 machine screws, pan head
4 6mm long untapped spacers
4 M3 nuts with shake-proof washers
4 adhesive rubber or plastic feet (optional)
Configuring the MCP2200
Semiconductors
1 MCP2200-I/SO USB 2.0 to UART protocol converter (IC1)
1 74HC14 hex Schmitt trigger inverter (IC2)
4 1N4148 100mA diodes (D1-D4)
1 3mm green LED (LED1)
1 3mm red LED (LED2)
While there are no adjustments to be made to the Interface
before it can be used, the MCP2200 USB-serial protocol
converter chip (IC1) does need to be configured to suit your
particular application.
As mentioned earlier, this is done by connecting the
Interface to one of the USB ports on your PC and then running Microchip’s freeware Configuration Utility.
When you first connect the Interface to a USB port on
your PC (assumed to be running), Windows will respond
by installing its standard ‘virtual COM port’ driver. You can
then call up Device Manager (usually via Control Panel)
and look under ‘Printers and Devices’ to make sure that
you now have a ‘USB serial port’. Otherwise you may need
to download and install the Microchip Serial Port Driver
from the link mentioned below.
Check its Properties to learn which COM port number
(LH END OF BOX)
Resistors (0.25W 1%)
1 10k
(brown black orange brown or brown black black red brown)
2 1k
(brown black red brown or brown black black brown brown)
2 470
(yellow violet brown brown or yellow violet black black brown)
(RH END OF BOX)
(UNDERSIDE OF BOX)
8
B
8.25
15.5
CL
15.5
B
CL
8.25
A
13
Capacitors
1 10F 16V tantalum electrolytic
1 470nF 50V multilayer monolithic ceramic (474 or 470n)
2 100nF 50V multilayer monolithic ceramic (104 or 100n)
1 33pF NP0 disc ceramic (33 or 33p)
1 15pF NP0 disc ceramic (15 or 15p)
12
C
6.5
6.5
6
(LID OF BOX)
CL
B
B
siliconchip.com.au
25.75
19
25.75
19
Fig.3: drilling detail for
the UB5 jiffy box. The
rectangular holes at the
box ends (for the RS232
and USB sockets) are
best made by drilling
around the inside of
the area with a small
(eg, 2mm) drill then
enlarging to size with a
small file.
HOLE A: 31 x 13mm
HOLES B: 3mm DIAMETER
HOLE C: 12 x 13mm
B
B
ALL DIMENSIONS IN MILLIMETRES
CL
April 2014 59
Here’s how the
PCB mounts on the lid of the
box, which becomes the base . . .
it has been given, the data format it has set (8 data bits,
no parity and one stop bit are usually best) and also check
whether Windows is advising that it is ‘working properly’.
Set the driver’s baud rate to match that of the instrument/
GPS receiver module/Rubidium oscillator or whatever
you’re going to be using the Interface to communicate with.
This will probably be either 4800 or 9600baud (bps) but
you may need to check in its user manual to make sure.
Assuming this first step has gone smoothly, the next step
is to download and install Microchip’s custom MCP2200
Configuration Utility. This can be downloaded from their
website by typing in this URL: www.microchip.com/
MCP2200. Click on ‘documentation and software’, then
scroll down until you find the MCP2200 Configuration
Utility. It’s a 5.3MB zipped file.
After unzipping, this provides a self-installing version
of the MCP2200 Configuration Utility.
When you run this then fire up the utility itself, you
should see a window like that shown in Fig.4 – although
you won’t see any text as yet in the large ‘Output’ box. This
box will be blank initially, while some of the smaller boxes
may also have different contents.
Before you click on the ‘Configure’ button at bottom
left, you’ll need to ensure that the contents of all of these
smaller boxes are as shown in Fig.4. You probably won’t
need to change the contents of the Manufacturer, Product,
Vendor ID or Product ID boxes, nor will you need to click
on the ‘Update VID/PID’ button.
But you may need to click on the check box next to the
label ‘Enable Tx/Rx LEDs’, to display the tick as shown.
It’s also possible that you may need to click on the check
box next to ‘Enable CTS/RTS pins’, if the serial device
you’re going to be communicating with needs this kind of
handshaking. But this is unlikely with most of the devices
you’ll want to communicate with using the Interface.
If the Baud Rate: text box is not showing the baud rate
you want, click on the down arrow to its right to get the
drop-down list box, and then select ‘4800’ or ‘9600’ or
whatever baud rate you do need from the list. Then if
the I/O Config: text box is showing something other than
‘00000000’, click inside the box so that you can type in the
correct ‘00000000’ text string.
Similarly if the Output Default: text box is not showing ‘11111111’, click inside that box and type in that text
string yourself.
Now turn your attention to the LED Function box at lower
right, and if necessary click on the ‘Blink LEDs’ radio but60 Silicon Chip
ton if this isn’t displaying the ‘selected’ bullet. Similarly
click on the ‘100ms’ radio button so that it too is selected.
At this stage you should be seeing a display very much
like that shown in Fig.4, apart from a blank output window.
If this is so, you can now click on the Configure button at
lower left. There should then be a brief pause while the
Config utility ‘does its thing’ with the MCP2200 chip in
your Interface; then the text shown in Fig.4 should appear
in the Output window to show that the configuration has
been done and your Interface is now communicating with
the PC via the USB cable. You can then close the Config
utility, because your USB-Serial Interface is now configured
and ready for use.
What if you decide at a later time that you want to use
the same Interface to communicate with a different serial
device? That’s not really a problem, because all you’ll need
to do is fire up the MCP2200 Configuration Utility again
and use it to reconfigure the Interface’s MCP2200 to suit
the ‘new’ serial device. You’ll be able to change the baud
rate, disable the CTS/RTS pins if handshaking is not needed
any more, and so on.
A few words about cables
That’s about it as far as the Interface itself is concerned,
but before closing we had better give some basic information regarding RS-232C serial cables and the ways in which
they’re wired. That’s because it’s not easy to buy this type
of cable nowadays, so you may need to wire up one or
more cables yourself.
Another possibility is that you may have one or two older
serial cables, but are not sure how they’re wired. This can
be frustrating if you try using one to connect between the
Interface and a particular device and find they won’t ‘talk
Fig.4: Microchip’s Configuration Utility, which can be
downloaded free of charge (see URL in text).
siliconchip.com.au
3
8
4
9
‘DTE’ END
(PC OR USB
INTERFACE)
5
DCD = DATA CARRIER DETECT
RxD = RECEIVE DATA
TxD = TRANSMIT DATA
DTR = DATA TERMINAL READY
GND = SYSTEM GROUND
DSR = DATA SET READY
RTS = READY TO SEND
CTS = CLEAR TO SEND
RI = RING INDICATOR
RxD
7 RTS
TxD
8 CTS
DTR
9 RI
GND
‘DCE’ END
(INSTRUMENT,
GPS RECEIVER OR
RUBIDIUM OSC)
A ‘STANDARD’ RS-232C SERIAL CABLE WIRING USING 9-PIN CONNECTORS
DE-9F
(FEMALE)
1
DCD
DSR
RxD
RTS
TxD
CTS
DTR
RI
GND
2
3
4
5
DE-9M
(MALE)
1
6
2
7
3
8
4
9
‘DTE’ END
(PC OR USB
INTERFACE)
5
SOFTWARE MAY NEED
THESE PINS LINKED
DCD
6 DSR
RxD
7 RTS
TxD
8 CTS
DTR
9 RI
GND
‘DCE’ END
(INSTRUMENT,
GPS RECEIVER OR
RUBIDIUM OSC)
B ‘BARE MINIMUM’ SERIAL CABLE WIRING USING 9-PIN CONNECTORS
DE-9F
(FEMALE)
(DCD)
DSR
RxD
RTS
TxD
CTS
DTR
(RI)
GND
1
2
3
4
5
DE-9F
(FEMALE)
1
6
2
7
3
8
4
9
‘DTE1’ END
(PC OR USB
INTERFACE)
5
NOTE: TxD & RxD CROSS CONNECTED,
DTR & DSR CROSS CONNECTED,
RTS & CTS CROSS CONNECTED,
DCD & RI NOT USED
(DCD)
6 DSR
RxD
7 RTS
TxD
8 CTS
DTR
9 (RI)
GND
‘DTE2’ END
(PC OR USB
INTERFACE)
C ‘NULL MODEM’ SERIAL CABLE (OR ADAPTOR) USING 9-PIN CONNECTORS
Fig. 5: various types of serial cables which may be
required for the interface
to each other’.
First of all, most serial ports on older PCs used DE-9
nine-pin connectors rather than the DB-25 25-pin connectors originally used to interconnect RS-232C serial devices
like teleprinters and dial-up modems with minicomputers
and mainframes. So you’ll probably only have to concern
yourself with cables fitted with a nine-pin connector at
each end.
The next thing to be aware of is that many ‘RS-232C’ serial
devices didn’t use ‘hardware’ handshaking at all. Instead of
using any of the handshaking lines of the serial ports and
cables, they simply implemented a simple software-driven
handshaking protocol, sometimes called “X-on/X-off”).
As a result these devices may not even need you to use a
nine-conductor cable at all: just a stripped down or ‘bare
minimum’ three-wire cable, with only the RxD and TxD
data lines plus a ground line.
But be warned: even though the device itself may not
need any of the handshaking lines, the software running
in your PC might need to be ‘tricked’ into thinking that
siliconchip.com.au
RS-232C SERIAL
PERIPHERAL
7
DCD
6 DSR
USB / RS-232C
SERIAL
INTERFACE
4
5
2
TxD
3
1
6
RxD
2
the device is ready for action, by linking together some of
the pins at the Interface end of the cable (the RTS and CTS
pins, for example). Otherwise the software may regard the
device as ‘not present’ or ‘busy’.
Right, now take a look at Fig.5, which shows in (a) the
way a standard RS-232C serial cable was wired up using
9-pin connectors. You can make up this kind of cable very
easily using IDC-type DE-9 connectors and a length of
standard IDC ribbon cable, because all of the wires have
a ‘straight through’ connection – pin 1 to pin 1, pin 2 to
pin 2 and so on.
The main thing to remember is that the PC or Interface
end of this cable (the so-called ‘DTE’ end, standing for ‘data
terminal equipment) has a female (DE-9F) connector, while
the other end (the ‘DCE’ or ‘data comms equipment’ end)
is usually fitted with a male (DE-9M) connector.
This type of cable should be fine for connecting the PC
(via the Interface) to many types of ‘legacy’ serial device.
But just so you’ll be aware of the options, take a look at
Fig.5(b). This shows the wiring of a ‘bare minimum’ threewire cable, which only provides the RxD and TXD data lines
plus the ground line. You should be able to use this much
simpler type of cable to communicate reliably with many
of the ‘legacy’ devices using our new USB-serial Interface
– although you may find it necessary to link pins 7 (RTS)
and 8 (CTS) of the connector at the PC/Interface end, to
keep the software ‘happy’. That’s why the diagram shows
the link between these pins in red.
Finally, Fig.5(c) shows the wiring for a so-called ‘null
modem’ serial cable or adaptor. Quite possibly you won’t
need to worry about this type of cable/adaptor, because it
was really only used to allow two PCs to be hooked up to
each other directly via their serial ports, for exchanging
data files etc (although we did need to do this to connect
the old Agilent scope shown in the opening photo).
As you can see, this type of cable/adaptor has a female
DE-9 connector at each end. It also has ‘crossover’ connections linking the RxD and TxD data pins, the DTR and DSR
pins and also the RTS and CTS pins - so the ‘outputs’ at
each end connect to the ‘inputs’ at the other.
A cable wired up this way won’t work if you try to use
it to connect your PC and Interface to a ‘legacy’ device like
a test instrument, a GPS receiver module or a Rubidium
oscillator. You’ll need to either use a different cable or
SC
rewire it to remove the crossover connections.
SILICON
CHIP
1
DCD
DSR
RxD
RTS
TxD
CTS
DTR
RI
GND
DE-9M
(MALE)
USB TO/FROM
PC
DE-9F
(FEMALE)
Fig.6: this front panel artwork (which actually attaches to
the bottom of the box) can also be downloaded from the
SILICON CHIP website (www.siliconchip.com.au).
April 2014 61
|