RS-232 Confusion, And How To Escape!!

by R. Steve Walz  rstevew@armory.com
---------------------------------------

Each time someone new to RS-232 asks me what is wrong I wind up saying:

"Oh my. That's the terribly confusing way of thinking about it. DON'T!"

Don't let this stuff confuse you, because it's easy to do if you let it. 

DTE and DCE are ONLY opposite pin rearrangements of the various line
pairs so that a straight-through or ribbon cable can be used from what
is called a DTE port pinout to what is called a DCE port pinout.

BUT!!!
ALWAYS remember and represent the RS-232 lines to yourself as DTE,
because you ONLY HAVE TO REMEMBER ONE OF THESE TWO (DTE versus DCE)
because the other follows by symmetry!!

NOW REMEMBER!!
You only need to remember the DTE pins, labels and functions, since
the DCE is merely a re-labeling of them according to the pairs by
calling all outputs as inputs of the same name on DCE and vice versa. 

SO ATTENTION!: The output/input sense from DTE to DCE is reversed:

So that all DTE outputs go to their coordinate input of the 
SAME NAME on the DCE end.

AND!!

So that all DCE outputs go to their coordinate input of the 
SAME NAME on the DTE end.

LEARN THE FOLLOWING!:

DTE-wise: Tx is always an output and Rx is always its input.
  These are the Transmit Out and Receive In.
  Quiescent these lines are -12V, and the data begins after the start 
  bit (+12V) and all databits result from leaving the line at -12V 
  (logic 1 or HI) or pulling it to +12V (logic 0 or LO).


The Handshake lines are OFF when they are -12V and ON or asserted at +12V!
--
DTE-wise: RTS is always an output and CTS is always its input.

DTE-wise: DTR is always an output and DSR is always its input.

DTE-wise: DCD (data carrier detect) and RI (ring indicator) are 
  always inputs to the computer FROM these modem outputs OF THE 
  SAME NAME.
--

The DCE port pinout and labeling uses the SAME pins for the SAME 
labeled signals, but it REVERSES the sense, making each output into 
an input and each input into an output. 

THAT'S ALL DCE is about!: That all DTE outputs become DCE inputs of
the same label, and all DTE inputs become DCE outputs of the same 
label!

So:
        Straight-Through Cable   DTE (PC COMx) to  DCE(Modem)

DE-9P pinout  DTE-Labeling  Signal Flow  DCE-Labeling  DE-9S
---------------------------------------------------------------
   1           DCD  input <----------- output  DCD         1
   2           Rx   input <----------- output  Rx          2
   3           Tx   output -----------> input  Tx          3
   4           DSR  input <----------- output  DSR         4
   5           Gnd  ---------common----------  Gnd         5
   6           DTR  output -----------> input  DTR         6
   7           RTS  output -----------> input  RTS         7
   8           CTS  input  <----------- output CTS         8
   9           RI   input  <----------- output  RI         9
----------------------------------------------------------------

This cable works fine for modems. And that's about all!!

The TRUE problem with RS-232 NEVER involves modems!!!

--

Here's where you learn what you REALLY NEED!:

     Cross-Over Cable   DTE (PC COMx) to  DTE (Second Device)

DE-9P pinout  DTE-Labeling  Signal Flow  DTE-Labeling  DE-9P
---------------------------------------------------------------
   1           DCD  input <-----
   2           Rx   input <----------- output  Tx          3
   3           Tx   output -----------> input  Rx          2
   4           DSR  input <----------- output  DTR         6
   5           Gnd  ---------common----------  Gnd         5
   6           DTR  output -----------> input  DSR         4
   7           RTS  output -----------> input  CTS         8
   8           CTS  input  <----------- output RTS         7
   9           RI   input  <-----
----------------------------------------------------------------

OR SEE IT BEST THIS WAY:

DE-9P pinout  DTE-Labeling  Signal Flow  DTE-Labeling  DE-9P
---------------------------------------------------------------
   2           Rx   input <-------\/------->  input Rx      2
   3           Tx   output -------/\-------- output Tx      3

   4           DTR  output -------\/-------- output DTR     4
   6           DSR   input <------/\------->  input DSR     6

   7           RTS  output -------\/-------- output RTS     7
   8           CTS  input  <------/\------->  input CTS     8

   1           DCD  input <----        ---->  input DCD     1
   9           RI   input <----        ---->  input RI      9

   5           GND  ------------common------------- GND     5
----------------------------------------------------------------

This shows the pairs: Tx/Rx, RTS/CTS, and DTR/DSR crossed over,
and the modem signal RI is pulled to inactive (The phone didn't 
ring did it?) and DCD (Do you hear a data carrier? Does it want one?)
pulled to inactive (-12V) or active (+12V) as needed to make the
software respond properly. 

Some computer port drivers want to see DCD asserted, as if pretending
there's a modem carrier even if there is no modem, but some don't care
without higher-level application software telling them to care. The PC
doesn't care.

I use a 1K resistor and a bidirectional Red/Green LED to detect the
state of these lines, in fact I have a break-out box made the same way
with a bunch of these resistor-LEDs to show the state of these all at
once, with the LED anode pointed to make -12V turn on GREEN emission 
and +12V (asserted handshake/data activity) emits RED so I can notice
it. This way the data lines Tx/Rx are green when no data is flowing, 
and the handshake are red when good!!

I used 4 LEDs, two LEDs on each end for each of the three pairs: 
Tx/Rx, RTS/CTS, and DTR/DSR, and then left another two on each end
for RI and DCD. I use loose jumper wires with pins soldered on the 
board and DB25 Amp gold sockets on the wires to connect the two sides 
so I can make them cross over or go straight through or anything else
with just a rearrangement of the pushed on wires.

Now for simpler devices with no handshake, like a microcontroller 
board with a MAX232 data-only, you simply fool the PC by looping its 
own RTS to CTS and DTR to DSR so that it thinks the other end is
signalling okay. All the two handshake pairs do anyway is signal
"hardware alive" (DTR/DSR) and "okay send" (RTS/CTS) when asserted
(+12V), and make DCD +12V as needed to fool it, so it's not really
fucking rocket-science.

The only real issues with RS-232 are labeling and realizing how 
stupidly simple it is!
-Steve
-- 
-Steve Walz  rstevew@armory.com   ftp://ftp.armory.com/pub/user/rstevew
Electronics Site!! 1000's of Files and Dirs!!  With Schematics Galore!!
http://www.armory.com/~rstevew or http://www.armory.com/~rstevew/Public