I Miss My Serial Port

I haven't made much progress on my RC Tank recently. Although I've been doing a lot, that's not the real reason why my progress slowed. My computer was ancient, and it finally froze too often on me and became too frustrating. I upgraded my motherboard and CPU. This helped my sanity more that I ever imagined it would. But there is a problem with many of the new motherboards on the market, mine included. I no longer have a serial port.

To anyone who may not understand the problem, let me explain. When creating a device that connects to a computer, there are too many places where a bug can appear. The serial port of a PC outputs a protocol called RS-232. This lets the developer work as close to the hardware level as possible, meaning there are as few layers as possible for problems to occur. Here's a quick, non-exhaustive example of can go wrong.

Let's say the I create a program to talk to my device. When the user clicks a button, the PC will send "Who are you?" to my device. The device will send "I'm a microcontroller" back to the PC. The PC will then display "Microcontroller connected!" on the screen. I write the software (PC program) and firmware (device program), build the circuit, and connect the device to the PC. When I click the button, nothing is displayed. I'm going to assume that there is nothing wrong with the PC that doesn't involve my program, the circuit is built correctly (a bold assumption), all connectors work, nothing is wrong with the components used in my circuit, and there are no power supply issues.

Communication Problems

As said before, this doesn't include most of the possible problems, including more difficult errors such as buffer overruns. When a serial port is used, the only thing between the PC and the device is a level shifter e.g. MAX-232. This converts the -12V and 12V PC levels to the 5V and 0V UART levels, respectively. This list becomes much, much longer when the serial port's common replacement, USB, is used. USB is almost entirely software driven and is extremely complicated. That green area in the chart becomes huge, involving software libraries and differential drivers on both sides, USB identification and enumeration protocols for handshaking, and a protocol wrapping the application's protocol.

There are two or three options when "upgrading" to USB. Naturally, the differences boil down to money vs. time/knowledge.

Option 1

The first is cheap if you're a hobbyist. Learn the protocol, create your own USB device driver, and write a USB stack for your device. This takes so much time and patience that it'll become the majority of your project. To me a communications "Hello, World!" equivalent shouldn't take longer that building an entire robot. The best book I've seen for this is USB Complete by Jan Axelson.

USB Complete
Seriously, you read over 550 pages and tell me I'm wrong.

To top off the impracticality of this option, this option isn't very useful if you ever plan to sell your product. The USB Implementers Forum, the owners of the USB standard, require you to pay them. You can either use USB for $2,000, use USB and say that you're using USB for $2,000 every two years, or become a full-fledged member for $4,000 per year. This means that this option is pretty much intended for corporations who want to use the speed and capability of writing their own USB software and can use it on multiple projects.

Option 2

This is basically option 1 modified. Depending on the components your project uses, you may get the joys of option 1 without very much trouble. If you are using a PICmicro in your project, Microchip makes USB-capable microcontrollers complete with free license software libraries you can use in your projects. Microchip will even let you use its vendor ID for small production runs on commercial products. This option is still difficult, but much easier than option 1.

Option 3

FTDI UM232R Module

This is the most expensive option, but it's also the easiest. FTDI sells modules that convert between USB and RS-232 or UART complete with free license, easy to use software libraries. The module which I have used in the past is the UM232R that sells for £14.55 ($22.40) at the time of writing this post. For comparison the MAX232A, the industry standard RS-232 to UART converter, is $1.74. That's 92% cheaper. This makes sense considering it is only shifting voltage levels while the UM232R is emulating two completely different protocols.

As an added bonus, however, FTDI has released software that will emulate a serial port on the PC. This means that if you already have a device and software that work, but you have to move to USB, you literally do not have to change anything in your design. Replace your level shifter with this module and install the FTDI software. Your device won't know the difference, and your software can still connect through a virtual serial port.

After reading USB Complete and trying my hand at USB development, I decided to use option 3. My project isn't to build a USB interface; it's to build a robot.