Curriculum

Serial and Parallel Ports

A serial port is a serial communication physical interface through which information transfers in or out one bit at a time.

Data transfer through serial ports connected the computer to devices such as terminals or modems. Mice, keyboards, and other peripheral devices also connected in this way.

While such interfaces as Ethernet, FireWire, and USB all send data as a serial stream, the term "serial port" usually identifies hardware more or less compliant to the RS-232 standard, intended to interface with a modem or with a similar communication device.

For many computer peripheral devices the USB interface has replaced the serial port — as of 2007, most modern computers are connected to devices through a USB connection, and often don't even have a serial port. The serial port is omitted for cost savings, and is considered to be a legacy port. However serial ports can still be found in industrial automation systems, scientific analysis, and some industrial and consumer products. Network equipment (such as routers and switches) often have serial ports for configuration. Serial ports are still used in these areas as they are simple, cheap and allow interoperability between devices. The disadvantage is that setting up serial connections may require expert knowledge and complex commands if poorly implemented.

A male DE-9 connector used for a serial port on a PC style computer.

 

Settings

A multitude of software settings are required for serial connections used for asynchronous start-stop communication, most commonly setting speed, number of data bits per character, parity, and number of stop bits per character. In modern serial ports using a UART integrated circuit, all settings are usually software-controlled; hardware from the 1980s and earlier may require setting switches or jumpers on a circuit board. One of the simplifications made in such serial bus standards as Ethernet, FireWire, and USB is that many of those parameters have fixed values so that users can not and need not change the configuration; the speed is either fixed or automatically negotiated.

Speed

Serial ports use two-level (binary) signaling, so the data rate in bits per second is equal to the symbol rate in baud. Common bit rates per second for asynchronous start/stop communication are 300, 1200, 2400, 9600, 19200 baud, etc. These rates are based on multiples of the rates for electromechanical teleprinters. The port speed and device speed must match, though some devices may automatically detect the speed of the serial port. Though the RS-232 standard is formally limited to 20,000 bits per second, serial ports on popular personal computers allow settings up to 115,200 bits per second; the capability to set a bit rate does not imply that a working connection will result. Not all bit rates are possible with all serial ports. Some special-purpose protocols such as MIDI for musical instrument control, or OBD diagnostics for automobiles, use serial data rates other than the above series.

The speed includes bits for framing (stop bits, parity, etc.) and so the effective data rate is lower than the bit transmission rate. For example for 8-N-1 encoding only 80% of the bits are available for data (for every eight bits of data, two more framing bits are sent).

 Data Bits

The number of data bits in each character can be 5 (for Baudot Code), 6 (rarely used), 7 (for true ASCII), 8 (for any kind of data, as this matches the size of a byte), or 9 (rarely used). 8 data bits are almost universally used in newer applications. 5 or 7 bits generally only make sense with older equipment such as teleprinters.

Most serial communications designs send the data bits within each byte LSB (Least Significant Bit) first. This standard is also referred to as "little endian". Also possible, but rarely used, is "big endian" or MSB (Most Significant Bit) first serial communications. The order of bits is not usually configurable.

 Parity

Parity is a method of detecting some errors in transmission. Where parity is used with a serial port, an extra data bit is sent with each data character, arranged so that the number of 1 bits in each character, including the parity bit, is always odd or always even. If a byte is received with the wrong number of 1 bits, then it must have been corrupted. If parity is correct there may have been no errors or an even number of errors. Electromechanical teleprinters were arranged to print a special character when received data contained a parity error, to allow detection of messages damaged by line noise. A single parity bit does not allow implementation of error correction on each character, and communication protocols working over serial data links will have higher-level mechanisms to ensure data validity and request retransmission of data that has been incorrectly received.

The parity bit in each character can be set to none (N), odd (O), even (E), mark (M), or space (S). None means that no parity bit is sent at all. Mark parity means that the parity bit is always set to the mark signal condition (logical 1) and likewise space parity always sends the parity bit in the space signal condition. Aside from uncommon applications that use the 9th (parity) bit for some form of addressing or special signalling, mark or space parity is uncommon, as it adds no error detection information. Odd parity is more common than even, since it ensures that at least one state transition occurs in each character, which makes it more reliable. The most common parity setting, however, is "none", with error detection handled by a communication protocol.

 Stop bits

