Cookie
Electronic Team, Inc. uses cookies to personalize your experience on our website. By continuing to use this site, you agree to our cookie policy. Click here to learn more.

RS-232 DB9 Pinout and Usage

Olga Weis Olga Weis Jun 22, 2020

RS-232 DB9 Overview

The RS232C DE-9, often mistakenly referred to as a DB-9 port used to be the industry standard for serial data transmission. A RS-232 serial port was a standard feature of personal computers as it was the preferred way to connect modems, keyboards, mice, external storage and many other peripheral devices.

RS232 interface

The background of the 9 pin serial port


First introduced in the 60s, RS-232 is a protocol that defines how the data is transferred, bit by bit from a Data Terminal Equipment (DTE) such as a computer terminal, to Data Communication Equipment (DCE) such as a modem.

RS-232 is the common standard used in serial ports. It defines the electrical properties and the timing of signals, as well as the interpretation of signals, and the physical size and pinout configuration of a connector.

Modern day computers seldom have RS-232 ports. Universal Serial Bus (USB) has replaced the traditional RS-232 interface. RS-232 has many shortcomings when compared to later technologies such as RS-422 , RS-485 and even Ethernet. These shortcomings include low transmission speed, limited cable length, substantial voltage fluctuations, and limited multidrop capabilities.

It is however possible to use an external USB-to-RS-232 converter or an internal expansion card with one or more serial ports to connect a RS-233 serial peripheral device to your computer. Many motherboards also feature a COM port header which makes it possible to install a bracket with a DE-9 port.

USB to RS232 COM Port Serial 9 Pin DB9 Adapter Cable Converter Interface

Despite the shortcomings and the technology advancements, RS-232 interfaces are still very much in use with large industrial machines, networking equipment and scientific instruments where point to point, low speed wired data connections is sufficient.

A PC serial port interface is single ended. This means that you can only connect two devices using a RS232 serial cable. The data that is transferred between these two devices is transferred at a rate less than 20 kbps.

RS232 allows for full-duplex communication – this means that both devices can interface with each other simultaneously. A common ground between the computer and the connected serial device is mandatory. This is represented by voltage levels defined by the RS232 protocol.

Full-duplex communication performs the best mode of transmission

With RS232, hot-plugging or hot-swapping is not supported, though it is sometimes possible to plug in a serial device and it will work while the computer is running. With current technology, only a 9-pin connector is in use with most personal computers.

Standard RS232 data packet


A RS232 transmission begins with a start bit. A start bit notifies the receiving computer of the incoming transmission. The data packets consist of 7 or 8 bit words. The start bit is generally a low voltage bit, between +3v and +15v. The data bits then follow the start bit on a LSB basis ( least significant bit ) - this is the bit with the lowest numerical value. A parity bit would generally follow the data, and then the transmission is ended with a stop bit.

An example of how RS232 serial port works with the help of the serial mouse

serial port mouse

A serial mouse comprises sensors, mouse controller, communication link, data interface, driver and software. Movement of the mouse as well as button clicks is detected by the sensors. The mouse controller takes note of the current mouse position as well as the state of the various sensors.

When this information changes, a data packet is transmitted by the mouse controller to the computer’s serial data interface controller. It is the mouse driver that is installed on the computer that receives the data packet and decodes it, then executing the appropriate action based on the instructions received.

PC RS232 serial mouse voltage levels:


A standard mouse expects a RS-232C output signal with an approximate 12V level as its input signal. The RS-232C port will have a number of output lines from which the mouse can take current (about 10mA). The mouse then sends data to the computer’s receiver chip. The data being sent must be at a level that can be understood by the receiver chip. Average mouse outputs range between +5V, -.5V and +12V. On average, a mouse will use about +5 volts to perform.

Serial device hardware implementation


A serial mouse makes use of DTR (Data Terminal Ready) and RTS (Request to send) lines to generate approximately 5V of power for its microcontroller circuit. An optomechanical mouse (one that makes use of optical sensors) that has LEDs will require power to light those LEDs.

Diodes are often used to take current from the DTR and RTS lines – intercepting the diodes and resistor. Negative supply for the transmitter is taken from the TD pin. The TD pin is the pin that carries the data from the DTE to the DCE.

A standard serial mouse takes 10 mA total current operating at a voltage range between 6 and 15 volts. The data is sent using standard asynchronous RS-232C serial format:

Standard asynchronous rs-232c graphic

An explanation of serial RS-232 mouse pinout


When DTR link is toggled, the mouse should identify itself by sending one data byte containing the letter M ( ASCII 77). For the mouse to work correctly, both RTS and DTR lines must be positive.

Ensure the DTR-DSR and RTS-CTS lines are not shorted. To implement the RTS toggle, set the RTS line to negative and then positive again. The negative pulse width is at least 100ms.

This is a cold boot, after which the RTS line will be set to negative. Setting the RTS line to a positive level is considered a RTS toggle. Here is the layout and function of the 9 pins:

DB9 Pinout Interface

Pin

Signal

Description

shellProtective Ground
3TDSerial data from host to mouse (only for power)
2RDSerial data from mouse to host
7RTS(Request to Send)Positive voltage to mouse
8CTS(Clear to Send)
6DSR (Data Set Ready)
5Signal Ground
4DTR (Data Terminal Ready)Positive voltage to mouse and reset/detection

RS232 serial data parameters and packet formats

Serial data parameters are 1200bps, 7 databits, 1 stop-bit.

A data packet consists of 3 bytes. Every time the mouse state changes, the mouse sends that packet to the computer.

Data packet paramets overview

Note: X denotes a 0 when the mouse received 7 databits and 2 stop bits format. 8 databits and 1 stop bit is also possible . When that happens, X is then 1.
The safest options is to use a 7 databits and 1 stopbit format when the mouse is receiving information. For sending information use the 7 databits and 2 stop bits format.

The bite marked with 1 is sent first, (lowest numerical value) then the others follow. Should the data transmission go out of sync, the bit D6 is the first byte for synchronizing the software to mouse packets.

LB represents the left mouse button where 1 denotes that it is pressed down.

RB is the right button.

X7 - X0 describes movement in a X direction since the last data packet transmission (signed byte)

Y7 - Y0 is movement in a Y direction since last data packet transmission (signed byte)