Serial Port Communication Software

Find the manual for your serial device to determine what the baud rate and communications parameters should be (yes, I know we all hate to read the manual!). If you have multiple serial ports on your PC, change the serial port within ComTestSerial to determine which serial port your device is connected to.

A maleD-subminiature connector used for a serial port on an IBM PC compatible computer along with the serial port symbol.
  1. This serial port communication software does not require any additional hardware to perform its functionality. Advantages offered by Serial Port Monitor (SPM): Collect data; RS232 communication program monitors and collects all data transmitted through serial ports.
  2. Arduino and Genuino boards have built in support for serial communication on pins 0 and 1, but what if you need more serial ports? The SoftwareSerial Library has been developed to allow serial communication to take place on the other digital pins of your boards, using software to replicate the functionality of the hardwired RX and TX lines.
  3. If you are looking for complete software solution to view serial port communication traffic and explore serial protocol packets data, Free Serial Analyzer is what you need. This serial port monitoring tool requires no additional hardware and allows you to debug protocol errors, view and test device failures.
  4. HHD Software Free Serial Port Monitor - RS232/422/485 Communication Software Data Sniffer and Analyzer. Analyze Your Com Port Communication Data Traffic. Freeware Modem Data Capture Utility, Connection Test Tool Packet Analyser.

In computing, a serial port is a serial communication interface through which information transfers in or out one bit at a time (in contrast to a parallel port).[1] Throughout most of the history of personal computers, data was transferred through serial ports to devices such as modems, terminals, and various peripherals.

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

Modern computers without serial ports may require USB-to-serial converters to allow compatibility with RS-232 serial devices. Serial ports are still used in applications such as industrial automation systems, scientific instruments, point of sale systems and some industrial and consumer products. Server computers may use a serial port as a control console for diagnostics. Network equipment (such as routers and switches) often use serial console for configuration. Serial ports are still used in these areas as they are simple, cheap and their console functions are highly standardized and widespread. A serial port requires very little supporting software from the host system.

  • 1Hardware
  • 3Settings

Hardware[edit]

Some computers, such as the IBM PC, use an integrated circuit called a UART. This IC converts characters to and from asynchronous serial form, implementing the timing and framing of data in hardware. Very low-cost systems, such as some early home computers, would instead use the CPU to send the data through an output pin, using the bit banging technique. Before large-scale integration (LSI) UART integrated circuits were common, a minicomputer would have a serial port made of multiple small-scale integrated circuits to implement shift registers, logic gates, counters, and all the other logic for a serial port.

Early home computers often had proprietary serial ports with pinouts and voltage levels incompatible with RS-232. Inter-operation with RS-232 devices may be impossible as the serial port cannot withstand the voltage levels produced and may have other differences that 'lock in' the user to products of a particular manufacturer.

Low-cost processors now allow higher-speed, but more complex, serial communication standards such as USB and FireWire to replace RS-232. These make it possible to connect devices that would not have operated feasibly over slower serial connections, such as mass storage, sound, and video devices.

Many personal computer motherboards still have at least one serial port, even if accessible only through a pin header. Small-form-factor systems and laptops may omit RS-232 connector ports to conserve space, but the electronics are still there. RS-232 has been standard for so long that the circuits needed to control a serial port became very cheap and often exist on a single chip, sometimes also with circuitry for a parallel port.

IBM PC Serial Card with a 25-pin connector (obsolete 8-bit ISA card)
A PCI Express ×1 card with one serial port
A four-port serial (RS-232) PCI Express ×1 expansion card with an octopus cable that breaks the card's DC-37 connector into four standard DE-9 connectors
A converter from USB to an RS-232 compatible serial port; more than a physical transition, it requires a driver in the host system software and a built-in processor to emulate the functions of the IBM XT compatible serial port hardware.

DTE and DCE[edit]

The individual signals on a serial port are unidirectional and when connecting two devices the outputs of one device must be connected to the inputs of the other. Devices are divided into two categories data terminal equipment (DTE) and data circuit-terminating equipment (DCE). A line that is an output on a DTE device is an input on a DCE device and vice versa so a DCE device can be connected to a DTE device with a straight wired cable. Conventionally, computers and terminals are DTE while modems and peripherals are DCE.

If it is necessary to connect two DTE devices (or two DCE devices but that is more unusual) a cross-over null modem, in the form of either an adapter or a cable, must be used.

Male and female[edit]

DE-9 gender changers, showing both male (visible on the left) and female DE-9 connectors (visible on the right)

Generally, serial port connectors are gendered, only allowing connectors to mate with a connector of the opposite gender. With D-subminiature connectors, the male connectors have protruding pins, and female connectors have corresponding round sockets.[2] Either type of connector can be mounted on equipment or a panel; or terminate a cable.

Connectors mounted on DTE are likely to be male, and those mounted on DCE are likely to be female (with the cable connectors being the opposite). However, this is far from universal; for instance, most serial printers have a female DB25 connector, but they are DTEs.[3]

Connectors[edit]

While the RS-232 standard originally specified a 25-pin D-type connector, many designers of personal computers chose to implement only a subset of the full standard: they traded off compatibility with the standard against the use of less costly and more compact connectors (in particular the DE-9 version used by the original IBM PC-AT). The desire to supply serial interface cards with two ports required that IBM reduce the size of the connector to fit onto a single card back panel. A DE-9 connector also fits onto a card with a second DB-25 connector. Starting around the time of the introduction of the IBM PC-AT, serial ports were commonly built with a 9-pin connector to save cost and space. However, presence of a 9-pin D-subminiature connector is not sufficient to indicate the connection is in fact a serial port, since this connector is also used for video, joysticks, and other purposes.

Some miniaturized electronics, particularly graphing calculators and hand-held amateur and two-way radio equipment, have serial ports using a phone connector, usually the smaller 2.5 or 3.5 mm connectors and use the most basic 3-wire interface.

Serial Port Communication Software

Many models of Macintosh favor the related RS-422 standard, mostly using German mini-DIN connectors, except in the earliest models. The Macintosh included a standard set of two ports for connection to a printer and a modem, but some PowerBook laptops had only one combined port to save space.

Since most devices do not use all of the 20 signals that are defined by the standard, smaller connectors are often used. For example, the 9-pin DE-9 connector is used by most IBM-compatible PCs since the IBM PC AT, and has been standardized as TIA-574. More recently, modular connectors have been used. Most common are 8P8C connectors, for which the EIA/TIA-561 standard defines a pinout, while the 'Yost Serial Device Wiring Standard'[4] invented by Dave Yost (and popularized by the Unix System Administration Handbook) is common on Unix computers and newer devices from Cisco Systems. 10P10C connectors can be found on some devices as well. Digital Equipment Corporation defined their own DECconnect connection system which is based on the Modified Modular Jack (MMJ) connector. This is a 6-pin modular jack where the key is offset from the center position. As with the Yost standard, DECconnect uses a symmetrical pin layout which enables the direct connection between two DTEs. Another common connector is the DH10 header connector common on motherboards and add-in cards which is usually converted via a cable to the more standard 9-pin DE-9 connector (and frequently mounted on a free slot plate or other part of the housing).

9-pin to 25-pin D-type adapter cable
Pair of femaleMini DIN-8 connectors used for RS-422 serial ports on a Macintosh LC computer
A Hirose 3560-16S used for RS-232 on a Tatung TWN-5213 CU tablet computer. Below is a mating 3540-16P-CV connector.

Pinouts[edit]

The following table lists commonly used RS-232 signals and pin assignments.[5]

SignalDirectionConnector pin
NameV.24 [de] circuitAbbreviationDTEDCEDB-25DE-9
(TIA-574)
MMJ8P8C ('RJ45')10P10C ('RJ50')
EIA/TIA-561Yost (DTE)Yost (DCE)Cyclades[6]Digi (ALTPIN option)[7]National Instruments[8]Cyclades[6]Digi[9]
Transmitted Data103TxDOutIn23266334845
Received Data104RxDInOut32553665976
Data Terminal Ready108/2DTROutIn204137228739
Data Carrier Detect109DCDInOut81N/A2277110810
Data Set Ready107DSRInOut6661N/A8N/A592
Ring Indicator125RIInOut229N/AN/AN/AN/AN/A2101
Request To Send105RTSOutIn47N/A88112423
Clear To Send106CTSInOut58N/A71857368
Signal Ground102GCommon753, 444, 54, 546657
Protective Ground101PGCommon1N/AN/AN/AN/AN/AN/A3N/A14

The signal ground is a common return for the other connections; it appears on two pins in the Yost standard but is the same signal. The DB-25 connector includes a second 'protective ground' on pin 1, which is intended to be connected by each device to its own frame ground or similar. Connecting this to pin 7 (signal reference ground) is a common practice but not recommended.