Stop bits sent at the end of every character allow the receiving signal hardware detect the end of a character and to resynchronise with the character stream. Electronic devices usually use one stop bit. Occasionally, and especially if slow electromechanical devices are used, such as teleprinters, one-and-one half or two stop bits are required. A stop bit is a way to indicate the end of a byte of data.

 Conventional notation

The D/P/S conventional notation specifies the framing of a serial connection. The most common usage on microcomputers is 8/N/1 (8N1). This specifies 8 data bits, no parity, 1 stop bit.

In this notation, the parity bit is not included in the data bits. 7/E/1 (7E1) means that an even parity bit is added to the seven data bits for a total of eight bits between the start and stop bits. If a receiver of a 7/E/1 stream is expecting an 8/N/1 stream, half the possible bytes will be interpreted as having the high bit set.

 Flow control

A serial port may use signals in the interface to pause and resume the transmission of data. For example, a slow printer might need to handshake with the serial port to indicate that data should be paused while the mechanism advances a line. Common hardware handshake signals use the RS-232 RTS/CTS, DTR/DSR signal circuits. See the separate article on transmit flow control.

Another method of flow control may use special characters such as XON/XOFF to control the flow of data. The XON/XOFF characters are sent by the receiver to the sender to control when the sender will send data, that is, these characters go in the opposite direction to the data being sent. The XON character tells the sender that the receiver is ready for more data. The XOFF character tells the sender to stop sending characters until the receiver is ready again.

If the control characters are part of the data stream, they must be sent as part of an escape sequence to prevent data from being interpreted as flow control. Since no extra signal circuits are required, XON/XOFF flow control can be done on a 3 wire interface.

All computer operating systems in use today support serial ports, because serial ports have been around for decades. Parallel ports are a more recent invention and are much faster than serial ports. USB ports are only a few years old, and will likely replace both serial and parallel ports completely over the next several years.

The name "serial" comes from the fact that a serial port "serializes" data. That is, it takes a byte of data and transmits the 8 bits in the byte one at a time. The advantage is that a serial port needs only one wire to transmit the 8 bits (while a parallel port needs 8). The disadvantage is that it takes 8 times longer to transmit the data than it would if there were 8 wires. Serial ports lower cable costs and make cables smaller.

Before each byte of data, a serial port sends a start bit, which is a single bit with a value of 0. After each byte of data, it sends a stop bit to signal that the byte is complete. It may also send a parity bit.

Serial ports, also called communication (COM) ports, are bi-directional. Bi-directional communication allows each device to receive data as well as transmit it. Serial devices use different pins to receive and transmit data -- using the same pins would limit communication to half-duplex, meaning that information could only travel in one direction at a time. Using different pins allows for full-duplex communication, in which information can travel in both directions at once.


This 40-pin Dual Inline Package (DIP) chip is a variation of the National Semiconductor NS16550D UART chip.

Serial ports rely on a special controller chip, the Universal Asynchronous Receiver/Transmitter (UART), to function properly. The UART chip takes the parallel output of the computer's system bus and transforms it into serial form for transmission through the serial port. In order to function faster, most UART chips have a built-in buffer of anywhere from 16 to 64 kilobytes. This buffer allows the chip to cache data coming in from the system bus while it is processing data going out to the serial port. While most standard serial ports have a maximum transfer rate of 115 Kbps (kilobits per second), high speed serial ports, such as Enhanced Serial Port (ESP) and Super Enhanced Serial Port (Super ESP), can reach data transfer rates of 460 Kbps.

The Serial Connection

The external connector for a serial port can be either 9 pins or 25 pins. Originally, the primary use of a serial port was to connect a modem to your computer. The pin assignments reflect that. Let's take a closer look at what happens at each pin when a modem is connected.


Close-up of 9-pin and 25-pin serial connectors

9-pin connector:

  1. Carrier Detect - Determines if the modem is connected to a working phone line.
  2. Receive Data - Computer receives information sent from the modem.
  3. Transmit Data - Computer sends information to the modem.
  4. Data Terminal Ready - Computer tells the modem that it is ready to talk.
  5. Signal Ground - Pin is grounded.
  6. Data Set Ready - Modem tells the computer that it is ready to talk.
  7. Request To Send - Computer asks the modem if it can send information.
  8. Clear To Send - Modem tells the computer that it can send information.
  9. Ring Indicator - Once a call has been placed, computer acknowledges signal (sent from modem) that a ring is detected.

