When to use RS232 Handshaking or Flow Control?

Software Handshaking: Xon \ Xoff | Hardware Handshaking | Removing the Handshaking | Related Topics

When connecting a measurement instrument to the PC's COM port, you may have to decide whether or not to use handshaking (also known as flow control). Although this is often not necessary, it has two functions.

  1. It allows the computer to stop your instrument from sending data when the PC is not ready for it.
  2. It allows your instrument to prevent the PC from sending data when the instrument not ready for it.
Do you need a handshake to communicate?
Do you need a handshake to communicate?

The fact that your instrument comes equipped with inputs and outputs that can be used for handshaking is no guarantee that handshaking is needed. Unless you know differently, when connecting the instrument to the PC it is best to start with the assumption that handshaking is not required.

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. With Windmill's ComDebug software the buffers are 3000 bytes long so you are unlikely to be bothered by this problem. The other possibility is that the instrument misses part of a message sent by the computer. This will probably cause the instrument not to work properly.

There are two types of handshaking: hardware and software.

Software Handshaking: Xon \ Xoff

Xon \ Xoff Handshaking is a software protocol that is often used to control data flow. Suppose that the computer were sending data to an instrument which could accept no more data for the time being - the instrument 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.

Xon is ASCII character 17 and Xoff ASCII character 19.

Hardware Handshaking

Handware handshaking is not often used: you can therefore tie any potential handshake lines to fixed voltages so that they do not affect operation. In fact many manufacturers add tying resistors to handshake lines so that if you do not want to use them you simply make no connection.

If you do decide that handshaking must be used then you need to know which lines your communications software (such as COMIML) and your instrument use. COMIML, for example, uses the DTR (Data Terminal Ready) line to indicate when it is able to receive data. Other programs may use the RTS (request to Send) line. The instrument will probably use the CTS (Clear To Send) line to indicate when it is ready to receive data. Once you select hardware handshaking in COMIML, the state of the CTS input to the computer becomes important. When hardware handshake is not selected the CTS line state is ignored. COMIML keeps the DTR output permanently high.

Our free ComDebug serial communication software lets you see, and set, the state of the DTR, RTS, CTS and other COM port lines.

Setting the state of DTR, RTS, CTS and other COM port lines.

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.

Related Topics:

Learn More

To find out more - or to ask our advice on your project - enter your details below.