Note that EIA/TIA 561 combines DSR and RI,[10][11] and the Yost standard combines DSR and DCD.

Powered serial port[edit]

Some serial ports on motherboards or add-in cards provide jumpers that select whether pin 1 of the DE-9 connector connects to DCD or a power supply voltage, and whether pin 9 of the DE-9 connector connects to RI or a power supply voltage. The power supply voltage can be +5V, +12V, +9V, or ground. (Selection varies by vendor.) The power is intended for use by point-of-sale equipment. Makers include Dell[12], HP, and others[13] (This is not an official standard.)

Hardware abstraction[edit]

Operating systems usually create symbolic names for the serial ports of a computer, rather than requiring programs to refer to them by hardware address.

Unix-like operating systems usually label the serial port devices /dev/tty*. TTY is a common trademark-free abbreviation for teletype, a device commonly attached to early computers' serial ports, and * represents a string identifying the specific port; the syntax of that string depends on the operating system and the device. On Linux, 8250/16550 UART hardware serial ports are named /dev/ttyS*, USB adapters appear as /dev/ttyUSB* and various types of virtual serial ports do not necessarily have names starting with tty.

The DOS and Windows environments refer to serial ports as COM ports: COM1, COM2,.etc. Ports numbered greater than COM9 should be referred to using the .COM10 syntax.[14]

Common applications for serial ports[edit]

The RS-232 standard is used by many specialized and custom-built devices. This list includes some of the more common devices that are connected to the serial port on a PC. Some of these such as modems and serial mice are falling into disuse while others are readily available.

Serial ports are very common on most types of microcontroller, where they can be used to communicate with a PC or other serial devices.

  • Dial-up modems
  • Configuration and management of networking equipment such as routers, switches, firewalls, load balancers
  • GPS receivers (typically NMEA 0183 at 4,800 bit/s)
  • Bar code scanners and other point of sale devices
  • LED and LCD text displays
  • Satellite phones, low-speed satellite modems and other satellite based transceiver devices
  • Flat-screen (LCD and Plasma) monitors to control screen functions by external computer, other AV components or remotes
  • Test and measuring equipment such as digital multimeters and weighing systems
  • Updating firmware on various consumer devices.
  • Hobbyist programming and debugging MCU's
  • Stenography or Stenotype machines
  • Software debuggers that run on a second computer
  • Industrial field buses
  • Computer terminal, teletype
  • Older digital cameras
  • Networking (Macintosh AppleTalk using RS-422 at 230.4 kbit/s)
  • Older GSMmobile phones
  • IDEhard drive[15][16]repair[17][18]

Since the control signals for a serial port can be easily turned on and off by a switch, some applications used the control lines of a serial port to monitor external devices, without exchanging serial data. A common commercial application of this principle was for some models of uninterruptible power supply which used the control lines to signal loss of power, low battery, and other status information. At least some Morse code training software used a code key connected to the serial port, to simulate actual code use. The status bits of the serial port could be sampled very rapidly and at predictable times, making it possible for the software to decipher Morse code.

Settings[edit]

Common serial port speeds
Bit rate
(Baud rate)
Time
per bit
Windows predefined
serial port speed[19][20]
Other reasons that this speed is common
50 bit/s20000 μsNoListed in PC16550D datasheet[21]
75 bit/s13333.3 μsYes
110 bit/s9090.9 μsYesBell 101 modem
134.5 bit/s7434.9 μsYes
150 bit/s6666.6 μsYes
300 bit/s3333.3 μsYesBell 103 modem or V.21
600 bit/s1666.7 μsYes
1,200 bit/s833.3 μsYesBell 202, Bell 212A, or V.22 modem
1,800 bit/s555.6 μsYes
2,400 bit/s416.7 μsYesV.22bis modem
4,800 bit/s208.3 μsYesV.27ter modem
7,200 bit/s138.9 μsYes
9,600 bit/s104.2 μsYesV.32 modem
14,400 bit/s69.4 μsYesV.32bis modem
19,200 bit/s52.1 μsYes
31,250 bit/s32 μsNoMIDI port
38,400 bit/s26.0 μsYes
56,000 bit/s17.9 μsYesV.90/V.92 modem
57,600 bit/s17.4 μsYesV.32bis modem with V.42bis compression
76,800 bit/s13.0 μsNoBACnet MS/TP networks[22]
115,200 bit/s8.68 μsYesV.34 modem with V.42bis compression
low cost serial V.90/V.92 modem with V.42bis or V.44 compression
128,000 bit/s7.81 μsYes
230,400 bit/s4.34 μsNoLocalTalk
high end serial V.90/V.92 modem with V.42bis or V.44 compression[23][24]
256,000 bit/s3.91 μsYes
460,800 bit/s2.17 μsNo[citation needed]

