Serial Communication:
Hardware description
by Nicolas Martin

This additional document gives extra information about the hardware of the serial communications, and deals mainly with the signal definitions, voltages, the connectors pinouts, and the required cables to connect together different types of devices to ensure a proper operation. It is provided here as the article intends to deal with all the angles of the serial communications subject, from hardware to software.

Serial communications versus Parallel communications

Most computers are equipped with serial ports and a parallel port. Although these two types of ports are used for communicating with external devices, they work in different ways :

- parallel ports
A parallel port sends and receives data eight bits at a time over 8 separate wires. This allows data to be transferred very quickly. Parallel ports are typically used to connect a PC to a printer and are rarely used for much. The cable length cannot be very long, generally less than a few meters.
- serial ports
A serial port sends and receives data one bit at a time over one wire. While it takes eight times as long to transfer each byte of data this way, only a few wires are required. In fact, two-way (full duplex) communications is possible with only three separate wires - one to send, one to receive, and a common signal ground wire. Cables for serial communications can be much longer than the parallel ones.

The RS-232C standard

RS-232 stands for Recommend Standard number 232 and C. It is now getting somehow obsolete, (it defined a maximum speed of 19200 bauds), a new one (RS232D) has been recently released. The serial ports on most computers use a subset of the RS-232C standard. The full RS-232C standard specifies a 25-pin “D” connector of which 22 pins are used. Most of these pins are not needed for normal PC communications, and indeed, most new PCs are equipped with male D type connectors having only 9 pins.

DTE and DCE Devices

Two terms are commonly used in serial communications, DTE and DCE. DTE stands for Data Terminal Equipment, and DCE stands for Data Communications Equipment. These terms are used to indicate the pin-out for the connectors on a device and the direction of the signals on the pins. Your computer is a DTE device, while most other devices are usually DCE devices.

You can simply replace the term “DTE device” with “your PC” and the term “DCE device” with “remote device” in the following discussion.

The RS-232 standard states that DTE devices use a 25-pin male connector, and DCE devices use a 25-pin female connector. You can therefore connect a DTE device to a DCE using a straight pin-for-pin connection. However, to connect two like devices, you must instead use a null modem cable. Null modem cables cross the transmit and receive lines in the cable, and are discussed later in this chapter. The table below shows the connections and signal directions for both 25 and 9-pin connectors.

First, let's go to some hardware basics. The electrical characteristics of the RS232C standard is contained in the EIA (Electronics Industry Association). The main ones are the following :

- A “Space” (logic 0) will be between +3 and +25 Volts.
- A “Mark” (Logic 1) will be between -3 and -25 Volts.
- The region between +3 and -3 volts is undefined.
- An open circuit voltage should never exceed 25 volts. (In Reference to GND)
- A short circuit current should not exceed 500mA. The driver should be able to handle this without damage. (Take note of this one!)

Serial Ports come in two “sizes”, There are the D-Type 25 pin connector and the D-Type 9 pin connector both of which are male on the back of the PC, thus you will require a female connector on your device. Below is a table of pin connections for the 9 pin and 25 pin D-Type connectors. The following table gives the pinouts of the different connectors, along with the signals involved on the serial communication port :

