Serial Port

Way back when... There was the serial port

Serial port, COM port, RS-232, it all gets lumped together. This technology is old, old, old. It has its roots way back, back before the beginning of time. (Technical writers like to mention Morse code as a very early, bit serial communication protocol, but I would never do that!) You probably have two serial ports on the back of your PC, and chances are nothing's connected to either one. The serial mouse seems a thing of the past and modems, if not internal, now generally use USB. With the growth of USB and Ethernet, the serial port would seems to be obsolete, a legacy connection on its way out. However that doesn't seem to have stopped the development of new products using RS-232. Just a few months ago (when I first wrote this, it was a "few months") I wrote some test code to talk to a new product from Symbol, a key-chain-size bar code scanner. It has a little serial connector on the back end, and we talked with it just fine over COM1. The fact is, RS-232 is a well understood, robust serial communication technology that nicely fills a low to moderate performance niche.

The serial port -- Easy I/O

The serial port is an easily accessible interface technology that may offer you flexibility you can't conveniently get elsewhere.; (For instance, driving a simulated artificial horizon incorporating stepping motors.) As mentioned above, the hardware's probably already on your PC, and the drivers are part of windows.; Coding in MSVC++ is simply a matter of doing an createfile() on "COM1". (Okay, maybe I'm stretching it a bit by saying "simple", but it's not a huge task.)

Serial port + Micro controllers = Good match

A very low cost way of handling the other end is to use a programmable microcontroller like a PIC from Microchip. You can develop code for PICs in a high level language like C, though you'll have to buy the compiler. If you're comfortable with assembly, you can download an IDE with one for free from Microchip.

You can gain an introduction to PICmicros by visiting a few sites that offer free information. Nigel Goodwin, in particular, has done a bang up job of pulling together PIC tutorials with accompanying hardware exercises, as well as the requisite programming software and hardware for loading your code into one of the little beasties.;All of the great and gory details of the entire PICmicro line are, of course, available on line from the Microchip site.

If you're going to put forth the effort to learn PIC programming, you probably will want to use it in more than one or two places. Serial connections are usually point to point affairs, and given that you likely only have two serial ports, this may seem to be a rather serious limitation. There is nothing that prevents you from adding your own custom protocol layer that implements a shared bus approach. Drive the serial data out from your PICs with open collector gates. Your PC's serial port would not need to be modified as it would be the only data transmitter connected to all the paralleled PIC data input ports. Define your data packets with a device address in the header. Each PIC receives all packets, but only acts on its own.

Or, as an alternative to bussing, daisy chain your devices.


FSBUS is an entire flight sim I/O system that makes use of the serial port. It includes software and hardware components that can be used to interface switches, 7-segment displays, servo based instruments and potentiometers. It was designed by Dirk Anderseck who continues to expand and improve it. The design documentation is available through the FSBUS website as free downloads. The site is in both German and English. Additional English language documentation is available here.

A few resources

If you are even moderately interested in using a serial interface you should; pick up a copy of Programming and Customizing PICmicro Microcontrollers, 2nd edition, by Myke Predko. Get through it and you can call yourself a resident expert. Predko covers PICmicros in detail and does a pretty good job with serial communication as well. Further info can be had from Jan Axelson's book, Serial port Complete.  There are also some pretty informative articles on-line at Beyond Logic.

The above references will get you up and running in terms of the hardware and an old style (i.e. DOS) software approach. To access the serial port under Windows without jeopardizing system stability, one should make an effort to use proper Windows APIs rather than trying to touch the hardware registers directly. A tutorial on doing so is available on the Microsoft MSDN site.; It's called "Serial Communications in Win32 You'll find it in the technical article section just after the base windows services in the platform SDK. Win32 communication APIs are also covered in the book Win32 System Services by Marshall Brain and Ron Reeves. The book has a lot of sample code in C.