User:Jeh/wip/RS232 signals

Data Terminal Ready
Data Terminal Ready, or DTR, is originated by data terminal equipment (DTE) such as a computer and interpreted by data communications equipment (DCE), for example a modem. When asserted, it indicates that the terminal is ready for communications and that the modem may initiate a communications channel. Deasserting DTR indicates to the modem that the communications session should be terminated.

A computer will typically assert the DTR signal (if it isn't already asserted) before sending commands such as "dial" commands. When a modem is being used for automatic answering, the DTR signal confirms to the modem that the computer is available to accept a call.

On many operating systems, including Windows, a serial port's DTR signal is deasserted while the serial port is not being controlled by an application.

off-spec usages

As with many aspects of RS-232, the usage and interpretation of DTR varies with the implementation in the operating system, the program or programs that use the modem, and the modem's firmware. For example, if the DTR signal is not asserted and the modem receives a "dial" command, some modems will refuse to place the call, while others will silently disable DTR support for the duration of that call. On most newer modems the modem's responses to changes in DTR can be manually overridden or configured. and higher values are used by some vendors.

Many external modems have LED indicators, one of which is labeled "TR" ("terminal ready") or similar. This follows the state of the DTR pin, illuminated when DTR is high, and off when it is low.

Null modem operation
When a serial connection is made between two computers using a null modem adapter, the DTR and the Data Set Ready (DSR) lines are typically paired. This allows each end of the connection to sense when the other end is powered up and ready to communicate.

Use for flow control
On some printers with serial interfaces, the DTR line is used for hardware flow control, similar to the use of RTS and CTS for modems. This practice is not consistent; other printers define RTS for this same purpose. The printer cable must connect the DTR or RTS pin to the computer's CTS pin in order to achieve the desired flow control.

Use as a power source
On some hardware the DTR line (along with RTS) may be used to provide power. The most notable example of this is a serial mouse. The DE-9 serial port on the PC does not provide any dedicated power source. The mouse driver holds the DTR and RTS lines high at all times so that the device has a source of power.

Another category of devices commonly powered by the DTR line includes converters between RS-232 and other serial standards such as RS-422 and RS-485.

Data Carrier Detect
Data Carrier Detect is sent "from DCE to DTE", or in a typical scenario, from the peripheral to the computer. Its purpose varies depending on the device connected, but the most typical meaning is to indicate when a modem is connected to another remote modem via telephone lines. (The word "carrier" is a reference to the analog carrier signal generated by a modem, which is modulated to carry the data. On a data modem, loss of the carrier usually equates to termination of the connection.)

Changes to the DCD signal state can generate a hardware interrupt that can notify the processor of the change, preventing the CPU from needing to constantly poll the pin.

As used on modems
DCD is very important on modems, as it is the computer's primary way to find out that the modem has established or lost its connection to the remote host. It is possible to use a modem without the DCD signal, however the only way for the computer to know that a connection is disconnected is by the modem transmitting the words "NO CARRIER" over the data lines. Because the words "NO CARRIER" are also a message that could appear in the context of a normal data session (for example, if typed by a person on the remote end, or when browsing a reference manual on a modem), there is no completely unambiguous way for a computer program to differentiate the words being sent over the connection versus from the modem.

External modems with LED status lights usually have a light labeled "CD" (carrier detect). This indicates the state of the modem's DCD signal: On if the modem is asserting DCD, off otherwise.

The signal is asserted at the same time the modem reports its CONNECT message, and stays asserted until the call is disconnected (either intentionally or because of a fault in the line). DCD is deasserted once the local modem is no longer receiving carrier from the remote modem, regardless of which side initiated the disconnect. So long as the DCD signal is high, the computer can assume that any data coming from the modem was sent from the remote side.

Virtually all newer modems allowing the behavior of the DCD signal to be configured. Typical options available include "always assert DCD", "assert DCD only when connected" (the usual default), and "always assert DCD except immediately after sensing a disconnect".

As used with null modems
A frequent use of a serial port is for a direct computer-to-computer connection. This requires an adapter called a null modem, which isn't actually a modem in the traditional sense, but rather a pair of connectors that simply crosses the complementary pins on two serial ports so the two sides can communicate. A null modem typically connects the DTR output of each computer to the DCD and DSR inputs of the other. When used in this scenario, DCD is used to simply detect the presence and/or readiness of the other side to start a session.

For example, on PCs running Windows, the DTR output is kept low until some program is run to access the serial port and raise the DTR signal high. The remote side will sense this as the DCD input going high. Some equipment will recognize the transition alone as the beginning of a session. Other equipment (such as the console port of a router) may expect characters to be transmitted, but the DCD signal high is still a prerequisite for every communication.

PPS (Pulse per second) timing use
The serial DCD pin can be used to accurately detect a PPS signal, as described in RFC 2783: