The RS-232-C serial connection is one of the most common
connections in the Commercial Computer system and also one of the least
understood. It works so well, people frequently never get into how it
works. The purpose of this paper is to shed enough light on the subject
to make it a lot easier.
The RS-232-C Specification was designed to connect a
DTE device (data terminal equipment) and a DCE device (data
communication equipment) USING STRAIGHT THRU CONNECTIONS. All
signals are referenced to DTE; meaning the DCE end of the cable will
have the same signal name but opposite function (i.e. outs are ins and
ins are outs). On a DTE device pin 2 is 'TD' transmit data therefore on
the DCE end, pin 2 is also called TD but is an input (receiver).
Confusing isn't it!
What is DTE and DCE?
Who cares whether a device is DTE or DCE. YOU DO! Ever
try to hook up a printer or terminal with cables of questionable origin
or you don't have a clue as to what a 40242G cable is. By knowing first
what kind of devices you are trying to connect; you can quickly find a
cable that will work.
A DTE device is a consumer or producer of data; computers, terminals and
printers are examples.
A DCE device transfers the data; modems, multiplexers and data switches
are examples.
To connect between two DTE's or two DCE's requires the crossing of many
wires to work; add to this, inconsistency among manufacturers and you
get a lot different cables types.
How to determine whether a device is DTE or DCE
Fortunately this is easily done by inspection. DTE
devices transmit on pin two and DCE devices transmit on pin three. A
breakout box will quickly show this by lighting the led on pin 2 or 3.
If you don't have a break out box use a volt meter and measure between
pins 2/3 and pin 7 (signal ground). The transmit line will be
approximately -12 volts.
If you find both devices are DCE or DTE you will need
to use a cross wired cable. The classic example is the null modem
eliminator / adapter we hear about frequently. It would be used when
connecting say a laserjet (DTE) to a IBM PC Clone's DBM25 serial port
which is also a DTE device. This requires crossing pin 2 and pin 3.
Printers don't normally need control lines so a simple 3 wire connection
with 2 crossed to 3 will do the job.
Surprisingly most connections actually require few
wires to work. Even Modems will work on 3 wire connections! Just set the
modems DTR high all the time and connect your 3 wires and go to work.
The real beauty of this method is it's simplicity; you
don't worry about what the connector is wired for, DTE or DCE since you
can determine it by simple inspection. And if the cable should be
crossed you will see that quickly too. And oh yea, remember we never
connect (TD) transmit data pin to a (TD) transmit data pin. Which brings us to:
RS-232-C Asynchronous Serial Data Format and voltage levels
Asynchronous character transmission is the most common
type of Serial Data communications. We are only interested in this type
of signal for our printer, terminal and modem communication's which
will comprise 95 percent of your need.
Everybody intuitively knows that an asynchronous
serial character is an alternating voltage level. What most people don't
know is what the hell is a mark, space, start bit, stop bit or for that
matter what the heck is a BAUD!
A mark is logically equivalent to a logical one. A
space is equivalent to a logical zero. And of course ones and zeros are
used to determine the ASCII code for any particular character. We refer
to these marks and zeros as bits. The number bits or marks and zeros in a
character determines the size of the Character Set.
The limitation as to the number of characters we can
encode is limited to the number of bits used. In the printer world this
is why we hear the terms; 7-bit character set, 8-bit character set etc.
For instance: The Roman-8 character set uses 8 bits or marks and zeros
when encoding a character. Of course 8 bits equal a byte and a byte can
have a decimal value of 256. Therefor an 8-bit character set has 256
possible characters. A 7-bit character set has one half the binary
weight or 128 characters available.
Mark and space also have additional functions. To
alert a printer that a character is coming; the encoded character is
preceded by a start bit (space). Upon seeing the start bit the printer
starts building a character based on the marks and spaces transmitted
following the start bit. The last piece sent is a stop bit (mark), which
signals the end of a character. Therefor if we are using an 8-bit
character set; we have the 8 bits for the character, a start bit and a
stop bit giving us 10 bits in total.
Which brings us to the BAUD! The baud
rate with which we are all so familiar; is the number of bits
transmitted in one second. For example 19.2k baud is how many characters
per second. Well if we are using an 8-bit character set, have one start
bit and one stop bit; that equals 10 bits per character and at 19200
baud we get 1920 characters per second. Easy, huh! Whoops but what if
the stop bit is 1.2 bits or 2 bits long. Now we get 10.2 bits per
character or 11 bits per character which when divided into 19.2k baud
equals less characters per second. So while baud rate appears to
indicate the character rate it is not entirely true. It only indicates
the maximum possible character rate depending on the character format
used.
Here is another thing to also remember about
asynchronous transmission; you can have say a 56k baud rate but you may
only be sending one character every 5 years. While it is true you have a
fast baud rate, it will still take 25 years to print 'HELLO'.
An asynchronous ASCII character data signal therefor
varies between -12v (mark) and +12v (space). The lowest value this
should ever be is -3v and +3v. So when we measure -12v on pin 2 of a DTE
device (like a printer) we are actually looking at the stop bit. When a
character starts you will see a start bit which will change the voltage
level from -12v to +12v followed by the mark and space code for the
ASCII character terminating with the stop bit. ASCII Character Format
ASCII Character format is the familiar, 8 data bits, no
parity, 1 stop bit or 7 data bits, even parity and 1 stop bit. These
different formats impact our mission so it is very important to
understand the above explanation of 7-bit and 8-bit character sets. How
does this effect us? For example:
Customer has connected a Laserjet to a DTC and is using
7 data bits w/even parity. Printer works ok but has trouble with some
forms. You bet he does, he can not send any 8 bit characters to the
printer, such as raster graphics until he changes to 8 data bits, no
parity.
Customer logs into his HP Unix system over a modem,
can't run SAM. Normal connection on Unix is 7 data bits w/even parity.
Whoops SAM has line drawing characters which requires the 8 bit
character set.
Successful Serial Communications between 2 Devices always require:
1. BAUD RATE - The same baud rate
2. CHARACTER FORMAT - The same character format (type of parity in use and
number of bits)
An important observation
Any device that transmits a signal; i.e. a mux panel
port, supplies its own driving voltages (-12 & +12v). It is
considered an active pin. That means whatever is connected to this
active signal such as a modem or printer; that pin is a passive pin.
Since the mux panel is supplying the voltage for the signal we wish to
transmit, it is absolutely mandatory that the common, ground or signal
reference wire be connected. Without this wire the passive device; i.e.
the printer, cannot see the signal.
This is a law of physics that is frequently forgotten.
Why the hype? Because many times people will not connect pin 7 of the
RS-232-C, or the connection is resistive. Yet their mux panel
connections or building wiring works! How can this be?
Simple, the printer has a chassis ground and the
computer has a chassis ground; signal is developed by this alternate
path. That being the case; you can actually connect a printer using only
a one wire connection. Try it sometime. That is where people frequently
get sloppy. Worse yet the printer setup has been working fine; the
printer is moved or the computer is moved: suddenly it is not working
any more. (spoolie i/o errors)
However if the cabling follows the standard, and the
active pin and the signal ground go between both devices; it will always
work! Period! Full Stop!
Now what about a signal coming from say a printer to a
mux panel. Again the printer is now the transmitter and that makes it
the active pin and the mux panel pin is the passive pin. Since the
printer is now supplying the driving voltages you must provide a signal
reference from it to the mux panel. Pin 7 has been designated as the
common signal reference between any two devices. It is the only
mandatory connection in the RS-232-C specification.
With what we have just discussed; we have a transmit
line from a mux panel to a printer. Also a transmit line from the
printer to the mux panel and a single common signal reference line (pin
7). This is a known as a serial channel and it only takes three wires to
do it.
What is a Channel?
A channel is the expression used to describe a RS-232-C
serial connection. For example when a program dials a modem to connect
to a remote computer; this process is called 'OPENING A CHANNEL'. This
is why the RS-232-C standard refers to a primary channel. This primary
channel consists of pins 2 & 3 plus the signal reference pin 7. The
RS-232-C specification also has set aside 2 more pins out of the 25 pins
as a secondary channel. It merely means you can transmit/receive data
on to separate sets of pins; thus the RS-232-C specification has two
data channels. Primary and the Secondary channel.
If you only need 3 wires (2,3 & &) for a serial channel; what
the are all those other 22 pins for?
The answer is sweet and simple protocol control. How we
transmit our serial channel. Lucky for us; 90% of all the different
connections we use only require a few basic control signals.
BASIC RS-232-C Controls and Status - for typical applications; only 8
lines need to considered:
SIMPLIFIED RS-232-C |
| | | | |
| | | | | | | |
CIRCUIT TYPE |
COMMON SIGNAL MNEMONICS |
PIN |
RS-232-C DESCRIPTIONS |
DTE I/O |
OUTPUT SOURCE |
EIA |
COMMON |
FG |
1 |
SHIELD/FRAME GROUND |
|
COMMON |
AA |
|
SG |
7 |
SIGNAL COMMON (connection is mandatory!) |
COMMON |
AB |
| | | | | | | |
DATA |
TD |
2 |
TRANSMITTED DATA |
out |
DTE |
BA |
|
RD |
3 |
RECEIVED DATA |
in |
DCE |
BB |
| | | | | | | |
CONTROL |
RTS |
4 |
REQUEST TO SEND |
out |
DTE |
CA |
|
CTS |
5 |
CLEAR TO SEND |
in |
DCE |
CB |
|
DSR |
6 |
DATA SET READY |
in |
DCE |
CC |
|
DCD |
8 |
DATA CARRIER DETECT |
in |
DCE |
class=ALT3k CF |
|
DTR |
20 |
DATA TERMINAL READY |
out |
DTE |
CD |
|
RI |
22 |
RING INDICATOR |
in |
DCE |
CE |
This table lists the most common signals required used in serial channel
connections.
RS-232-C Signal Definitions - Check your modem or terminal handbook
for local description:
DTR - Data Terminal Ready is used for call initiaiton, call termination,
suppressing Autoanswer
DSR - Data Set Ready is an indicator that the modem is ready.
Most modems have selectable behavior.
DCD - modem indicates it is receiving carrier from the remote modem
RTS - terminal requests permission to send data to the modem
CTS - Clear to Send grants permission for the terminal to send data for
retransmission to the remote modem.
RI - modem indicates that the phone is ringing
3 Wire connections don't need control or status signals.
Controlling data between say a DTC port or mux panel and say a printer is done
using
In-Band Control.
HP uses two types of In-Band Control. Flow Control and Status Checking.
What is Flow Control?
Flow control is the ability to start and stop the flow
of ASCii characters over a serial channel. This is a critical process
needed to ensure characters are not sent at the wrong time and
subsequently loss. There are two basic types of flow control used in
RS-232-C channel communications; in-band and out-of-band flow control.
In-Band Flow Control (Software Handshaking)
XON/XOFF - flow control is the most common type
of in-band flow control. The ASCii control characters for XON/XOFF are
mixed in with the data being sent over the channel for the purpose of
starting or stopping data flow. A XON sent from a printer to the
computer tells the computer the printer is ready for more data. XOFF
performs the opposite function and tells the computer to stop sending
data.
A classical example of loss of in-band control to a
printer is that the first few pages printed are fine. But suddenly there
is a loss of printout then the printing picks up further on. This is
usually the result of the computer not seeing an XOFF from the printer
to stop the data flow. The problem can be a bad connection on pin 2,
broken or misconfigured printer, bad serial port on the CPU or
frequently the printer is configured for 7 data bits with even parity
but the HP3000 is configured for 8 bits no parity. The HP3000 won't
recognize the XOFF!
ENQ/ACK - flow control is the same as XON/XOFF
but are 2 different control characters. Older versions of MPE used
ENQ/ACK as well as HP1000 computers.
ETX/ACK - flow control is the IBM version of XON/XOFF but are 2 different
control characters
Status Checking (Software Handshaking)
Hewlett Packard has developed it's own strategy of
In-Band Control that it uses in addition to XON/XOFF flow control. The
purpose of this was to improve the integrity of remote printing.
HP Term types 19,22 and 26 use status checking. Before
a print job is sent the software sends the 3 following characters:
escape, XON and a question mark (?). A printer upon receiving the (?)
question mark transmits a single decimal character to the computer. If
the printer is ready and on-line the printer will send the ASCII
character for a zero. The HP computer sees this character; determines
the printer is ready and starts transmitting the print job. If the
Computer does not receive the character or the character has a value
other than zero; then the computer assumes there is a problem and will
shut down the print job (frequently seen as a spoolie i/o error).
There is nothing to indicate that this handshake
failed. The printer just sits there and looks like it can't be printed
to. Review the part about transmit voltages (An Important Observation).
If you think you may be experiencing Status Checking
failure; change the term type to 18. This is known as the dumb term type
and does not use Status Checking. Use term type 18 only for printers
that don't support status checking.
Out-of-Band Flow Control (Hardware handshaking)
Out-of-band flow control; frequently called hardware
handshaking use the RS-232-C control line or lines to control data flow
over the channel. This is most frequently needed for binary transfers (8
bits per character) where embedding XON/XOFF control characters would
interfere with the binary data.
RTS/CTS - is the most commonly used control
lines for flow control. Using a computer modem hookup as an example;
when the computer is ready to send data it raises or asserts the RTS
request to send control line. The modem is monitoring this line; upon
seeing the line asserted and the modem is able to receive and retransmit
a character; the modem will assert CTS clear to send which grants the
computer the right to send. The computer will then send data until CTS
is lowered or the data flow is complete. With this arrangement data can
be paced i.e. start..stop..start..stop..etc.
DTR - data terninal ready can also be used to
control flow. When DTR is asserted the computer will send data. When
de-asserted the data flow stops. HP3000.s use this signal to enable the
modem and force the modem to hang up by lowering of DTR. The old MPE
spooler would assert DTR upon receipt of a print job. When the print job
was complete the spooler would de-assert or lower DTR. DTR can enable
flow or even pace the flow i.e. start..stop..start..stop..etc. Printers
can control flow by de-asserting DTR when the buffer is full and
asserting DTR when the buffer is ready for more data.
DCD - data carrier detect will also work for
flow control. If DCD is asserted then the modem has established a
connection with the remote modem's carrier which shows the channel is
open. DCD can enable flow but does not pace the flow i.e.
start..stop..start..stop..etc.