// ENTRY NEWS
RS232 and null modem: how to choose a DB9 cable without mistakes
Two devices both having a DB9 connector is no guarantee that they can communicate once you join them with any cable. The port may be RS232, another interface that reuses the same shell, or even a proprietary connection. If it really is RS232, you still have to settle the physical gender, straight-through or crossover wiring, the signals in use and the serial port configuration.
The right purchase starts with each device's manual. Look for terms such as RS232, DTE, DCE, TXD, RXD, GND, null modem and flow control. Then compare that information against the cable's pinout, not just a photograph of its connectors.
DB9 describes the shell, RS232 the interface
DB9 is the common name for the nine-contact connector, although its technical designation also appears as DE-9. RS232 defines electrical characteristics and signals for serial communication. They are different concepts: a DB9 can carry RS232, but its presence alone does not prove that the port complies with that standard.
On older computers, the DB9 serial port is usually male. Many peripherals have a female socket, although there are plenty of exceptions in machinery, instrumentation, management consoles and control systems. Gender does not tell you whether the equipment is DTE or DCE either.
In the most common RS232 DB9 connections, a DTE uses pin 2 as RXD, pin 3 as TXD and pin 5 as signal ground. A DCE swaps the transmit and receive functions with respect to the DTE. This relationship explains why a straight-through cable is needed in some cases and a null modem in others.
Straight-through cable versus null modem
A straight-through cable joins each pin to the same number at the other end: 2 to 2, 3 to 3, 5 to 5, and so on for the lines that are implemented. It is normally used between a DTE and a DCE, for example in the classic terminal and modem arrangement.
A null modem cable crosses at least transmit and receive so that two devices of the same logical type, frequently two DTEs, can communicate. In its basic form it connects TXD on one side to RXD on the other, RXD to TXD, and keeps the signal ground. More complete cables also cross or link the flow control signals.
There is no single null modem pinout that covers every case. There are three-wire variants, local «loopback» variants and full flow control variants. Equipment that only uses TXD, RXD and GND can work with the basic crossover; equipment that requires RTS/CTS, DTR/DSR or carrier detect may sit waiting if those lines are not wired the way it expects.
The serial and parallel cables and adapters section is useful for comparing formats once you have identified the interface, the genders and the wiring scheme you need.
Physical gender: male, female and orientation
A male DB9 shows nine pins; a female DB9, nine sockets. Describe each end of the cable separately: male-male, male-female or female-female. Do not infer the gender from what the device does.
A 5 m female-female DB9 null modem cable physically fits between two male ports that distance apart, but it will only be suitable if both devices require a null modem and their pinout accepts the corresponding wiring.
Typical pinout of an RS232 DB9
| Pin | Signal on a DTE | Function summary |
|---|---|---|
| 1 | DCD | Carrier detect |
| 2 | RXD | Data receive |
| 3 | TXD | Data transmit |
| 4 | DTR | Data terminal ready |
| 5 | GND | Signal ground |
| 6 | DSR | Data set ready |
| 7 | RTS | Request to send |
| 8 | CTS | Clear to send |
| 9 | RI | Ring indicator |
The table shows the usual assignment as seen from a DTE. The manufacturer's manual takes precedence, above all on equipment that reuses the DB9 with a different pinout. The numbering can also be misread if you look at the solder side instead of the mating side; the two are visually mirrored.
Checklist for choosing without trial and error
- Confirm that both ports are RS232, not RS422, RS485, CAN, video or a proprietary interface on DB9.
- Note whether each port is male or female by looking at the pins and sockets.
- Identify each device as DTE or DCE, if the manual states it.
- Check whether the connection calls for a straight-through cable or a null modem.
- Work out which null modem variant you need: three wires or crossed control signals.
- Compare the TXD, RXD and GND pins at both ends.
- Check whether the equipment requires RTS/CTS, DTR/DSR or DCD.
- Choose a length that is long enough without creating an unnecessary run alongside power cables.
- Check the speed, data bits, parity, stop bits and flow control in the software.
Settings the cable cannot fix
Even with a correct pinout, both ends must use the same configuration: speed in baud, data bits, parity and stop bits. A typical setting is written 9600 8N1, that is, 9600 baud, eight data bits, no parity and one stop bit. «Typical» does not mean mandatory; check the equipment.
Flow control must match as well. It can be none, software based through XON/XOFF, or hardware based through RTS/CTS. A three-wire cable does not carry RTS and CTS. If the device requires hardware control, switching it off at random can cause stalls or data loss.
What changes when you use a USB-to-serial adapter
Current computers usually have no RS232 port, so a USB-to-serial adapter is used instead. This device creates a COM port on Windows or a device such as /dev/ttyUSB0 on Linux. It needs a driver compatible with its chipset and operating system.
The adapter does not automatically take the place of a null modem. Many USB-RS232 adapters behave as DTE; when you connect them to another DTE you may still need to cross TXD and RXD.
Do not confuse a USB-TTL adapter with USB-RS232. TTL and RS232 use different electrical levels; a direct connection may not work and could damage an input. USB-RS485 adapters are not equivalent either, even if they are sold for serial communications.
Common mistakes
- Choosing by the DB9 shell. The same connector can house incompatible interfaces.
- Assuming that female-female means null modem. Gender describes the mechanics; the crossover describes the internal wiring.
- Reversing the numbering when soldering. The front and rear views are mirror images.
- Crossing only 2 and 3 when there is flow control. The link may open, but stop as soon as a transfer begins.
- Changing several settings at once. That makes it hard to tell whether the fault lies in the cable, the COM port or the configuration.
- Assuming USB-to-serial solves any connection. The chipset, the drivers, the electrical levels and the DTE/DCE role still matter.
Frequently asked questions
Is a male-female DB9 cable always straight-through?
No. Gender says nothing about the internal wiring. Although many male-female extension cables are straight-through, you have to check their pinout or test continuity.
Can I join two computers with a straight-through cable?
In classic RS232, two computers usually behave as DTE and need a null modem to cross transmit and receive. Confirm the ports and the pinout before connecting them.
Do all null modem cables cross the same pins?
No. The minimum crossover affects TXD and RXD, but the variants handle RTS/CTS, DTR/DSR and DCD differently. Your equipment may require a specific variant.
What is the difference between RS232 and RS485?
RS232 is usually point to point and uses signals referenced to ground. RS485 uses differential signalling and allows other topologies. A DB9 connector does not turn one interface into the other.
Do I need to install a driver for USB-to-serial?
It depends on the chipset and the operating system. Some have built-in support and others require a specific driver. Once it is installed, check which COM port or device has been created.