Many settings are required for serial connections used for asynchronous start-stop communication, to select 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 cannot and need not change the configuration; the speed is either fixed or automatically negotiated. Often if the settings are entered incorrectly the connection will not be dropped; however, any data sent will be received on the other end as nonsense.

Speed[edit]

Serial ports use two-level (binary) signaling, so the data rate in bits per second is equal to the symbol rate in baud. A standard series of rates is based on multiples of the rates for electromechanical teleprinters; some serial ports allow many arbitrary rates to be selected. The port speed and device speed must match. 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, use serial data rates other than the teleprinter series. Some serial port systems can automatically detect the bit rate.

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, with 8-N-1 character framing only 80% of the bits are available for data (for every eight bits of data, two more framing bits are sent).

Bit rates commonly supported include 75, 110, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600 and 115200 bit/s.[20]

Crystal oscillators with a frequency of 1.843200 MHz are sold specifically for this purpose. This is 16 times the fastest bit rate and the serial port circuit can easily divide this down to lower frequencies as required.

Data bits[edit]

The number of data bits in each character can be 5 (for Baudot code), 6 (rarely used), 7 (for true ASCII), 8 (for most kinds of data, as this size 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; this was used, for example, by the IBM 2741 printing terminal. (See Bit numbering for more about bit ordering.) The order of bits is not usually configurable within the serial port interface. To communicate with systems that require a different bit ordering than the local default, local software can re-order the bits within each byte just before sending and just after receiving.

Parity[edit]

Parity is a method of detecting errors in transmission. Java serialization performance. When 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 1s, then it must have been corrupted. However, an even number of errors can pass the parity check.

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 one of the following:

  • None (N) means that no parity bit is sent at all.
  • Odd (O) means that parity bit is set so that the number of 'logical ones' must be odd.
  • Even (E) means that parity bit is set so that the number of 'logical ones' must be even.
  • Mark (M) parity means that the parity bit is always set to the mark signal condition (logical 1).
  • Space (S) parity always sends the parity bit in the space signal condition (logical 0).

Aside from uncommon applications that use the last bit (usually the 9th) for some form of addressing or special signaling, mark or space parity is uncommon, as it adds no error detection information. Odd parity is more useful 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[edit]

Stop bits sent at the end of every character allow the receiving signal hardware to detect the end of a character and to resynchronise with the character stream. Electronic devices usually use one stop bit. If slow electromechanical teleprinters are used, one-and-one half or two stop bits are required.

Conventional notation[edit]

The data/parity/stop (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 7 data bits for a total of 8 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[edit]

In many circumstances a transmitter might be able to send data faster than the receiver is able to process it. To cope with this, serial lines often incorporate a 'handshaking' method, usually distinguished between hardware and software handshaking.

Hardware handshaking is done with extra signals, often the RS-232 RTS/CTS or DTR/DSR signal circuits. Generally, the RTS and CTS are turned off and on from alternate ends to control data flow, for instance when a buffer is almost full. DTR and DSR are usually on all the time and, per the RS-232 standard and its successors, are used to signal from each end that the other equipment is actually present and powered-up. However, manufacturers have over the years built many devices that implemented non-standard variations on the standard, for example, printers that use DTR as flow control.

Software handshaking is done for example with ASCIIcontrol charactersXON/XOFF to control the flow of data. The XON and 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 circuit starts in the 'sending allowed' state. When the receiver's buffers approach capacity, the receiver sends the XOFF character to tell the sender to stop sending data. Later, after the receiver has emptied its buffers, it sends an XON character to tell the sender to resume transmission. It is an example of in-band signaling, where control information is sent over the same channel as its data.

The advantage of hardware handshaking is that it can be extremely fast; it doesn't impose any particular meaning such as ASCII on the transferred data; and it is stateless. Its disadvantage is that it requires more hardware and cabling, and these must be compatible at both ends.

The advantage of software handshaking is that it can be done with absent or incompatible hardware handshaking circuits and cabling. The disadvantage, common to all in-band control signaling, is that it introduces complexities in ensuring that a) control messages get through even when data messages are blocked, and b) data can never be mistaken for control signals. The former is normally dealt with by the operating system or device driver; the latter normally by ensuring that control codes are 'escaped' (such as in the Kermit protocol) or omitted by design (such as in ANSI terminal control).

