22.3 Serial Cables
If
you have problems getting a serial port to talk to a peripheral,
you're probably using the wrong cable.
That's not surprising, because
there's no such thing as a standard serial cable.
Serial cables differ in the connectors used on each end, the number
and type of wires that are connected end to end, the
pinouts (which pin on one connector is connected
to which pin on the other), and the connections made internally
within each local connector, if any. With permutations, there are
literally millions of ways you could build a
serial cable. Fortunately, only a handful are commonly used.
22.3.1 Common Serial Cable Types
Commonly used serial cables fall into one of the two following
general categories:
- Straight-through serial cables
-
Straight-through serial cables are used to
connect unlike devices (DTE to DCE). A straight-through cable is just
what it sounds like—each pin on one connector connects to the
corresponding pin on the other. On a DB25-to-DB25 or DB9-to-DB9
cable, this means that each pin on one connector connects to the same
pin number on the other. On a DB9-to-DB25 cable, the wires connect
different pin numbers, but the same signal. For example, DTR (pin 20
on the DB25) is connected to DTR (pin 4 on the DB9). Almost any cable
with a DB9 connector connects all nine pins. DB25 cables may have all
or only some pins connected, but the existing connections are
straight-through.
- Cross-over serial cables
-
Cross-over serial cables are used to connect
like devices (DTE to DTE, or DCE to DCE). Cross-over cables come in
an amazing variety of pinouts, some reasonably standard and others
specific to one particular type of connection, e.g., an HP LaserJet
serial port to a DB25 PC serial port. The term null-modem
cable is often misused to mean any cross-over cable, but a
null-modem cable is really just one variety of cross-over cable.
PC serial ports are usually configured as DTE. Modems, mice,
trackballs, digitizers, and scanners are usually DCE devices, and so
connect to a PC with a straight-through cable. Serial printers and
plotters are usually DTE devices, and so connect to a PC using some
form of cross-over cable. Connecting two DTE PCs also requires a
cross-over cable.
Any bidirectional serial cable must connect at least TD, RD, and SG
(pins 2, 3, and 7 on a DB25). Those to be used with hardware flow
control require additional connections. Here are pinouts for some
common serial cables.
Table 22-4 shows the simplest possible
bidirectional straight-through cables, which may be used to connect a
DTE (e.g., a serial port) to a DCE (e.g., a modem). These cables are
not commonly used because they make no provision for hardware flow
control.
Table 22-4. Simple straight-through cables
Pin 2 to Pin 2
|
Pin 3 to Pin 3
|
Pin 2 to Pin 3
|
DTE RD to DCE TD
|
Pin 3 to Pin 3
|
Pin 2 to Pin 2
|
Pin 3 to Pin 2
|
DTE TD to DCE RD
|
Pin 5 to Pin 5
|
Pin 7 to Pin 7
|
Pin 5 to Pin 7
|
SG to SG
|
Table 22-5 shows the simplest possible
bidirectional cross-over cables. These cables, which also make no
provision for hardware flow control, are commonly used to attach DTE
terminal server ports to DTE terminals in a host environment, but are
uncommon in the PC environment.
Table 22-5. Simple cross-over cables
Pin 2 to Pin 3
|
Pin 3 to Pin 2
|
Pin 3 to Pin 3
|
RD to TD
|
Pin 3 to Pin 2
|
Pin 2 to Pin 3
|
Pin 2 to Pin 2
|
TD to RD
|
Pin 5 to Pin 5
|
Pin 7 to Pin 7
|
Pin 5 to Pin 7
|
SG to SG
|
Table 22-6 shows the connections for typical
straight-through cables used to link DB25M and DB9M serial ports to a
DB25F modem. Some programs, notably some bulletin board software,
also require that pins 12 and 23 be connected, which rules out using
these programs with a DB9 serial port.
Table 22-6. Connections for typical straight-through modem cables
Pin 1 to shield
|
N/A
|
Cable shield to ground
|
Pin 2 to Pin 2
|
Pin 3 to Pin 2
|
DTE TD to DCE RD
|
Pin 3 to Pin 3
|
Pin 2 to Pin 3
|
DTE RD to DCE TD
|
Pin 4 to Pin 4
|
Pin 7 to Pin 4
|
RTS to RTS
|
Pin 5 to Pin 5
|
Pin 8 to Pin 5
|
CTS to CTS
|
Pin 6 to Pin 6
|
Pin 6 to Pin 6
|
DSR to DSR
|
Pin 7 to Pin 7
|
Pin 5 to Pin 7
|
SG to SG
|
Pin 8 to Pin 8
|
Pin 1 to Pin 8
|
CD to CD
|
Pin 20 to Pin 20
|
Pin 4 to Pin 20
|
DTR to DTR
|
Pin 22 to Pin 22
|
Pin 9 to Pin 22
|
RI to RI
|
Table 22-7 lists the pinouts for a DB9-to-DB25
adapter cable, which allows a DB25 serial cable to connect to a DB9
serial port. We generally keep only straight-through, 25-wire,
DB25-to-DB25 cables on hand, which can be used with such adapters to
connect anything to anything.
Table 22-7. Pinouts for a DB9-to-DB25 adapter cable
1
|
8
|
Data Carrier Detect (CD) to Data Carrier Detect (CD)
|
2
|
3
|
Received Data (RD) to Received Data (RD)
|
3
|
2
|
Transmitted Data (TD) to Transmitted Data (TD)
|
4
|
20
|
Data Terminal Ready (DTR) to Data Terminal Ready (DTR)
|
5
|
7
|
Signal Ground (SG) to Signal Ground (SG)
|
6
|
6
|
Data Set Ready (DSR) to Data Set Ready (DSR)
|
7
|
4
|
Request to Send (RTS) to Request to Send (RTS)
|
8
|
5
|
Clear to Send (CTS) to Clear to Send (CTS)
|
9
|
22
|
Ring Indicator (RI) to Ring Indicator (RI)
|
The following tables list the pinouts for serial cables that you can
use with the MS-DOS InterLink or the Windows 9X Direct Cable
Connection (DCC) utilities. Because a serial link is much slower
(about 10 KBps), use one of these serial cables to link the computers
only if parallel ports are not available on both or if the operating
system does not support direct parallel connections. The pinouts for
parallel InterLink/DCC cables are provided later in this chapter.
Although Windows NT does not support InterLink, DCC, or direct
parallel connection, you can also use these serial cables to connect
a Windows NT computer and a Windows 9X computer via Windows NT RAS.
For detailed instructions, see Microsoft article Q142065,
Connecting Windows
NT to
Windows 95
with a
Null-Modem
Cable.
Table 22-8 shows a DB9F-to-DB9F serial cable for
use with InterLink or Direct Cable Connection. Pins 1 and 6 are shown
bridged because some motherboards cause a "Cable not
connected" message to appear unless CD is asserted
by being bridged to DSR (so that the voltage that appears on DSR any
time the modem is ready also appears on CD to spoof the DTE into
believing that a carrier is always present). You can leave pin 1
disconnected if this is not the case with your motherboard. However,
it doesn't hurt to have pin 1 connected, even if
your motherboard does not require CD be forced high, so the pinouts
shown result in a more generally useful cable.
Table 22-8. DB9F-to-DB9F serial cable for use with InterLink or Direct Cable Connection
1 & 6
|
4
|
CD and DSR to DTR
|
2
|
3
|
RD to TD
|
3
|
2
|
TD to RD
|
4
|
1 & 6
|
DTR to CD and DSR
|
5
|
5
|
SG to SG
|
7
|
8
|
RTS to CTS
|
8
|
7
|
CTS to RTS
|
Table 22-9 shows a DB25F-to-DB25F serial cable and
Table 22-10 a DB9F-to-DB25F serial cable, both for
use with InterLink or Direct Cable Connection.
In Table 22-9, pins 6 and 8 are bridged per the explanation in the
preceding text.
Table 22-9. DB25F-to-DB25F serial cable for use with InterLink or Direct Cable Connection
2
|
3
|
TD to RD
|
3
|
2
|
RD to TD
|
4
|
5
|
RTS to CTS
|
5
|
4
|
CTS to RTS
|
6 and 8
|
20
|
DSR and CD to DTR
|
7
|
7
|
SG to SG
|
20
|
6 and 8
|
DTR to DSR and CD
|
In Table 22-10, pins 1 and 6 and pins 6 and 8 are bridged per the
explanation in the preceding text.
Table 22-10. DB9F-to-DB25F serial cable for use with InterLink or Direct Cable Connection
1 and 6
|
20
|
CD and DSR to DTR
|
2
|
2
|
TD to RD
|
3
|
3
|
RD to TD
|
4
|
6 and 8
|
DTR to DSR and CD
|
5
|
7
|
SG to SG
|
7
|
5
|
RTS to CTS
|
8
|
4
|
CTS to RTS
|
22.3.2 Cable Guidelines
Keep the following issues in mind when you need to buy or build a
cable:
Buy the cable if you can. Any cable you need is probably a standard
item, and will be cheaper and better than one you build. If you need
an unusual pinout, order a custom cable from Black Box, DataComm
Warehouse, or another company that produces cables to order.
Use the shortest cable possible for more reliable connections,
particularly at high speeds. If you need a long cable, buy a
high-grade one made with low-capacitance wire.
Don't judge cables by appearance. Mass-produced
cables appear similar, but vary in quality. Custom-built cables are
usually of high quality and are priced accordingly.
You'll get no more than you pay for, and sometimes
less.
Don't assume that a cable connects every pin that
appears on the connector. Mass-produced cables usually have pins in
each position, while custom-built cables often have pins only in the
positions that are actually connected. Nearly any DB9 serial cable
connects all 9 pins, but cables with two DB25s may have anything from
3 to 25 pins connected, with 9 and 25 wire connections most common.
Any decent mass-produced cable lists the number of wires and how they
are connected on the packaging, and sometimes on the connectors.
22.3.3 Building Cables
You'll probably never need to build a cable, but
these guidelines will serve you well if you do:
Create a grab bag of patch boxes, male-male and female-female 9- and
25-pin gender changers, 9-to-25 adapters, and so forth. You can get
these things from Global, DataComm Warehouse, and similar places.
They cost only a few dollars and occupy little space. Buy two of
each, and add a straight-through 25-wire DB25-to-DB25 cable to the
bag. The next time you desperately need a cable and all the stores
are closed, you can use these parts to cobble together any cable you
need.
Use these parts to make a jerry-built cable that works, record the
pinouts, order a custom cable made to those specifications, and leave
the jerry-built cable in place until the new cable arrives to replace
it.
If you're running cables through walls to wall
jacks, make those cables straight-through and label both ends
accordingly. No one will remember the cable pinouts later, and
testing pinouts on a cable when only one end at a time is accessible
is almost impossible. Do the custom pinouts in the drop cable that
connects the wall jack to the equipment, and label both ends of that
cable, too. Note that a plain cable is a lot easier to run through
walls and floors than one that already has connectors attached.
To make semi-permanent, quick-and-dirty cables, keep a supply of
RJ-to-DB connectors on hand. They are available from Global and other
vendors in DB9 and DB25 male and female versions, and have a standard
6P6C ("RJ11") or 8P8C
("RJ45") jack on the back. The jack
is pre-wired to loose pins, which you can insert as appropriate into
the DB connector. You then use standard flat satin cable to link the
two connectors. If six or eight wires is enough, you can make a
custom cable with these connectors in about two minutes flat.
We've made a lot of
"temporary" cables this way that
are still in use ten years later.
22.3.4 Determining Pinouts on an Unknown Cable
At some point, you may find yourself
looking at a cable with no idea how it's pinned out
or whether it's usable for what you want to do. When
that happens, proceed as follows:
- Just try it
-
You can connect any RS232 pin to any other pin without damaging
anything. The worst that can happen is that nothing will work.
- Look for a label
-
Labels may be unambiguous. One labeled "HP
LaserJet" is probably just what you need to connect
a serial HP LaserJet. Short labels may mislead. A cable labeled
"null modem" may not have the
pinouts you need for your "null
modem" cable. Also, some cables are
asymmetric—both ends may use the same connector, but the
pinouts differ and the two ends are not interchangeable.
- Identify the active pins visually
-
Custom-made cables often have pins only for active lines. By
determining which pins are connected on each end, you can often make
a reasonable guess about the actual pinouts. If the visible pins
correspond to a "standard" cable
type, chances are good that it is that type of cable.
- Disassemble the connectors
-
Remove the connector hood and note the connections, including local
loopbacks within the connector body. By noting which pin number is
connected to which color wire, you can trace the pinouts end to end.
Mass-produced cables ordinarily use molded connectors, making this
method impossible to use.
- Use a continuity tester or DVM
-
Assuming a male-to-female cable, insert one probe into hole 1 of the
female connector, and then brush the other probe quickly against each
of the pins on the male connector, noting the pin number each time
the tester beeps to indicate continuity. Repeat this process for each
hole of the female connector. On a female-to-female cable, it takes a
bit longer because you cannot simply brush against the pins on the
second connector. On a male-to-male cable, it may seem that you need
three hands to keep everything lined up, but after some practice it
takes only a couple minutes to determine a pinout.
22.3.5 Loopback Plugs
In days of yore, every PC technician carried a set of
loopback
plugs for testing 9-pin serial ports, 25-pin serial ports, and
parallel ports. Nowadays, it's rare to see a
loopback plug, but they can still be invaluable in diagnosing port
problems.
In essence, a loopback plug (also called a wrap plug) is simply a
connector of the appropriate type with internal wiring that connects
paired pins such as TD and RD. When the loopback plug is connected to
a serial port for testing, outbound signals from the serial port
(e.g., TD) are looped back to the corresponding inbound pin (e.g.,
RD). If a signal does not appear as expected, either the outbound pin
or the inbound pin is not doing its job.
High-end diagnostic software (such as CheckIt) often includes
loopback plugs, either standard or as an option. You can also buy a
combination DB25/DB9 loopback plug from most electronics distributors
for $5 or so. If you have the components on hand to make cables,
it's easy enough to make your own loopback plugs,
using an empty D-shell connector and crimp-on, solder-on, or wirewrap
pins. The exact pinouts required differ according to the diagnostic
utility you are using, but most utilities can use a loopback plug
that uses the following standard pinouts:
DB25F Loopback Plug:
- 2 to 3 (TD to RD)
- 4 to 5 to 22 (RTS to CTS to RI)
- 6 to 8 to 20 (DSR to CD to DTR)
DB9F Loopback Plug:
- 2 to 3 (RD to TD)
- 7 to 8 to 9 (RTS to CTS to RI)
- 6 to 1 to 4 (DSR to CD to DTR)
|