25-pin connector:

  1. Not Used
  2. Transmit Data - Computer sends information to the modem.
  3. Receive Data - Computer receives information sent from the modem.
  4. Request To Send - Computer asks the modem if it can send information.
  5. Clear To Send - Modem tells the computer that it can send information.
  6. Data Set Ready - Modem tells the computer that it is ready to talk.
  7. Signal Ground - Pin is grounded.
  8. Received Line Signal Detector - Determines if the modem is connected to a working phone line.
  9. Not Used: Transmit Current Loop Return (+)
  10. Not Used
  11. Not Used: Transmit Current Loop Data (-)
  12. Not Used
  13. Not Used
  14. Not Used
  15. Not Used
  16. Not Used
  17. Not Used
  18. Not Used: Receive Current Loop Data (+)
  19. Not Used
  20. Data Terminal Ready - Computer tells the modem that it is ready to talk.
  21. Not Used
  22. Ring Indicator - Once a call has been placed, computer acknowledges signal (sent from modem) that a ring is detected.
  23. Not Used
  24. Not Used
  25. Not Used: Receive Current Loop Return (-)

Voltage sent over the pins can be in one of two states, On or Off. On (binary value "1") means that the pin is transmitting a signal between -3 and -25 volts, while Off (binary value "0") means that it is transmitting a signal between +3 and +25 volts...

An important aspect of serial communications is the concept of flow control. This is the ability of one device to tell another device to stop sending data for a while. The commands Request to Send (RTS), Clear To Send (CTS), Data Terminal Ready (DTR) and Data Set Ready (DSR) are used to enable flow control.

    1. When a PC sends data to a printer or other device using a parallel port, it sends 8 bits of data (1 byte) at a time. These 8 bits are transmitted parallel to each other, as opposed to the same eight bits being transmitted serially (all in a single row) through a serial port. The standard parallel port is capable of sending 50 to 100 kilobytes of data per second.

Parallel Port Basics

Parallel ports were originally developed by IBM as a way to connect a printer to your PC. When IBM was in the process of designing the PC, the company wanted the computer to work with printers offered by Centronics, a top printer manufacturer at the time. IBM decided not to use the same port interface on the computer that Centronics used on the printer.

The original specification for parallel ports was unidirectional, meaning that data only traveled in one direction for each pin. With the introduction of the PS/2 in 1987, IBM offered a new bidirectional parallel port design. This mode is commonly known as Standard Parallel Port (SPP) and has completely replaced the original design. Bidirectional communication allows each device to receive data as well as transmit it. Many devices use the eight pins (2 through 9) originally designated for data. Using the same eight pins limits communication to half-duplex, meaning that information can only travel in one direction at a time. But pins 18 through 25, originally just used as grounds, can be used as data pins also. This allows for full-duplex (both directions at the same time) communication.

Enhanced Parallel Port (EPP) was created by Intel, Xircom and Zenith in 1991. EPP allows for much more data, 500 kilobytes to 2 megabytes, to be transferred each second. It was targeted specifically for non-printer devices that would attach to the parallel port, particularly storage devices that needed the highest possible transfer rate.

Instead, IBM engineers coupled a 25-pin connector, DB-25, with a 36-pin Centronics connector to create a special cable to connect the printer to the computer. Other printer manufacturers ended up adopting the Centronics interface, making this strange hybrid cable an unlikely de facto standard.

When a PC sends data to a printer or other device using a parallel port, it sends 8 bits of data (1 byte) at a time. These 8 bits are transmitted parallel to each other, as opposed to the same eight bits being transmitted serially (all in a single row) through a serial port. The standard parallel port is capable of sending 50 to 100 kilobytes of data per second.

Let's take a closer look at what each pin does when used with a printer:

Notice how the first 25 pins on the Centronics end match up with the pins of the first connector. With each byte the parallel port sends out, a handshaking signal is also sent so that the printer can latch the byte.

Close on the heels of the introduction of EPP, Microsoft and Hewlett Packard jointly announced a specification called Extended Capabilities Port (ECP) in 1992. While EPP was geared toward other devices, ECP was designed to provide improved speed and functionality for printers.

In 1994, the IEEE 1284 standard was released. It included the two specifications for parallel port devices, EPP and ECP. In order for them to work, both the operating system and the device must support the required specification. This is seldom a problem today since most computers support SPP, ECP and EPP and will detect which mode needs to be used, depending on the attached device. If you need to manually select a mode, you can do so through the BIOS on most computers.