If no handshaking is employed, an overrun receiver might simply fail to receive data from the transmitter. Approaches for preventing this include reducing the speed of the connection so that the receiver can always keep up; increasing the size of buffers so it can keep up averaged over a longer time; using delays after time-consuming operations (e.g. in termcap) or employing a mechanism to resend data which has been corrupted (e.g. TCP).

'Virtual' serial ports[edit]

A virtual serial port is an emulation of the standard serial port. This port is created by software which enable extra serial ports in an operating system without additional hardware installation (such as expansion cards, etc.). It is possible to create a large number of virtual serial ports in a PC. The only limitation is the amount of resources, such as operating memory and computing power, needed to emulate many serial ports at the same time.

Virtual serial ports emulate all hardware serial port functionality, including baud rate, data bits, parity bits, stop bits, etc. Additionally, they allow controlling the data flow, emulating all signal lines (DTR, DSR, CTS, RTS, DCD, and RI) and customizing pinout. Virtual serial ports are common with Bluetooth and are the standard way of receiving data from Bluetooth-equipped GPS modules.

Virtual serial port emulation can be useful in case there is a lack of available physical serial ports or they do not meet the current requirements. For instance, virtual serial ports can share data between several applications from one GPS device connected to a serial port. Another option is to communicate with any other serial devices via internet or LAN as if they are locally connected to computer (serial over LAN/serial-over-Ethernet technology). Two computers or applications can communicate through an emulated serial port link. Virtual serial port emulators are available for many operating systems including MacOS, Linux, NetBSD and other Unix-like operating systems, and various mobile and desktop versions of Microsoft Windows.

Best christmas songs download. 31 rows  Listen free to Various Artists – 101 Christmas Songs (Let It Snow! Let It Snow!, White Christmas and more). 101 tracks (315:49). Discover more music, concerts, videos, and pictures with the largest catalogue online at Last.fm.

See also[edit]

  • ITU-T/CCITT V.24 [de]
  • ITU-T/CCITT V.28 [de]

References[edit]

  1. ^Webopedia (2003-09-03). 'What is serial port? - A Word Definition From the Webopedia Computer Dictionary'. Webopedia.com. Retrieved 2009-08-07.
  2. ^'Serial Cable Connection Guide'. CISCO. 2006-08-01. Retrieved 2016-01-31.
  3. ^'RS232 - DTE and DCE connectors'. Lantronix. 2006-03-29. Retrieved 2016-01-31.
  4. ^Yost Serial Device Wiring Standard
  5. ^Ögren, Joakim. 'Serial (PC 9)'.
  6. ^ abCyclom-Y Installation Manual, page 38, retrieved on 29 November 2008[permanent dead link]
  7. ^'RJ-45 8-Pin to Modem (ALTPIN option)'. Digiftp.digi.com. Retrieved 2014-02-08.
  8. ^National Instruments Serial Quick Reference Guide, February 2007
  9. ^'RJ-45 10-Pin Plug to DB-25 Modem Cable'. Digiftp.digi.com. Retrieved 2014-02-08.
  10. ^Hardware Book RS-232D
  11. ^RS-232D EIA/TIA-561 RJ45 Pinout
  12. ^'OptiPlex XE Powered Serial Port Configuration'(PDF).
  13. ^'Powered Serial Cards - Brainboxes'.
  14. ^'HOWTO: Specify Serial Ports Larger than COM9'. Microsoft support. Retrieved 2013-10-26.
  15. ^'Paul's 8051 Code Library, IDE Hard Drive Interface'. Pjrc.com. 2005-02-24. Retrieved 2014-02-08.
  16. ^'IDE Hard Disk experiments'. Hem.passagen.se. 2004-02-15. Archived from the original on 2004-04-15. Retrieved 2014-02-08.
  17. ^'The Solution for Seagate 7200.11 HDDs - Hard Drive and Removable Media issues - MSFN Forum'. Msfn.org. Retrieved 2014-02-08.
  18. ^'Fixing a Seagate 7200.11 Hard Drive'. Sites.google.com. Retrieved 2014-02-08.
  19. ^'SERIAL_COMMPROP structure'. Microsoft. 2018-04-22. Retrieved 2019-09-28.
  20. ^ ab'DCB Structure'. Windows Dev Center. Microsoft. 2018-12-04. Retrieved 2019-09-28.
  21. ^'PC16550D Universal Asynchronous Receiver/Transmitter With FIFOs'(PDF). Texas Instruments. May 2015. Retrieved September 25, 2019.
  22. ^'BACnet MS/TP Overview Manual'(PDF). Neptronic. Retrieved September 26, 2019.
  23. ^'MultiModem ZBA'(PDF). Multi-Tech Systems, Inc. January 2019. Retrieved September 26, 2019.
  24. ^'Courier 56K Business Modem: User Guide: Controlling Data Rates'. USRobotics. 2007. Retrieved September 26, 2019.

Further reading[edit]

  • Serial Port Complete: COM Ports, USB Virtual COM Ports, and Ports for Embedded Systems; 2nd Edition; Jan Axelson; Lakeview Research; 380 pages; 2007; ISBN978-1-931-44806-2.

External links[edit]

Wikibooks has a book on the topic of: Programming:Serial Data Communications
Retrieved from 'https://en.wikipedia.org/w/index.php?title=Serial_port&oldid=918343010'

This article tells you just about everything you need to know to get a RS232 connection working between your computer and your measuring device or instrument. It starts by discussing the RS232 standard and continues with the various pin connections available. The next section gives a step-by-step guide to getting communications working: testing the different elements of the system. Finally there are suggestions for further reading and you are invited to send us your comments or questions.

The Ins and Outs of RS232 Testing Serial Port Communication Status of the COM Port Lines DTR High: Removing Handshaking Further Reading Comments or Questions?

RS232 Connections

RS stands for recommended standard. In the 60's a standards committee now known as the Electronic Industries Association developed an interface to connect computer terminals to modems. Over the years this has been updated: the most commonly used version of the standard is RS232C (sometimes known as EIA232); the most recent is RS232E. The standard defines the electrical and mechanical characteristics of the connection - including the function of the signals and handshake pins, the voltage levels and maximum bit rate.

If RS232 is a standard why can't I just use a standard lead to connect together two RS232 ports and expect them to talk to one another? That's a good question. The answer is that the RS232 standard was created for just one specific situation and the difficulties come when it is used for something else. The standard was defined to connect computers to modems. Any other use is outside of the standard. The authors of the standard had in mind the situation below:

The standard defines how computers (it calls them Data Terminal Equipment or DTEs) connect to modems (it calls them Data Communication Equipment or DCEs). The standard says that computers should be fitted with a 25 way plug whilst modems should have a 25 way D socket. The interconnecting lead between a computer and a modem should be simply pin1-pin1, pin2-pin2, etc. The main signals and their direction of flow are described below. It is important to note that a signal which is an output from a computer is an input to a modem and vice versa. This means that you can never tell from the signal name alone whether it is an input or an output from a particular piece of equipment. Also, instead of being a DCE device, a data acquisition device might be configured as DTE. In this case you need an adaptor or the RS232 cable wired differently to normal. When the PC is connected to a DTE instrument - called a null modem arrangement - some of the cable wires must cross over.

RS232 Pin Connections

TXD Transmitted Data, Pin 2 of 25 way D
This is the serial encoded data sent from a computer to a device.

RXD Received Data, Pin 3 of 25 way D
This is the serial encoded data received by a computer from a device.

DSR Data Set Ready, Pin 6 of 25 way D
This should be set true by a device whenever it is powered on. It can be read by the computer to determine that the device is on line.

DTR Data Terminal Ready, Pin 20 of 25 way D
This should be set true by a computer whenever it is powered on. It can be read by the device to determine that the computer is on line.

RTS Request to Send, Pin 4 of 25 way D
This is set true by a computer when it wishes to transmit data.

CTS Clear To Send, Pin 5 of 25 Way D
This is set true by a device to allow the computer to transmit data. The standard envisaged that when a computer wished to transmit data it would set its RTS. The local modem would then arbitrate with the distant modem for use of the telephone line. If it succeeded it would set CTS and the computer would transmit data. The distant modem would use its CTS to prevent any transmission by the distant computer.

DCD Data Carrier Detect, Pin 8 of 25 Way D
This is set true by a modem when it detects the data carrier signal on the telephone line.

PC Serial Ports (DTE)
A nine pin D plug has become the standard fitting for the serial ports of PCs, although it's nothing to do with the RS232 standard. The pin connections used are:

Pin DirectionSignal
1 InputDCD Data Carrier Detect
2 InputRXD Received Data
3 OutputTXD Transmitted Data
4 Output DTR Data Terminal Ready
5 Signal Ground
6 Input DSR Data Set Ready
7 Output RTS Request To Send
8 InputCTS Clear To Send
9 Input RI Ring Indicator

9-Way Pin to 25-Way Pin

DB9 DB25 Signal
1 8 DCD Data Carrier Detect
2 3 RXD Received Data
3 2 TXD Transmitted Data
4 20 DTR Data Terminal Ready
5 7 Signal Ground
6 6 DSR Data Set Ready
7 4 RTS Request To Send
8 5 CTS Clear To Send
9 22 RI Ring Indicator

Null Modem Connections
Instead of being a DCE device (see above for details), a data acquisition device might be configured as DTE. In this case you need an adaptor or the RS232 cable wired differently to normal. When the PC is connected to a DTE instrument - called a null modem arrangement - some of the cable wires must cross over. For example, when there is no hardware handshaking in place the connections are as follows.

DB9 DB9 Signal
23RXD Received Data - TXD Transmitted Data
32TXD Transmitted Data - RXD Received Data
55Signal Ground

Testing Serial Port Communication

You've plugged your instrument into your computer's COMport, installed your data acquisition software, but nodata appears. You suspect it is a problem with yourRS232 communications. What do you do?

Download the free ComDebug serial port monitor software. This provides many features which let you detect, and correct, communication errors. Please note that we can't offer free technical support for the free software - if you need help using it click the program's Help button or see this web page.

If you can't immediately obtain data from your device with ComDebug, follow these steps.

1. Find Communication Details: Baud Rate etc.

Obtain all the information available about your instrument or device. You will need to know the number of the com port into which you have plugged your device, the device baud rate, number of bits in the data byte and parity. Enter this information in ComDebug. If you have information about the Stop Bits then use it, otherwise set them to 2. This will at worse slow the message down slightly. See Making Measurements through the COM Port for a detailed explanation of each of these settings.

If you are using a virtual com port, for example with a USB-RS232 adaptor, open the Device Manager from Windows Control Panel to find the number of the com port that Windows has assigned to your device. Tips on Using USB-to-Serial Converters gives more information.

2. Send a message

If you can persuade your device to send a message, perhaps a power on message or a message that can be initiated by a button press, then do so. This will verify your signal connections. At this stage you should select the no handshake option when setting up the COM Port. If you still can't receive any data, you may have a wiring error. Use the ComDebug program's COM Port Status window to check the state of the lines to and from the computer, and see points 3, 4 and 5 below.

3. Check the COM port is Working Correctly

This loopback test works if your instrument is a DTE computer type with a 9-pin connector. (See above for more onDTE type instruments).

  1. Disconnect the RS232 cable fromyour instrument and check it has a socket on the freeend.
  2. Unravel a paperclip, insert one end into thepin 2 hole on the cable socket and the other into thepin 3 hole. (Pin 1 is to the right of the long edge,pin 2 is next to it.)
  3. Send a message. Itshould echo back to the computer, confirming that messages are arriving at your instrument and the COM port is working correctly.

4. Check the Cabling

If you suspect a wiring error, you could try contactingthe manufacturer of your instrument to see if they sellthe correct cable. Sartorius devices, for example,won't work with a standard RS232 cable and you need toeither purchase a cable from the company or re-wire theconnections. If your instrument is a DTE computer type,you may need a Null Modem adaptor. Alternatively, you may want to try rewiring thecable connector yourself.

When wiring the cable yourself, The first signals to connect are the ground, RXD and TXD. Try to establish, from your device's documentation, which signal wire carries its output data - connect this to the computer's RXD. The signal which inputs data to your device should be connected to the computer's TXD. Don't rely on the signal names, remember the signals can be either inputs or outputs depending on whether your device is a computer or modem type. It's not unusual for Instrument Manuals to neglect this vital information, but you may be able to get a clue from other signals. For instance if the manual says that DTR is an output then the instrument should be a computer type. If on the other hand it says that DSR is an output then it should be a modem type. In fact if you know the direction of any one of the signals you should be able to deduce the rest. Be careful when doing this: we have encountered manufacturers who change the names of the data signals when dealing with modem types - after all it must be confusing to tell a user that Transmitted Data is an input.
If the signals are correctly named then a computer to modem link connects TXD to TXD and RXD to RXD. A computer to computer link (more common when dealing with instruments) connects TXD to RXD and RXD to TXD. This crossed arrangement is sometimes called a Null Modem connection, and buying an adaptor may solve your wiring problems.

