USB-RS232 Interface: A Compact Solution For Missing Ports

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

COMPUTER

USB-RS232 Interface
A compact solution for missing ports
Design by L. Lemmens

Thanks to a special integrated circuit from FTDI Chip, computer


peripherals with an RS232 interface are easily connected to a USB port.
This simple solution is ideal if a peripheral does not have a USB port, your
notebook PC has no free RS232 port available, or none at all!

After a slow and faltering start, the USB port


has become commonplace on PCs, to the
extent that the latest GHz machines have
just one RS232 port left, or none at all. The
compact USB-RS232 interface described in
this article allows your good old RS232
peripherals (printer, programmer system,
etc.) to be hooked up to a USB port. The free
driver programs for Win98/ME/2000/XP,
Linux and Apple Macintosh make the inter-
face virtually transparent, enabling the USB
port to behave like a regular COM interface.
The driver and the conversion chip from
Glasgow-based FTDI Chip allow a full serial
data link to be set up on a 9-way RS232 con-
nector, including all handshaking signals.
The UK representative for FTDI Chip is Alpha
Micro Components Ltd. in Basingstoke
(www.alphamicro.net). International distrib-
utors for FTDI Chip products may be found register), which is controlled by the ingly they contain the same drivers
on the ‘Sales Network’ page which may be computer by way of a virtual COM in the relevant section. At the input
accessed via www.ftdichip.com. FTDI Chip port. The difference between these side, an USB Transceiver forms the
has representatives in most parts of the two components is that the link with the USB cable and its two
world and hosts a very useful website. FT232AM contains a UART which in signal wires called D+ and D– for
turn comprises an RS232 interface the USB 1.1 Full-Speed mode. The
(using TTL levels). The FT245AM, on 3.3-V reference voltage needed for
Function and architecture the other hand, features a 8-bit inter- the USB Transceiver is supplied by
Although it is not necessary to know all the face with handshake lines that allow an internal low-drop voltage regula-
ins and outs of the converter chip if you just direct access to the on-chip FIFO. tor whose output is available at pin
want to use the circuit we’re about to This makes the ’245 IC particularly 6 of the chip. This is done not only to
describe, it is still useful to have an idea of interesting if an existing microcon- enable the reference voltage to be
what is going on inside the black box. troller system is to be upgraded with applied to an external decoupling
The simplified block diagram of the a serial interface. Note, however, capacitor but also to allow the USB
FT232AM is shown in Figure 1 and the pin that you will need to provide the Full-Speed mode to be defined. With
assignment, in Figure 2. Like its family mem- necessary software ‘glue’ yourself! reference to the circuit diagram
ber the FT245AM, the FTDI Chip FT232AM is At the side of the USB, the two shown in Figure 3, that is achieved
essentially a serial USB FIFO (first in, first out chips are identical and not surpris- using resistor R6 which pulls the D+

60 Elektor Electronics 4/2003


COMPUTER
VCC
48MHz Baud Rate
Generator

3.3 Volt
3V3OUT Dual Port TX
LDO
Buffer
Regulator
128 bytes TXD
RXD
RTS#
CTS#
DTR#
DSR#
USBDP DCD#
Serial Interface RI#
USB USB UART UART
Engine
Transceiver Protocol Engine FIFO Controller
USBDM ( SIE )
TXDEN
USBEN

TXLED#
RXLED#

Dual Port RX
Buffer
USB DPLL
384 Bytes

EECS
EEPROM EESK
Interface EEDATA

XTOUT 48MHz GND


6MHZ x8 Clock RESET#
Oscillator Multiplier SLEEP#
XTIN 12MHz TEST
PWRCTL

RCCLK
020375 - 13

Figure 1. Simplified block diagram of the USB/RS232 converter type FT232AM (courtesy FTDI Chip).

line to +3.3 V. This level causes the functional parameters. between 300 bits/s and 2 Mbits/s (actually,
USB Host (i.e., the USB controller in Buffers for ‘receive’ and ‘transmit’ up to 920 kbits/s for RS232 and 2 Mbits/s for
the PC) to recognise our interface as (‘Dual-Port TX Buffer’ with 128 bytes RS422/485).
a Full-Speed device and arrange for capacity and a 384-byte ‘Dual-Port The ‘EEPROM Interface’ on board the
the appropriate addressing. In the RX Buffer’) arrange for the exchange FT232AM chip is intended for the connection
case of a Low-Speed device, the D– of data in both directions (between of an external 93C46 EEPROM chip. Although
line is held at +3.3 V with the aid of Serial Interface Engine and the UART the FT232AM will work happily without the
a resistor. Behind the USB Trans- registers). The block identified as addition of a non-volatile data memory, the
ceiver we find a functional block ‘UART FIFO Controller’ is responsible interface will then ‘report’ as a standard ser-
identified as ‘Serial Interface Engine’ for the exchange process between ial device. The small EEPROM allows specific
which handles the parallel-to-serial the two buffers and the transmit and data like manufacturer and product identifier
and serial-to-parallel conversion of receive registers of the UART.
USB data. Next, the ‘USB Control Functionally, the ‘UART’ proper is
Engine’ processes the USB control not unlike the one found in the PC.
RCCLK

XTOUT
AGND
AVCC
EECS

information and looks after the com- Its task is to supply all relevant sig-
XTIN

VCC
TXD

munication with the USB Host Con- nals to the RS232 interface and in
troller (in accordance with the USB addition, for RS422 and RS485.
Low Level protocol), as well as the The ‘Baud Rate Generator’ allows 32 25

commands that define the UART’s the serial data speed to be set EESK 1 24 RXD

FTDI
EEDATA RTS#
VCC CTS#
RESET# DTR#
FTDI Chip contact details TEST
FT232AM DSR#
3V3OUT DCD#
Future Technology Devices International Ltd., USBDP RI#
St. George’s Studios, 93-97 St George’s Road, Glasgow G3 6JA, United Kingdom. USBDM 8 XXYY 17 GND
Tel.: (+44) (0)141 353 2565, Fax: (+44) (0)141 353 2656. 9 16
URL: www.ftdichip.com

UK distributor:
VCC

TXDEN
GND

RXLED#

PWRCTL
USBEN
TXLED#
SLEEP#

Alpha Micro Components Ltd, Springfield House, Cranes Road, 020375 - 14

Sherbourne St. John, Basingstoke, Hants RG24 9LJ, United Kingdom.


Tel : (+44) (0)1256 851 770, Fax: (+44) (0)1256 851 771.
URL: www.alphamicro.net Figure 2. Pin connections of the FT232AM in
QFP case (7 x 7 mm) (courtesy FTDI Chip).

4/2003 Elektor Electronics 61


COMPUTER
+5V +5V +5V

R3 C6 R9 R11 R10
C1

470Ω

470Ω
10k
100k
8
100n
10n
T1
3 4 AVCC
DI DO
7 IC2 6 RCCLK
PRE PE
2 1
BC857 SK CS C4 C5
93C46
R2 R1 R12
100n 100n

2k2
470k

100k

5
RESET +5V

C13 C14
+5V
100n 10µ
16V
C8
D1 D2
C11
100n
L1
R7 R8 3 13 26 100n
C7 13
1k

1k

2 30 11 V+ 12
EEDATA AVCC C1+ C9
10µ 16V 1 32 24
EESK EECS EN K1
11 31 IC3 14
RXLED RCCLK C1– 100n
12
IC1 19 26 27 DCD 1
TXLED DCD R3OUT R3IN
4 20 5 4 DSR 6
RESET DSR R2OUT R2IN
15 24 22 23 RXD 2
USBEN RXD R4OUT R4IN
R5 16 23 20 1 RTS 7
D+ TXDEN RTS T3IN T3OUT
10Ω 25 7 2 TXD 3
K2 FT232AM TXD T1IN T1OUT
3 7 22 8 9 CTS 8
R4 USBDP CTS R1OUT R1IN
2 D– 8 21 6 3 DTR 4
10Ω USBDM DTR T2IN T2OUT
1 6 18 19 18 RI 9
3V3OUT RI R5OUT R5IN
R6 5 10 21 28 5
C3 TEST SLEEP T4IN T4OUT
1k5

USB-B 4 14 29 15
PWRCTL AGND MAX213 C2+ C10
10n 25
XIN XOUT SHDN SUB-D9
10 16 100n
9 27 28 17 C2–
X1 V-
C2
17
C12
33n 6MHz
100n
020375 - 11

Figure 3. Circuit diagram of the USB/RS232 Interface.

codes (VID, vendor ID; PID, product ID), ser- tor (K2). A sufficient amount of sup- mode while booting. The other R-C
ial numbers, etc., to be permanently stored ply noise decoupling is afforded by a combination, R11-C4, only decouples
and made known to the operating system. small choke (L1) and capacitor (C7). the voltage at the AVCC (analogue
Note that the EEPROM is obligatory when In addition all integrated circuits supply) pin which powers the inter-
several USB/RS232 converters using FTDI have their own supply decoupling. nal 8x clock multiplier.
chips are connected to a PC. This is because As already mentioned, resistor R6 The MAX213 and its external
the drivers will only install virtual COM ports pulls the USB D+ line to +3.3 V, in charge pump capacitors only serve
for converters with unique serial numbers. order to tell the USB host that the to convert the 5-V signals at the
Without the serial number (i.e., without the interface is a ‘Full-Speed’ device. The RS232 side of the FT232AM into true
EEPROM) only one virtual COM port can be same resistor also triggers the recog- RS232 signals (i.e., having a polar-
installed. nition of an USB device when the ized swing). Normally, that would
interface cable is plugged into the mean approximately ±12 V, but in
USB port on the PC or on a hub. practice only ±8 V is achieved, with
Circuit diagram Very conveniently, the FT232AM a maximum of up to ±10 V.
The circuit diagram shown in Figure 3 looks features two LED driver outputs that
rather uncomplicated. In the top left-hand cor- allow active data transmission (D1)
ner we find the power-up reset circuit com- and reception (D2) to be visualised. Circuit board
prising T1 and the customary R-C network. Although the two R-C networks Even if the circuit diagram is unclut-
Right beside it is the (optional) EEPROM. In R11-C4 and R10-C5 are identical in tered and fairly straightforward, that
the next lower ‘row’ we find, from the left to value, their functions are quite dif- does not necessarily apply to the
the right, the USB-B connection, the FT232AM, ferent. The combination R10-C5 at printed circuit board (Figure 4). The
a MAX213 and finally the RS232 header. the RCCLK pin is a timing network main reason for the discrepancy is
The circuit receives its +5 V supply volt- to ensure clock stability when the found in the use of SMD parts. Also,
age from the PC via pin 1 of the USB connec- FT232AM wakes up from Sleep the PCB is double-sided and

62 Elektor Electronics 4/2003


COMPUTER
D2 D1C14
COMPONENTS LIST

K2
C10

C11
Inductors:

C9
All resistors and capacitors C12
L1 = BLM31A601S (Murata) (e.g., C7
SMD shape 1206

R1
IC3

L1
R2
T1

C13
Farnell # 581-094) R3
C1
Resistors: C2
R1,R3,R10 = 100kΩ Semiconductors:

K1
C5
R2 = 470kΩ D1,D2 = LED, 3mm dia. 020375-1 R10
X1
R4,R5 = 10Ω T1 = BC857
R6 = 1kΩ5 IC1 = FT232AM or FT232BM (FTDI
R7,R8 = 1kΩ Chip order code FT8U232AM)
R9 = 10kΩ IC2 = 93C46 (optional)
R11 = 470Ω IC3 = MAX213ECWI
R12 = 2kΩ2

(C) ELEKTOR
020375-1
Miscellaneous:
Capacitors: K1 = 9-way sub-D plug (male), PCB
C1,C3 = 10nF mount, angled pins
C2 = 33nF K2 = USB connector, type B, PCB
C4,C5,C6,C8-C13 = 100nF mount
C7,C14 = 10µF 16V radial X1 = 6MHz ceramic resonator
C4 R11

R9
R12

C6
IC1

IC2

(C) ELEKTOR
020375-1
R6
R5

C8
R4
C3

R8
R7

Figure 5. Our finished and fully working prototype board seen from above… Figure 4. Copper track layout and component
overlay of the PCB designed for the interface.

through-plated, and has components fitted at


both sides! Those of you who have experi-
ence in dealing with SMDs will not be
deterred by the extremely compact board lay-
out. Fortunately, for those with less know-
how in this area, Elektor Electronics recently
published a number of useful articles on the
subject of SMD soldering (see ‘References’ at
the end of this article). Beginners are advised
to prepare themselves by first reading the
articles and then acquire practical experience
from some (defective) boards and SMD parts
to prevent disappointment with the present
project.
The bare board is first populated with the
SMDs and then with the ‘leaded’ components
and sockets. One of the sockets is a USB Type
Figure 6. … and from below. ‘B’, for which the pinout is shown in Figure

4/2003 Elektor Electronics 63


COMPUTER
7. The other variant of the socket, called USB 2 3 4 1 = +5V
1
‘A’, is always at the PC or hub side, while type USB-A 2 = D-
3 = D+
‘B’ should always be inside the equipment 4 = GND

reporting to the PC. Via the USB cable, the 1


2
type ‘A’ socket supplies current to the ‘B’ 3
socket at the equipment side. In our case, this 4

current is used to power the USB-RS232 con-


verter board. USB cables always contain 1-to-
1 wire connections. 3 2 4
USB-B 1 = +5V
2 = D-
3 = D+
Ready-made modules 4 = GND

3 2
Those of you who dislike DIY constructing on
PC boards, and SMDs in particular, will be 4 1
glad to know that FTDI chip also supply
ready-made USB-RS232 interface modules
020375 - 12
under part number DLP-USB232M, see their
website for further details. These modules
have all connections brought out to pins of a Figure 7. USB-A and USB-B socket pinouts.
standard 0.6-inch wide DIP plug.

Once finished, you will have a new Figure 8a.


Software serial port on your system, just check During the installation, two dri-
Before connecting your circuit to the PC’s USB it using Start → Settings → Control vers are actually installed that are
port, give your soldering work a last, thor- Panel → System → Device Manager. linked with one another. One of
ough, visual inspection, for which a magnify- If you open the ‘Ports (COM & LPT)’ these provides the virtual COM port
ing glass will prove very useful. folder you should see a new ‘USB you just found as the new device in
Next, download the necessary drivers from Serial Port (COMx)’ as illustrated in the Device Manager. The other driver
the FTDI Chip website. Drivers are available
for all popular Windows versions, as well as
for the Macintosh and Linux platforms.
Regarding the Windows drivers, versions are
available with and without PNP (Plug & Play) Installation
support. The latter are called ‘non-PNP’. The As is well known, USB devices may be ‘hot plugged’ to the PC. The operating
difference is small but essential. The drivers system will recognise the interface and request the associated driver. This may be
with PNP support should only be used when downloaded from the Drivers and Utilities page on the FTDI Chip website. The
the peripheral connected to the PC via the so-called Virtual COM Port (VCP) drivers arrange for the interface to behave like
USB/RS232 interface also installed its drivers an ordinary serial port. There are drivers for Windows, MacOS and Linux. Here,
using Windows PNP. In other words, in case we will assume the Windows drivers are used.
of doubt, resort to the non-PNP drivers first to
prevent problems. Typical problems you may Having installed the driver, the simulated COM port may be addressed by applica-
encounter with the PNP supporting drivers tions just like any regular serial port on the system. Higher programming lan-
include slow booting and erroneous identifi- guages like Delphi and C++ allow ‘components’ like Tcomport to be employed
cation of an USB/RS232 converter as a for the communication with the serial interface. If you do your own programming
‘pointer device’ which will result in failure of anyway, we’d recommend using the ‘D2XX ‘Direct’ Drivers’ for Windows
the mouse to operate as expected! For Win- instead of the VCP ones. A Direct Driver must be employed to be able to pro-
dows XP, there’s an additional XPNPNP tool gram the external EEPROM!
that allows the Plug & Play function to be
switched off for serial FTDI interfaces. The Windows VCP drivers copied form the FTDI website come in two flavours:
With the right driver securely stored in a with and without PNP. This has nothing to do with the interface proper (which is
subdirectory , you may start the installation always recognised automatically by Windows). But only concerns the hardware
process by connecting the USB/RS232 inter- connected to the interface (see the subheading ‘Software’).
The VCP driver download comes as a zip file containing drivers for Windows98,
face to a USB port on the PC. After a short
ME, 2000 and XP. The zip archive file is unpacked on the hard disk. The FTDI
delay, Windows will report that a USB device
Chip website supplies extensive documentation, all the latest on the software and
has been found. If there is no reference to a
the installation process.
USB device, then there is a problem on our lit-
tle board. In some cases, all you have to do is
Windows will automatically launch its New Hardware Wizard when the interface
unplug the USB connector, wait a few seconds is connected to the USB port on the PC. Next it will prompt you to point to the
and insert it again, so try this first. When location where the drivers may be found. Browse and navigate to the folder con-
everything goes well, all you have to do is taining the unpacked files. After a short delay, the Wizard will find FTDIBUS.INF
browse the system and click on FTDIBUS.INF and install the drivers and associated software for the interface.
to make the rest of the installation proceed.

64 Elektor Electronics 4/2003


COMPUTER
ensures that the USB side of the FT232AM
appears as a USB device in the sub-folder
‘Universal Serial Bus Controllers’ (see Figure
8b).
Figure 9 shows the programming win-
dow of the tool available for programming the
EEPROM connected to the FT232AM. This lit-
tle tool may also be downloaded from the
FTDI website. OEMs (original equipment
manufacturers) may want to use this tool to
program their own VID or PID. If you do not
a have a VID or PID, you may either omit them
or omit the entire EEPROM. Yet another pos-
sibility is to simply resort to the PIDs and
VIDs reserved by FTDI Chip. For the
FT232AM, VID = 0403 and PID = 6001. A
more extensive description of the actual uses
b of this option may be found in the program-
ming instructions supplied by FTDI in the
form of yet another free download.
Finally, we should mention that there are,
of course, limits to the performance of a con-
verter acting as a simulated RS232 port. Con-
trol of the data flow is essential to ensure
trouble-free conversion between RS232 and
USB, in order to prevent overruns occurring
on the two buffers inside the FT232AM (128
and 384 bytes). Such situations would cause
bytes to be lost in the conversion process and
Figure 8. After the installation you should find a new ‘USB Serial COM Port’ under are most likely to occur at high data speeds
‘Ports’ in the Device Manager (8a) and a new ‘USB High Speed Serial Converter’ when no handshaking is used.
under ‘Universal Serial Bus Controller’ (8b). (020375-1)

Note: since writing this article we have been advised by FTDI Chip that the FT232AM chip
has been superseded by the FT232BM.
Literature:
– USB Driver Programming, Elektor Electronics
October and November 2002.
– USB UART, Elektor Electronics December 2001
and January 2002.
– USB Interface, Elektor Electronics September
2000.
– SMD’s? Don’t Panic!, Elektor Electronics January
and February 2003.

Free Downloads
– PCB layout (pdf file), on
www.elektor-electronics.co.uk/dl/dl.htm.
Select file number 020375-11.zip, month
of publication.
– FT232AM datasheets, drivers, info on
ready-made modules, etc.,
Figure 9. Utility program for (optional) programming of PID and VID information www.ftdichip.com
into the 93C46 EEPROM.

4/2003 Elektor Electronics 65

You might also like