[EdCert previous] [EdCert next] [EdCert top]

RS-232: Connectors and Cabling

Most serial ports follow a standard called the RS-232 specification. RS-232 is a sort of "do all" specification, and as such is not perfect in every situation. In fact, it's overkill for most standard communication. However, it's good enough to have become an industry standard.

Table 1
DB-25 pin assignments
Pin Name Signal Pin Name Signal
1 FG Frame ground 14 STD Secondary TD
2 TD Transmitted data 15 TC Transmit clock
3 RD Received data 16 SRD Secondary RD
4 RTS Request to send 17 RC Receive clock
5 CTS Clear to send 18 - Unassigned
6 DSR Data set ready 19 SRTS Secondary RTS
7 SG Signal ground 20 DTR Data terminal ready
8 DCD Data carrier signal 21 SQ Signal quality detector
9 - Positive voltage 22 RI Ring indicator
10 - Negative voltage 23 DRS Data rate selector
11 - Unassigned 24 SCTE Clock transmit external
12 SDCD Secondary DCD 25 BUSY Busy
13 SCTS Secondary CTS

RS-232 defines the meaning of the different serial signals and their respective pin assignments on a standard 25-pin (DB-25) serial connector. Table 1 (a plain text version is also available) shows these assignments. Luckily, in standard types of communications only 9 of these pins are important: 1-8, and 20.

DB-25 connectors are either male, with the pins sticking out, or female, with matching holes. Often there are very small numbers marking the pins or holes 1-25. The female connector is a mirror image of the male so that pins and holes match.

Originally, there was no standardization of the gender of connectors and serial devices. Both connectors and serial devices could be either gender. However, since male connectors are more susceptible to injury than female, most expensive computing hardware these days has female connectors, while cables are male on both ends.

Since RS-232 defines signals that are not used for most standard communication, sometimes DB-25 connectors are missing unneeded pins. In this case, serial cables simply leave the unused pins disconnected.

Cabling

There are two cable configurations in use today for serial equipment:

DTE (Data Terminal Equipment)
Typically used for computers, terminals, and printers.
DCE (Data Communications Equipment)
Typically used for modems.

These different configurations determine which signal a device expects on which pin. All devices are configured as either DTE or DCE. Because terminals are typically DTE, and modems are typically DCE, you must use a different cable between a computer and a terminal than between a computer and a modem. We will talk more about this cabling difference later.

The RS-232 specification defines the the maximum length of serial cable to be 75 feet at 9,600 bps. This is a pretty conservative figure and has been stretched as far as 1,000 feet. How far the limit can be stretched depends on the brand of terminal and computer you are using. This is something to keep in mind when connecting terminals to computers in other rooms.

Alternate Serial Connectors

Because of the fact that RS-232 defines signals that go unused in standard types of communication, and because the traditional DB-25 connector is large an unwieldy (especially for small equipment, like laptops), many alternate serial connectors have come into widespread use. These connectors provide the same necessary pins as a DB-25, but are smaller, more manageable connectors. Because they provide access to the same signals, devices that use different connectors are compatible as long as you use the right kind of converter cable.

DIN-8

DIN-8 serial connectors are small, and almost circular. They are used on Macs, and often on laptops because they are so compact. DIN-8s provide the seven most common serial signals whose pin assignments are shown in Table 2 (a plain text version is also available).

Table 2
DIN-8 pin assignments
DIN-8 Pin Corresponding DB-25 Pin Signal Function
3 2 TD Transmitted data
5 3 RD Received data
6 4 RTS Request to send
2 5 CTS Clear to send
4,8 7 SG Signal ground
7 8 DCD Data carrier detect
1 20 DTR Data terminal ready

DB-9

DB-9s are most commonly found on PCs. They look like smaller versions of the DB-25 connector. DB-9s provide the eight most common serial signals whose pin assignments are shown in Table 3 (a plain text version is also available).

Table 3
DB-9 pin assignments
DB-9 Pin Corresponding DB-25 Pin Signal Function
2 3 RD Received data
3 2 TD Transmitted data
8 4 RTS Request to send
7 5 CTS Clear to send
6 6 DSR Data set ready
5 7 SG Signal ground
4 8 DCD Data carrier detect
1 20 DTR Data terminal ready

RJ-45

RJ-45 connectors look a lot like standard telephone connectors ... but they're not. They house eight wires instead of the four wires in a telephone connector. RJ-45s are not typically found on computers or normal serial equipment, but, because they are so small, they are often used on devices that have a lot of ports very close together. Terminal servers are a good example of devices that often use RJ-45 connectors.

There are many wiring schemes for mapping the pins on an RJ-45 connector to a DB-25 connector. Possibly the best is the Yost standard, which wires all RJ-45 to DB-25 connections the same way. The advantages this system provides are:

For more information about the Yost wiring standard see the optional document, Yost Serial Device Wiring Standard.

Hard Vs. Soft Carrier

When a serial device is attached to the system and turned on, Unix expects the DCD signal (data carrier detect) to be asserted. If your system pays close attention to whether that signal is asserted, you are using what is called hard carrier. Most systems also allow you to use soft carrier where the system pretends that the DCD signal is always asserted.

Soft carrier is often a very good thing for certain devices. For instance, with a terminal, it lets you use only 3 wires for a connection: transmitted data, received data, and signal ground. However, in a modem connection, you really want to pay attention to DCD. When you are connected via a modem, if the carrier signal is lost, you want the modem to hang up. If you are using soft carrier, DCD is assumed to be asserted, so even if you lose the signal, the modem can remain connected. This can be very bad news over a long distance connection since the modem could potentially remain connected for days.

Most modern systems set a default carrier mode for serial ports in their configuration files. The command stty -CLOCAL will force a terminal to use soft carrier, so for instance:

        stty -CLOCAL < /dev/ttya

would enable soft carrier on serial port ttya.


Terms used: RS-232, DB-25, DTE, DCE, null-modem cable, DIN-8, DB-9, RJ-45.



[EdCert previous] [EdCert next] [EdCert top]