D-Type-25 Pin No. | D-Type-9 Pin No. | Abbreviation | Full Name | Function
Pin 2 | Pin 3 | TD | Transmit Data | DTE Serial Data Output (TD) Data is sent from a DTE device to a DCE device on this wire. The TD line is kept in a mark condition by the DTE device when it is idle.
Pin 3 | Pin 2 | RD | Receive Data | DTE Serial Data Input (RD) A DTE device receives data on the RD (receive data) wire, and the DCE device keeps this line in a mark condition when idle.
Pin 4 | Pin 7 | RTS | Request To Send | The DTE device puts this line in a mark condition to tell the remote device that it is ready and able to receive data. If the DTE device is not able to receive data (typically because its receive buffer is almost full), it will put this line in the space condition as a signal to the DCE to stop sending data. When the DTE device is ready to receive more data (i.e. after data has been removed from its receive buffer), it will place this line back in the mark condition.
Pin 5 | Pin 8 | CTS | Clear To Send | The complement of the RTS wire is CTS. The DCE device puts this line in a mark condition to tell the DTE device that it is ready to receive the data. Likewise, if the DCE device is unable to receive data, it will place this line in the space condition.
Pin 6 | Pin 6 | DSR | Data Set Ready | DSR (Data Set Ready) is the companion to DTR in the same way that CTS is to RTS.
Pin 7 | Pin 5 | SG | Signal Ground |
Pin 8 | Pin 1 | CD | Carrier Detect | A modem uses Carrier Detect to signal that it has made a connection with another modem, or has detected a carrier tone.
Pin 20 | Pin 4 | DTR | Data Terminal Ready | Its intended function is very similar to the RTS line. Some serial devices use DTR and DSR as signals to simply confirm that a device is connected and is turned on. The DTR and DSR lines were originally designed to provide an alternate method of hardware handshaking.
Pin 22 | Pin 9 | RI | Ring Indicator | A modem toggles the state of this line when an incoming call rings your phone.

Note : The Carrier Detect (CD) and the Ring Indicator (RI) lines are only available in connections to a modem. Because most modems transmit status information to a PC when either a carrier signal is detected (i.e. when a connection is made to another modem) or when the line is ringing, these two lines are rarely used.

DTE to DCE cables

Linking between a DTE and a DCE device is the simplest connection; as each signal simply needs to be connected to the same one on each end. For instance, if the DTE and the DCE devices use a 25 pins connector, then you can use a cable in which each pin on one end of the cable is connected to the same pin on the other end. If you use on one side a 25 pin connector and on the other side a 9 pin connector, then the same signals on each end need to be connected together, as shown on the above table.

DTE to DTE or DCE to DCE cables - Null Modem cables/adapter

If you connect two DTE devices (or two DCE devices) using a straight RS232 cable (that is a DTE to DCE cable), then the transmit line on each device will be connected to the transmit line on the other device and the receive lines will likewise be connected to each other. A Null Modem cable or Null Modem adapter simply crosses the receive and transmit lines so that transmit on one end is connected to receive on the other end and vice versa. In addition to transmit and receive, DTR & DSR, as well as RTS & CTS are also crossed in a Null modem connection.

DTE to DTE or DCE to DCE cables - Simplest connection

As it can be seen, communications between 2 devices, DTE to DCE or DTE to DTE require at minimum the RD and TD lines to be connected, and the signal ground (SG). All the other signals are control signals, that are used to control in some way the data flow between the two devices. Transmission can be achieved even if these control signals are not used, for instance in the two following situations :

- Instead of using a hardware flow control, a “software” flow control can be substituted, based on the transmission of given characters to stop or restart transmission. Better known under the name Xon/Xoff protocol, it is nevertheless less efficient than the hardware one.
- If no flow control is needed, meaning that the devices are able to process the incoming flow of data sufficiently quickly to not require any flow control. Even though it is less robust than with a flow control, this situation is used frequently in serial communications.

In the case a communication is to be achieved without hardware flow control, then a cable with only 3 wires (TD, RD & SG) can be used. The theory of operation is reasonably easy. The aim is to make the device think it is talking to another in a nominal situation. Any data transmitted from the first device must be received by the second thus TD is connected to RD. The second computer must have the same set-up thus RD is connected to TD. Signal Ground (SG) must also be connected so both grounds are common.

The Data Terminal Ready is looped back to Data Set Ready and Carrier Detect on both devices. When the Data Terminal Ready is asserted active, then the Data Set Ready and Carrier Detect immediately become active. At this point the device thinks the Virtual Modem to which it is connected is ready and has detected the carrier of the other modem.

All left to worry about now is the Request to Send and Clear To Send. As flow control is not needed thus these two lines are also linked together on each device. When one device wishes to send data, it asserts the Request to Send high and as it's hooked together with the Clear to Send, It immediately gets a reply that it is ok to send and does so.

Notice that the ring indicator is not connected to anything of each end.