If all else fails you can determine which data signal is the output by measuring the unconnected data lines with a voltmeter or using one of the plugs with built in LED indicators which show the line state. The output signal will be at a definite negative voltage, properly -12 Volts or more. The input line will be close to 0V. The only time this strategy will fail is if your device is of the multidrop variety. These only drive the output line for the duration of the transmitted message.

5. Set Hardware Handshaking or Flow Control

If you are confident that the signal wires are properly connected, but you still can't retrieve a message from your instrument, you may need to tie the handshake lines.

Handshake arrangements can be used for 2 purposes. Firstly the computer can prevent the device from sending data when it is not able to receive it. Secondly the device can prevent the computer from sending data when it is not ready for it. The fact that your device comes equipped with inputs and outputs that can be used for handshaking is no guarantee that handshaking is needed. The signals are often provided simply because the processor used in the device provides them, so the manufacturer feels he may as well put them on the plug. It is usually best to start with the intention of tieing any potential handshake lines to fixed voltages so that they do not affect operation. In fact many manufacturers add tieing resistors to handshake lines so that if you do not want to use them you simply make no connection.

Freeware Serial Port Communication Software

If you start with no handshaking what symptoms might indicate that it really is needed ?. Well one possibility is that the computer misses part of a message because its input buffer overflows. In COMIML the buffers are 3000 bytes long so you are unlikely to be bothered by this problem. The other possibility is that the device misses part of a message sent by the computer. This will presumably cause the device not to operate as desired. If you do decide that handshaking must be used then COMIML uses DTR / CTS handshaking. This means that the computer uses its DTR output to indicate when it is able to receive data and its CTS input can be controlled by the device to prevent transmission of data from the computer. Once you select the hardware handshake option the state of the CTS input to the computer becomes important. When hardware handshake is not selected the CTS line state is ignored, the DTR output however is maintained permanently high so you can use it to tie unused inputs on your device. If your instrument needs DTR to be low, see below.

6. Set Software Handshaking or Flow Control

Xon Xoff Handshaking is a software protocol that is often used to control data flow. Supposing that the computer were sending data to a device which could accept no more data for the time being - the device would send the single Xoff character to the computer which would stop sending data until it received an Xon character to restart transmission. The same arrangements would apply for the reverse direction of data flow. If your device requires this type of handshaking then simply select it in ComDebug.

Status of the COM Port Lines: Serial Port Software

In ComDebug's Terminal screen, select the Status button. This shows you the state of the computer's COM port. If you are not receiving replies from the instrument this may help you identify the problem
Red indicates true or high, green false or low.

Rs232 Monitor Serial Port Communication Software

CTS - Clear To Send
If you are using Hardware Flow Control in your COM Settings, CTS must be true.
DCD - Data Carrier Detect
Should have no effect on data flow and will normally be false. If it is true you may have a wiring error.
DSR - Data Set Ready
Should have no effect on data flow and will normally be false. If it is true you may have a wiring error.
RI - Ring Indicator
Should have no effect on data flow and will normally be false. If it is true you may have a wiring error.

Serial Connection Software

COM Output Lines
You can control the state of these lines - check your instrument's Manual for details of the settings it expects. (Remember, red indicates true or high and green false or low.)
RTS - Request to Send
This is set true by a computer when it wishes to transmit data.
DTR - Data Terminal Ready
This should be set true by a computer whenever it is powered on. It lets the instrument check that the computer is on line.

What to do when the Instrument needs DTR Low and RTS high: Removing the Handshaking

Some software, like the Windmill COMIML serial driver, use the DTR line for handshaking (flow control), setting it high to indicate that it is ready to receive data. Some instruments, though, need DTR to be low and RTS to be high before they will provide data.

In this situation you need to change the connections on the RS232 cable.

Connect pins 8 and 7 (i.e. CTS drives RTS)
Connect pins 1, 4, 6 This should maintain the DTR line in the correct state, by connecting it to DCD and DSR

This would normally be done at the instrument end rather than the PC end of the cable.

Also check that transmit at one end goes to receive at the other.

Rs232 Serial Port Communication Software

Further Reading: