Observations about the universe, life, Lausanne and me

Wednesday, February 25, 2009

A day in the lab: RS 232

Yes RS 232, the humble COM-port. You don't see it on modern computers anymore, USB has superceded it thank god. In the labs though, it is quite another story. Oscilloscopes, flow controllers, mass spectrometers, you name it, if it has been built in the last twenty years or so, and can be controlled by a PC, it will have a COM-port. Maybe a GPIB too, but you can count on the COM-port. And you don't throw perfectly good equipment out just because the standards have changed, not when an oscilloscope will cost you about twenty thousand Euro. Indeed, at the Vienna University of Technology they have an X-Ray flourescence spectrometer that is still faithfully controlled by a PDP-11 (or 12, not too sure)!

Also, RS 232 data transfer is real easy to understand and program, without difficult handshake rituals to go through. But sometimes you can still hit snags, like I did on Monday, when I wanted my student to start writing a program to controll our MKS Pressure controller. No luck, it just wouldn't answer. I checked syntax, the ports on both sides, the cable etc. all working, but no answer from the MKS. The next day I finally found the reason: MKS Instruments are a bunch of greedy bastards.

 The culprit.

You see, in the RS 232 standard, two machines communicate with each other: The DTE (Data Terminal Equipment , normally the PC) and the peripheral device, called DCE (Data Communications Equipment, because originally it was mainly used for modems). The DE-9 connector (your typical COM-port) has nine pins, but in the simplest communication only three are used: pin 5 for ground, pin three for transmitted data (TxD) and pin two for received data (RxD). The other pins can be used for handshake protocols and to speed up data transfer, but since we are transmitting only a couple of characters (close valve, etc.) we don't need to bother with those.

Now who is transmitting and who is receiving? Both of course, because I can ask the pressure controller to report the current pressure to me. But in the standard  it is specified that the DTE (PC) will transmit on pin three and receive on two, and the DCE will do it the other way round.

Now MKS Instruments (and they are in no way alone in this) thought: "Hey, we could make loads of money if we specify our controller as a DTE, so people will have to buy our "special" cable to use it with a PC! I bet nobody will figure that one out, and to make sure, let's hide this in a small footnote in the user's manual."

The cable you have to use to let two DTE's communicate with each other is no overprized "special" cable at all, it is called a crossed or Null-modem cable, older readers may remember it from way back when you would use it to let two PCs talk to each other. If you don't have one, you can make the cross by yourself with a solder iron and two sub-DE 9 connectors. So once I was getting desperate and sat down comparing the pinout in the Manual with the RS 232 specification, it took me about a minute to recognise the problem, and five minutes to solder up the solution:


And hey presto! it works. Take this, MKS! Take it with the day I wasted, and the bitterness of the tears my poor inconsolable student wept when he could not get his program to work.

3 comments:

  1. I hate organizations that make things needlessly difficult. In my 20 years working at NASA, I've run into quite a bit of RS-232 stuff and that very problem multiple times. Easy to fix, but what a pain.

    ReplyDelete
  2. Yes, RS-232 is a dying art. At least the device didn't have a DB-25 connector :)

    ReplyDelete
  3. People not adhering to standards are always such a pain in the ass. That's why I am so happy that the EU is pushing the cell-phone industry to use micro-usb connectors for charging.

    @Robert: We have quite a few of those lying around too, rest assured. I also could have interfaced directly via some digital I/O pins, but I wanted to keep things simple for my student. After all, he wants to do a bit of research, not electrical engineering and programming.

    ReplyDelete