Download as pdf or txt
Download as pdf or txt
You are on page 1of 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 DONT BUY IT IF YOU HAVE SELF-ESTEEM ISSUES! Lets create a USB to RS232 converter on a breadboard that functions exactly like a premade 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 thats part of the fun isnt it? The BBUSBRS232 kit contains the following items:

1 2 3 4 5 6

BBUSB RS232 converter IC (MAX202 or ST202) Male DB-9 connector solder cup Female DB-9 connector solder cup 5 - 0.1F Capacitors 2 - 9 Wire 22 AWG wire

You will need parts that are NOT part of the kit: If you dont 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, youll 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 DCD Rx Tx DTR SG SR RTS CTS RI

DB-9 1 2 3 4 5 6 7 8 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 experimenters 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.1F 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, isnt it?
+5V 3V3OUT VCCIO 0.1 uF
1 16 15

+5V USBVCC VCC

0.1 uF

0.1 uF

DTR
14 13 12 11 10 9

TXD
FTD I

ST202EBN

3 4

T1OUT R1IN R1OUT T1IN

RTS

0.1 uF

RI DSR DCD CTS GND

RXD CBUS0 CBUS1 CBUS2 CBUS3 CBUS4

BBUSB

5 6

0.1 uF

7 8

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 wont/

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 Axelsons 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

You might also like