RS232 Wiring
RS232 DB9 Connector | ||
DB-9M | Function | Abbreviation |
Pin #1 | Data Carrier Detect | CD |
Pin #2 | Receive Data | RD or RX or RXD |
Pin #3 | Transmit Data | TD or TX or TXD |
Pin #4 | Data Terminal Ready | DTR |
Pin #5 | Signal Ground | GND |
Pin #6 | Data Set Ready | DSR |
Pin #7 | Request To Send | RTS |
Pin #8 | Clear To Send | CTS |
Pin #9 | Ring Indicator | RI |
RS232 DB25 Connector | ||
DB-25M | Function | Abbreviation |
Pin #1 | Chassis/Frame Ground | GND |
Pin #2 | Transmit Data | TD |
Pin #3 | Receive Data | RD |
Pin #4 | Request To Send | RTS |
Pin #5 | Clear To Send | CTS |
Pin #6 | Data Set Ready | DSR |
Pin #7 | Signal Ground | GND |
Pin #8 | Data Carrier Detect | DCD or CD |
Pin #9 | Transmit + (Current Loop) | TD+ |
Pin #11 | Transmit - (Current Loop) | TD- |
Pin #18 | Receive + (Current Loop) | RD+ |
Pin #20 | Data Terminal Ready | DTR |
Pin #22 | Ring Indicator | RI |
Pin #25 | Receive - (Current Loop) | RD- |
DTE vs DCE
This is one of the most misunderstood areas of RS-232. DTE stands for Data Terminal Equipment, and DCE stands for Data Communications Equipment. DTE is typically either a dumb terminal or the serial port on a computer/workstation. DCE is typically a modem, DSU/CSU, or other piece of data communications equipment... hence the names. This is all most people really need to know about these terms.
Where it gets confusing is when you start to talk about signal definitions and direction. For example, it's easy for someone to understand that when you transmit data, you send it out. However, when you talk in terms of the DCE, it becomes an input. This is because the specification was written from the perspective of the DTE end of the link. Another example is that the Receive Data signal is an input to DTE, but an output from DCE.
Therefore, a straight through "one to one" cable is all that is necessary between a modem and a standard DTE serial port. However, if you want to connect two DTE ports together, you have to simulate the existence of the pair of DCE devices, typically modems, that would normally be between the two DTE devices. This is where the null-modem device or cable comes in.
RS-232 signal information
TxD, or Transmit Data:
It is an output for DTE devices and
an input for DCE devices. This is the data channel from the DTE
device to the DCE device.
RxD, or Receive Data:
It is an input for DTE devices and an
output for DCE devices. This is the data channel from the DCE device
to the DTE device.
RTS, or Request To Send:
It is an output for DTE
devices and an input for DCE devices. This signal is typically used
to gate flow from the DCE device to the DTE device. In other words,
the workstation serial port would drop this signal to halt flow from
the modem, and then later raise it to resume flow.
CTS, or Clear To Send:
It is an input for DTE devices and an
output for DCE devices. This signal typically is used to gate flow
from the DTE device to the DCE device. In other words, a modem may
drop this signal to halt flow from the workstation, and then later
raise it to resume flow.
DSR, or Data Set Ready:
It is an input for DTE devices and an
output for DCE devices. This signal is not widely used in UNIX,
except on some DEC machines, which will block on open if it is not
true in some cases.
GND, or Signal Ground:
Signal return for all signal lines.
DCD, or Data Carrier Detect:
It is an input for DTE devices and an
output for DCE devices. This signal is used to show that there is a
valid connection between the DTE and DCE devices. It is typically
used to block opens on a port before connections, and to generate
UNIX "hang up" signals upon loss of a connection.
DTR, or Data Terminal Ready:
It is an output for DTE devices and
an input for DCE devices. This signal is typically used in UNIX to
show that the port has been activated or "opened".
RS-232 Flow Control Primer
Hardware flow control uses pins >RTS and CTS to
gate flow back and forth between two connected serial devices. The
DTE device uses RTS to start and stop flow from the DCE device, and
the DCE device uses CTS to gate flow from the DTE device.
This method is popular for higher speed connections where flow
control reaction time is more critical. It's also popular where the
data stream is such that embedded flow control characters can not be
tolerated by the protocol running on the link. The cost is that you
have to run two more wires in the cable.
Software flow control uses special START (XON) and
STOP (XOFF) characters embedded in the data stream to gate flow. In
other words, the receiving device would send a STOP character
(typically a control-s) to the sending device to halt flow. It would
then later send a START character (typically a control-q) to resume
flow.
This method of flow control is more popular for slower links whose
protocol can support embedded flow control characters. It's popular
because it only requires that you run 3 wires for the link to
function. Receive (RxD), Transmit (TxD), and Ground (GND).