Sie sind auf Seite 1von 7

USB RS232 Level Conversion copyright © 2/25/07 Joe Pardue

Before purchasing the BBUSBRS232 kit or attempting the project, make sure you have
read Breadboard Quick Start Guide, available to download from www.smileymicros.com
THIS PROJECT IS VERY HARD TO WIRE PROPERLY AND GET WORKING
RIGHT – DON’T BUY IT IF YOU HAVE SELF-ESTEEM ISSUES!

Lets create a USB to RS232 converter on a breadboard that functions exactly like a pre-
made USB to RS232 converter cable. So why would you want to go to the trouble of
building one on a breadboard when you can buy one already made for about the same
price? Good question and about all I can say is that this way you learn how that cable
works and get the opportunity to use the extra pins on the BBUSB for other projects. You
also get the opportunity to make a dozen frustrating mistakes and do a lot of debugging,
but that’s part of the fun isn’t it?

The BBUSBRS232 kit contains the following items:

1 BBUSB
2 RS232 converter IC (MAX202 or ST202)
3 Male DB-9 connector solder cup
4 Female DB-9 connector solder cup
5 5 - 0.1µF Capacitors
6 2 - 9” Wire 22 AWG wire
You will need parts that are NOT part of the kit:
• If you don’t purchase the BBUSBRS232+Breadboard you will need a breadboard.
• For testing, you will need a system with a RS232 connection, such as an older
computer or a Smiley Micros Butterfly++ Mini-Kit.
• You will need a USB cable.
• If doing the experiment with an older PC, you’ll need a RS232 cable.

You can do this experiment with any RS232 serial device that only requires the Tx, Rx,
and SG lines, such as an older PC with a RS232 connection or the Smiley Micros
Butterfly++ Mini-Kit.

• This experiment is difficult to wire properly, I had to use a scope to find a stupid
wiring error, so be careful and patient.
• Solder the wires to the DB9 connector
o For this experiment we will only use 3 of the 9 pins: Tx, Rx, and SG.
o Cut 3 3” pieces of 22 AWG wire.
o Strip about 1/8” insulation from one end and about 1/4” from the other.
o Solder the 1/8” end to the solder cups for Tx, Rx, and SG on the DB-9
connector.
o Remember that from the perspective of the PC and the external device the
Tx and Rx are switched. This means that you connect the Tx line from the
PC to the Rx line of the external device and visa versa.

DB9 Connector Wiring

Signal DB-9
DCD 1
Rx 2
Tx 3
DTR 4
SG 5
SR 6
RTS 7
CTS 8
RI 9
Solder Wires to back of male DB9 connectors

• We are using a ST202EBN (or a MAX202EBE or similar compatible IC), which


has two transmitters and two receivers. With this, we can do most common serial
communications including having RTS/CTS handshaking. We cannot use the
remaining modem lines at the RS232 voltages levels since such chips would add a
lot to the cost of the experimenter’s kit and add nothing to the learning.

MAX202 wiring and internal schematic are identical for the ST202EBN and other
compatible RS232 converter ICs.

• Wire up the ST202EBN level converter using the illustration shown on the next
page. The ST202EBN has two TX and two Rx level converters and you can find
the data sheet with the projects zip file.
• Place the BBUSB and the ST202EBN on the breadboard more or less as shown.
• Add the 5 0.1µF Caps as shown. Trim legs to get the caps near the board.
o Cap between +5V and GND.
o Cap between +5V and pin 2.
o Cap between pin 1 and 3.
o Cap between pin 4 and 5.
o Cap between pin 6 and GND.
• Wire ST202EBN pin 7 to pin 8.
• Wire ST202EBN pin 13 to pin 14.
• Wire TxD of BBUSB to pin 11 of theST202EBN.
• Wire RxD of BBUSB to pin 9 of theST202EBN.
• Wire BBUSB for +5V
o Wire USBVCC to VCC
o Wire VCC to breadboard +5V
o Wire VIO to breadboard +5V
o Wire GND to breadboard GND
• Connect the DB9 male connector to the RS232 level converter as shown.
• Connect the DB9 male to the DB9 female to the RS232 cable.
• Wiring this thing up correctly is harder than it appears, isn’t it?

+5V +5V
3V3OUT USBVCC
VCCIO VCC
0.1 uF 0.1 uF

1 16

0.1 uF 2 15
DTR TXD
ST202EBN

3 14
T1OUT RTS RXD
BBUSB

4 13 FTD I CBUS0
0.1 uF R1IN RI
5 12
R1OUT DSR CBUS1
6 11
T1IN DCD CBUS2
7 10
0.1 uF CBUS3
CTS
8 9
GND CBUS4

To DB9 Tx pin
To DB9 Rx pin
To DB9 GND pin

Test with Simple Term


Simple Term is a simple terminal (duh) written in C# and runs on .NET.
• Open Simple Term and click on the Settings Menu Item.
• Choose the first COM port. The illustration shows COM10, but yours will
probably be different. Un check ‘Send with CR+LF’ and click Okay.
• Open a second instance of Simple Term and follow the above steps, selecting the
second COM port. Again, this shows COM4, but yours probably won’t/

• Type a message in the send box of one terminal and watch it appear in the receive
box of the other terminal.
USB Butterfly

The type of DB9 connector, male or female depends on whether the connection end is on
the PC side or the peripheral side. The male is used on the PC side and the female is used
on the peripheral side.

• Remove the female DB9 connector form the breadboard


• Following the instructions earlier, make a male DB9 connection with three wire
legs to go to the breadboard. Pay attention to the TxD and RxD and remember to
ask which is relative to what? It gets confusing.
• Open an instance of Simple Term, but this time leave the CR+LF checked.
• Attach the Butterfly and turn it on with the joystick button pressed to the center.
You will see a series of ?????? on the receive panel indicating that the Butterfly is
sending okay.
• Turn the Butterfly off and back on.
• Click the joystick upward and the ‘AVR BUTTERFLY’ message will scroll.
• Click down until you see name.
• Click to the right twice to see ‘ENTER NAME’ scrolling.
• Click down to see ‘DOWNLOAD’
• Press to the center to see ‘WAITING FOR INPUT’.
• Enter a name, such as ‘RS232’ as shown below and the name should appear on
the Butterfly

Links:
Jan Axelson’s web page (author of USB Complete and Serial Port Complete).
http://www.lvr.com/usb.htm

USB Developers Forum: http://www.usb.org/developers

Stealing USB-port power: http://www.edn.com/article/CA220400.html

General Good Stuff: http://www.smileymicros.com

Coming Soon:

USB Made Almost Easy


by Joe Pardue

Like the name says, this book makes USB almost easy. It uses the FTDI FT232R
USBUART IC and has many instructive and useful hardware and software projects that
will help the user to gain an understanding of one way to communicate between a PC and
a microcontroller. The software is written in both C# and Visual Basic .NET and the