Making the Leap from RS232 to USB Output
Some considerations before deciding to switch ports
Thomas Lutz
RS232 serial ports have been around since the very first PCs as a way for software to communicate with external devices. Because of this, instrument makers have been producing hardware that communicates over RS232 ports since the beginning of computer history. The RS232 standard has a few small idiosyncrasies. However, in general, it is still extremely simple and very well supported by thousands of commercial software packages.
Problems with RS232
One small inconvenience with RS232 ports is that none of the pins on an RS232 serial port can provide any useable power. A larger problem is that the RS232 protocol supports a number of different configuration parameters including “baud rate,” “parity,” “data bits,” “stop bits” and “flow control” — all of which can be confusing to someone trying to configure a system to communicate with an RS232 device. Finally, many new PCs are now shipping without any RS232 COM ports and, instead, are equipped with one or more USB ports.
To get around the power problem, most devices have their own power supply — usually an AC adapter. The communications parameters (baud rate, etc.) are usually configurable on most instruments, and the users manual for most devices includes a section that describes the default settings, as well as instructions on how to change the parameters in the device.
The problem of PCs not shipping with RS232 serial ports also is easily solvable by purchasing add-on RS232 serial adapters that plug into a USB port. There are hundreds of “USB to RS232” converters now available, selling for as little as $20. A typical USB to RS232 converter is a small cable with a USB connector on one end and a RS232 serial connector on the other. The converter comes with a device driver that must be installed in the PC. However, once the device driver is installed, your PC works just like it has a standard RS232 serial port built in on the motherboard so all your existing serial communications software works without any problems.
Problems with USB
USB stands for “universal serial bus” which sounds similar to “RS232 serial ports.” However, it is a completely new standard that is not at all compatible with RS232 serial devices. USB was primarily designed not as a generic interface like the RS232 port, but more as a simple plug-and-play interface for devices like keyboards, mice, printers, scanners, cameras, hard drives and other typical PC peripheral devices.
Windows provides built-in functions that make it fairly easy for any programmer to develop software to communicate with an RS232 serial device, and there are also plenty of readily available developer tools that make the job even easier. All the programmer needs to do is “open” the serial port, set the correct “communications parameters” and send or receive data exactly the same way they would read or write data to a disk file.
With USB, this is impossible. One of the design criteria for USB is to make it plug-and-play so that, as soon as you connect a USB device to a PC, the operating system will recognize that the device is plugged in and automatically install a device driver for the device. This means that the manufacturer of most USB devices must develop the device driver software and provide that driver with the instrument. Fortunately, for most simple devices like keyboards, mice and mass storage devices, Windows provides built-in drivers.
Another design criteria of USB is that the USB port should be able to provide power to a device (up to a limit).
What to do?
Suppose that you are a manufacturer of an instrument that currently has an RS232 interface and you are wondering whether you should switch to a USB interface instead. Your first choice is to do nothing and to stick with the RS232 interface for your devices. If your customers complain that their PCs do not have an RS232 port and only have a USB port, you can simply tell them to get a RS232 to USB converter.
If you decide to make the switch to USB, you then have to decide what to do about developing the hardware and the software driver for your device. The hardware part is easy. There are plenty of companies that specialize in USB chipsets that will make this part of the job fairly simple. The hard part is deciding how your device driver software should work.
You could write a custom device driver for your device, and then either provide a custom application program to communicate with the device or provide software development tools that would give other programmers the ability to communicate with your device driver. The problem with this solution is that you would be limiting your device to working only with software that you provide or requiring that your customers write their own software to communicate with your device.
One extremely elegant solution is to develop the device driver so that, when you plug your device into the USB port, it appears to the PC as a standard RS232 port. A huge benefit to this approach is that it will allow all existing serial communications software to communicate with the device exactly as it did before you changed from RS232 to USB. You can even develop the driver so that it makes no difference what serial communication parameters are selected in any software that communicates with the device. In addition, you can design the device so that it gets its power from the USB port, eliminating the need to include a power supply or AC adapter with your device. There are even companies that specialize in providing chipsets and device drivers that use this approach so that all you need to do is add a single chip to your instrument hardware design. In reality, with this approach, you are building a RS232 to USB converter directly into your device and distributing the USB to RS232 device drivers that come with the converter.
Another possible solution is to design the USB interface on the device so that it identifies itself to a PC as a “keyboard device” which would cause Windows to load its built-in USB keyboard device driver. Using this approach, you do not need to develop any drivers at all. Your device will behave as if it were a second keyboard when connected to a PC. If your device is something simple like a bar code scanner, electronic scale, simple measuring tool or other gadget that normally only outputs small bursts of text or numeric data, this can greatly simplify the process of inputting data from your device into other PC software packages. All your users would need to do is plug the device into the USB port, put the cursor in a data input field in any program and then, perhaps, press a button on your device to transmit the data. The data would appear as if it were coming in on the keyboard.
If your device generates a large amount of data that would not be easily entered as “keystrokes,” you could also design your USB interface so that it identified itself as a mass storage device (i.e. a disk drive) and then store all data output in “disk files” in the mass storage. In other words, when your device gets plugged into a USB port, Windows would think that it had another disk drive attached. Your device would create files that anyone could read, copy or delete using the Windows explorer.
The following companies produce USB — RS232 chipsets that come complete with virtual RS232 port device drivers:
•FTDI Chip: www.ftdichip.com
•Texas Instruments: focus.ti.com/docs/prod/folders/print/tusb3410.html
Companies that supply RS232 to USB converters:
•Sewell: www.sewelldev.com/usbtoserial.asp
•IO Gear: www.iogear.com/products/product.php?Item=GUC232A
•Keyspan: www.keyspan.com/products/usb/USA19W/
Thomas Lutz is President of TAL Technologies, Inc. He may be reached at sceditor@scimag.com.