[go: nahoru, domu]

Jump to content

RS-232: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
use cite/ref format.
Line 21: Line 21:
Later [[personal computer]]s (and other devices) started to make use of the standard so that they could connect to existing equipment. For many years, a RS-232-compatible port was a standard feature for [[serial communications]], such as modem connections, on many computers. It remained in widespread use into the late 1990s, and while it has largely been supplanted by other interface standards in computer products, it is still used to connect legacy peripherals, industrial equipment (such as based on [[Programmable logic controller|PLC]]s), and [[Serial console|console]] ports.
Later [[personal computer]]s (and other devices) started to make use of the standard so that they could connect to existing equipment. For many years, a RS-232-compatible port was a standard feature for [[serial communications]], such as modem connections, on many computers. It remained in widespread use into the late 1990s, and while it has largely been supplanted by other interface standards in computer products, it is still used to connect legacy peripherals, industrial equipment (such as based on [[Programmable logic controller|PLC]]s), and [[Serial console|console]] ports.
The standard has been renamed several times during its history as the sponsoring organization changed its name, and has been variously known as EIA RS 232, EIA 232, and most recently as TIA 232. The standard continues to be revised and updated by the [[Electronic Industries Alliance|EIA]] and since 1988 the [[Telecommunications Industry Association]] (TIA<ref>[http://www.tiaonline.org/about/overview.cfm TIA Web site]</ref>). Revision C was issued in a document dated August 1969. Revision D was issued in 1986. The current revision is ''TIA-232-F Interface Between Data Terminal Equipment and Data Circuit-Terminating Equipment Employing Serial Binary Data Interchange'', issued in 1997. Changes since Revision C have been in timing and details intended to improve harmonization with the [[ITU-T|CCITT]] standard V.24, but equipment built to the current standard will interoperate with older versions.
The standard has been renamed several times during its history as the sponsoring organization changed its name, and has been variously known as EIA RS 232, EIA 232, and most recently as TIA 232. The standard continues to be revised and updated by the [[Electronic Industries Alliance|EIA]] and since 1988 the [[Telecommunications Industry Association]] (TIA)<ref>[http://www.tiaonline.org/about/overview.cfm TIA Web site]</ref>. Revision C was issued in a document dated August 1969. Revision D was issued in 1986. The current revision is ''TIA-232-F Interface Between Data Terminal Equipment and Data Circuit-Terminating Equipment Employing Serial Binary Data Interchange'', issued in 1997. Changes since Revision C have been in timing and details intended to improve harmonization with the [[ITU-T|CCITT]] standard V.24, but equipment built to the current standard will interoperate with older versions.


==Limitations of the standard==
==Limitations of the standard==

Revision as of 20:52, 30 April 2007

In telecommunications, RS-232 is a standard for serial binary data signals connecting between a DTE (Data terminal equipment) and a DCE (Data Circuit-terminating Equipment). It is commonly used in computer serial ports. A similar ITU-T standard is V.24.

Scope of the standard

The Electronic Industries Alliance (EIA) standard RS-232-C[1] as of 1969 defines:

  • Electrical signal characteristics such as voltage levels, signaling rate, timing and slew-rate of signals, voltage withstand level, short-circuit behavior, maximum stray capacitance and cable length.
  • Interface mechanical characteristics, pluggable connectors and pin identification.
  • Functions of each circuit in the interface connector.
  • Standard subsets of interface circuits for selected telecom applications.

The standard does not define such elements as character encoding (for example, ASCII, Baudot or EBCDIC), or the framing of characters in the data stream (bits per character, start/stop bits, parity). The standard does not define protocols for error detection or algorithms for data compression.

The standard does not define bit rates for transmission, although the standard says it is intended for bit rates lower than 20,000 bits per second. Many modern devices can exceed this speed (38,400 and 57,600 bit/s being common, and 115,200 and 230,400 bit/s making occasional appearances) while still using RS-232 compatible signal levels.

Details of character format and transmission bit rate are controlled by the serial port hardware, often a single integrated circuit called a UART that converts data from parallel to serial form. A typical serial port includes specialized driver and receiver integrated circuits to convert between internal logic levels and RS-232 compatible signal levels.

History

The original DTEs were electromechanical teletypewriters and the original DCEs were (usually) modems. When electronic terminals (smart and dumb) began to be used, they were often designed to be interchangeable with teletypes, and so supported RS-232. The C revision of the standard was issued in 1969 in part to accommodate the electrical characteristics of these devices.

Since application to such devices as computers, printers, digitizer tables, test instruments, and so on, were not envisaged in the standard, designers implementing an RS-232 compatible interface on their equipment often interpreted the requirements idiosyncratically. Common problems were non-standard pin assignment of circuits on connectors, and incorrect or missing control signals. The lack of adherence to the standards produced a thriving industry of breakout boxes, patch boxes, test equipment, books, and other aids for the connection of disparate equipment. A common deviation from the standard was to drive the signals at a reduced voltage: the standard requires the transmitter to use +12V and -12V, but requires the receiver to distinguish voltages as low as +3V and -3V. Some manufacturers therefore built transmitters that supplied +5V and -5V and labeled them as "RS-232 compatible."

Later personal computers (and other devices) started to make use of the standard so that they could connect to existing equipment. For many years, a RS-232-compatible port was a standard feature for serial communications, such as modem connections, on many computers. It remained in widespread use into the late 1990s, and while it has largely been supplanted by other interface standards in computer products, it is still used to connect legacy peripherals, industrial equipment (such as based on PLCs), and console ports.

The standard has been renamed several times during its history as the sponsoring organization changed its name, and has been variously known as EIA RS 232, EIA 232, and most recently as TIA 232. The standard continues to be revised and updated by the EIA and since 1988 the Telecommunications Industry Association (TIA)[2]. Revision C was issued in a document dated August 1969. Revision D was issued in 1986. The current revision is TIA-232-F Interface Between Data Terminal Equipment and Data Circuit-Terminating Equipment Employing Serial Binary Data Interchange, issued in 1997. Changes since Revision C have been in timing and details intended to improve harmonization with the CCITT standard V.24, but equipment built to the current standard will interoperate with older versions.

Limitations of the standard

Because the application of RS-232 has extended far beyond the original purpose of interconnecting a terminal with a modem, successor standards have been developed to address the limitations. Issues with the RS-232 standard include:

  • The large voltage swings and requirement for positive and negative supplies increases power consumption of the interface and complicates power supply design. The voltage swing requirement also limits the upper speed of a compatible interface.
  • Single-ended signaling referred to a common signal ground limit the noise immunity and transmission distance.
  • Multi-drop (meaning a connection between more than two devices) operation of an RS-232 compatible interface is not defined; while multi-drop "work-arounds" have been devised, they have limitations in speed and compatibility.
  • Asymmetrical definitions of the two ends of the link make the assignment of the role of a newly developed device problematic; the designer must decide on either a DTE-like or DCE-like interface and which connector pin assignments to use.
  • The handshaking and control lines of the interface are intended for the setup and takedown of a dial-up communication circuit; in particular, the use of handshake lines for flow control is not reliably implemented in many devices.
  • While the standard recommends a connector and pinout, the connector is large by current standards.

Role in modern personal computers

In the book PC 97 Hardware Design Guide[3], Microsoft deprecated support for the RS-232 compatible serial port of the original IBM PC design. Today, RS-232 is gradually being superseded in personal computers by USB for local communications. Compared with RS-232, USB is faster, has lower voltage levels, and has connectors that are simpler to connect and use. Both protocols have software support in popular operating systems. USB is designed to make it easy for device drivers to communicate with hardware. However, there is no direct analog to the terminal programs used to let users communicate directly with serial ports. USB is more complex than the RS 232 standard, requiring more software to support the protocol used. Serial ports of personal computers were also often used to directly control various hardware devices, such as relays or lamps, since the control lines of the interface could be easily manipulated by software. This isn't feasible with USB which requires some form of receiver to decode the serial data.

Many personal computers intended for office use ship with "legacy-free" motherboards without any RS-232 serial ports. However, RS-232 is still quite common in point-of-sale (cash drawers, barcode and magnetic stripe readers), amateur electronics and industrial measurement and remote-control devices, so computers made for such applications are still equipped with RS-232 ports. RS-232 was 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. Many motherboards and desktop systems provide these ports even though they may not be used, simply because it costs the manufacturer very little to include them. Small-form-factor systems and laptops, however, often do not include them in order to conserve space.

As an alternative, USB docking ports are available which can provide connectors for a keyboard, mouse, one or more serial ports, and one or more parallel ports. Corresponding device drivers are required for each USB-connected device to allow programs to access these USB-connected devices as if they were the original directly-connected peripherals.

Network equipment such as manageable switches and routers usually have an RS-232 port to be used for configuration of the device. It's a problem for some network administrators that most new laptops don't have an RS-232 port (though one can of course use a USB-to-serial dongle). Various PCI and PCI Express cards provide RS-232 ports.

It is also possible to connect RS-232 devices via Ethernet and WLAN device drivers, that act as network servers. Some manufacturers even have virtual serial port drivers available

Standard details

In RS-232, data is sent as a time-series of bits. Both synchronous and asynchronous transmissions are supported by the standard. In addition to the data circuits, the standard defines a number of control circuits used to manage the connection between the DTE and DCE. Each data or control circuit only operates in one direction, that is, signaling from a DTE to the attached DCE or the reverse. Since transmit data and receive data are separate circuits, the interface can operate in a full duplex manner, supporting concurrent data flow in both directions. The standard does not define character framing within the data stream, or character encoding.

Voltage levels

The RS-232 standard defines the voltage levels that correspond to logical one and logical zero levels. Valid signals are plus or minus 3 to 15 volts. The range near zero volts is not a valid RS-232 level; logic one is defined as a negative voltage, the signal condition is called marking, and has the functional significance of OFF. Logic zero is positive, the signal condition is spacing, and has the function ON. The standard specifies a maximum open-circuit voltage of 25 volts; signal levels of ±5V,±10V,±12V, and ±15V are all commonly seen depending on the power supplies available within a device. Circuits driving an RS-232-compatible interface must be able to withstand indefinite short circuit to ground or to any voltage level up to 25 volts. The slew rate, or how fast the signal changes between levels, is also controlled.

Because the voltage levels are higher than logic levels used by integrated circuits, special intervening circuits are required to translate logic levels, and to protect circuitry internal to the device from short circuits or transients that may appear on the RS-232 interface.

Because both ends of the RS-232 circuit depend on pin seven the ground being zero volts, problems will occur when connecting machinery and computers where the voltage between pin seven on one end, and pin seven on the other is not zero.

Connectors

RS-232 devices may be classified as Data Terminal Equipment (DTE) or Data Circuit termination Equipment (DCE); this defines at each device which wires will be sending and receiving each signal. The standard recommended but did not make mandatory the common D-subminiature 25 pin connector. In general, terminals have male connectors with DTE pin functions, and modems have female connectors with DCE pin functions. Other devices may have any combination of connector gender and pin definitions.

Presence of a 25 pin D-sub connector does not necessarily indicate an RS-232C compliant interface. For example, on the original IBM PC, a male D-sub was an RS-232C DTE port (with a non-standard current loop interface on reserved pins), but the female D-sub connector was used for a parallel Centronics printer port. Some personal computers put non-standard voltages or signals on their serial ports.

Female 9 pin plug

The standard specifies 20 different signal connections. Since most devices use only a few signals, smaller connectors can be used. For example, the 9 pin DE-9 connector was 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 8 pin RJ-45 connectors. Standard EIA/TIA 561 specifies a pin assignment, but the "Yost Serial Device Wiring Standard" invented by Dave Yost is common on Unix computers and newer devices from Cisco Systems. Many devices don't use either of these standards. 10 pin RJ-50 connectors can be found on some devices as well. Digital Equipment Corporation defined their own DECconnect connection system which was based on the Modified Modular Jack 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).

Pinouts (DTE relative)

The following table lists the commonly used RS-232 signals and common pin assignments (see also RS-485 for different standard with the same connectors):

Signal DB-25 DE-9 (TIA-574) EIA/TIA 561 Yost RJ-50 MMJ Cisco RJ-45 Hirschmann RJ-45
Common Ground G 7 5 4 4,5 6 3,4 4,5 4
Transmitted Data TD 2 3 6 3 8 2 3 3
Received Data RD 3 2 5 6 9 5 6 5
Data Terminal Ready DTR 20 4 3 2 7 1 2 -
Data Set Ready DSR 6 6 1 7 5 6 7 -
Request To Send RTS 4 7 8 1 4 - 1 (Aux only) -
Clear To Send CTS 5 8 7 8 3 - 8 (Aux only) -
Carrier Detect DCD 8 1 2 7 10 - - -
Ring Indicator RI 22 9 1 - 2 - - -

The signals are labeled from the standpoint of the DTE device; TD, DTR, and RTS are generated by the DTE and RD, DSR, CTS, DCD, and RI are generated by the DCE. The ground signal is a common return for the other connections; it appears on two pins in the Yost standard but is the same signal. Connection of pin 1 (protective ground) and pin 7 (signal reference ground) is a common practice but not recommended. Use of a common ground is one weakness of RS-232. If the two pieces of equipment are far enough apart or on separate power systems, the ground will degrade between them and communications will fail; this is a difficult condition to trace.

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

Signals

Commonly-used signals are:

Transmitted Data (TxD)
Data sent from DTE to DCE.
Received Data (RxD)
Data sent from DCE to DTE.
Request To Send (RTS)
Asserted (set to 0) by DTE to prepare DCE to receive data. This may require action on the part of the DCE, e.g. transmitting a carrier or reversing the direction of a half-duplex line.
Clear To Send (CTS)
Asserted by DCE to acknowledge RTS and allow DTE to transmit.
Data Terminal Ready (DTR)
Asserted by DTE to indicate that it is ready to be connected. If the DCE is a modem, it should go "off hook" when it receives this signal. If this signal is de-asserted, the modem should respond by immediately hanging up.
Data Set Ready (DSR)
asserted by DCE to indicate an active connection. If DCE is not a modem (e.g. a null-modem cable or other equipment), this signal should be permanently asserted (set to 0), possibly by a jumper to another signal.
Carrier Detect (CD)
Asserted by DCE when a connection has been established with remote equipment.
Ring Indicator (RI)
Asserted by DCE when it detects a ring signal from the telephone line.

NOTE: The standard defines RTS/CTS as the signaling protocol for flow control for data transmitted from DTE to DCE. The standard has no provision for flow control in the other direction. In practice, most hardware seems to have repurposed the RTS signal for this function.

Cables

Since the standard definitions are not always correctly applied, it is often necessary to consult documentation, test connections with a breakout box, or use trial and error to find a cable that works when interconnecting two devices. Connecting a fully-standard-compliant DCE device and DTE device would use a cable that connects identical pin numbers in each connector (a so-called "straight cable"). "Gender changers" are available to solve gender mismatches between cables and connectors. Connecting devices with different types of connectors requires a cable that connects the corresponding pins according to the table above. Cables with 9 pins on one end and 25 on the other are common, and manufacturers of equipment with RJ-45 connectors usually provide a cable with either a DB-25 or DE-9 connector (or sometimes interchangeable connectors so they can work with multiple devices).

Connecting two DTE devices together requires a null modem that acts as a DCE between the devices by swapping the corresponding signals (TD-RD, DTR-DSR, and RTS-CTS). This can be done with a separate device and two cables, or using a cable wired to do this. If devices require Carrier Detect, it can be simulated by connecting DSR and DCD internally in the connector, thus obtaining CD from the remote DTR signal. One feature of the Yost standard is that a null modem cable is a "rollover cable" that just reverses pins 1 through 8 on one end to 8 through 1 on the other end.

For configuring and diagnosing problems with RS-232 cables, a "breakout box" may be used. This device normally has a female and male RS-232 connector and is meant to attach in-line; it then has lights for each pin and provisions for interconnecting pins in different configurations.

RS-232 cables may be built with connectors commonly available at electronics stores. The cables may be between 3 and 25 conductors; typically 4 or 6 wires are used. Flat RJ (phone-style) cables may be used with special RJ-RS232 connectors, which are the easiest to configure. Cables are often unshielded, although shielding cables will help reduce electrical noise radiated by the cable.

The reason that a minimal two-way interface can be created with only 3 wires is that all the RS-232 signals share a common ground return. The use of unbalanced circuits makes RS-232 susceptible to problems due to ground potential shifts between the two devices. RS-232 also has relatively poor control of signal rise and fall times, leading to potential crosstalk problems. RS-232 was recommended for short connections (15 meters or less), however the limit is actually defined by total capacitance and low capacitance cables allow reliable communications over longer distances exceeding 50 m. RS-232 interface cables are not usually constructed with twisted pair because of the unbalanced circuits.

While the control lines of the RS 232 interface were originally intended for call setup and takedown, other "handshakes" may be required by one or the other device. These are used for flow control, for example, to prevent loss of data sent to a serial printer. For example, DTR is commonly used to indicate "device ready". Pins may also be "jumpered" or routed back within the connector; a pin saying "are you ready?" from device A might be wired to the pin saying "I'm ready" on device A, if device B did not transmit such a signal. Common handshake pins are DTR, DSR, DCD, and RTS/CTS.

Conventions

For functional communication through a serial port interface, conventions of bit rate, character framing, communications protocol, character encoding, data compression, and error detection, not defined in RS 232, must be agreed to by both sending and receiving equipment. For example, consider the serial ports of the original IBM PC. This implementation has an integrated circuit UART, often 16550 UART, using asynchronous start-stop character formatting with 7 or 8 data bits per frame, usually ASCII character coding, and data rates programmable between 75 bits per second and 115,000 bits per second. Data rates above 20,000 bits per second are out of the scope of the standard, although higher data rates are sometimes used by commercially manufactured equipment. In the particular case of the IBM PC, baud rates were programmable, so that a PC could be connected to, for example, MIDI music controllers (31,250 bits per second) or other devices not using the rates typically used with modems. Since most devices do not have automatic baud rate detection, users must manually set the baud rate (and all other parameters) at both ends of the RS-232 connection.

RTS/CTS handshaking

The standard RS-232 use of the RTS and CTS lines is asymmetrical. The DTE asserts RTS to indicate a desire to transmit and the DCE asserts CTS in response to grant permission. This allows for half-duplex modems that disable their transmitters when not required, and must transmit a synchronization preamble to the receiver when they are re-enabled. There is no way for the DTE to indicate that it is unable to accept data from the DCE.

A non-standard symmetrical alternative is widely used: CTS indicates permission from the DCE for the DTE to transmit, and RTS indicates permission from the DTE for the DCE to transmit. The "request to transmit" is implicit and continuous.

3-wire and 5-wire RS-232

A minimal "3-wire" RS-232 connection consisting only of transmit data, receive data, and ground, is commonly used when the full facilities of RS-232 are not required. When only flow control is required, the RTS and CTS lines are added in a 5-wire version.

Seldom used features

The EIA-232 standard specifies connections for several features that are not used in most implementations. Their use requires the 25-pin connectors and cables, and of course both the DTE and DCE must support them.

Signal rate selection

The DTE or DCE can specify use of a "high" or "low" signaling rate. The rates as well as which device will select the rate must be configured in both the DTE and DCE. The prearranged device selects the high rate by setting pin 23 to ON.

Loopback testing

Many DCE devices have a loopback capability used for testing. When enabled, signals are echoed back to the sender rather than being sent on to the receiver. If supported, the DTE can signal the local DCE (the one it is connected to) to enter loopback mode by setting pin 18 to ON, or the remote DCE (the one the local DCE is connected to) to enter loopback mode by setting pin 21 to ON. The latter tests the communications link as well as both DCE's. When the DCE is in test mode it signals the DTE by setting pin 25 to ON.

A commonly used version of loopback testing doesn't involve any special capability of either end. A hardware loopback is simply a wire connecting complementary pins together in the same connector. See loopback.

Loopback testing is often performed with a specialized DTE called a Bit Error Rate Tester (BERT).

Timing signals

Some synchronous devices provide a clock signal to synchronize data transmission. The timing signals are provided by the DCE on pins 15 and 17. Pin 15 is the transmitter clock; the DTE puts the next bit on the data line (pin 2) when this clock transitions from OFF to ON (so it is stable during the ON to OFF transition when the DCE registers the bit). Pin 17 is the receiver clock; the DTE reads the next bit from the data line (pin 3) when this clock transitions from ON to OFF.

Alternatively, the DTE can provide a clock signal on pin 24 for both transmitted and received data. Again, data is changed when the clock transitions from OFF to ON and read during the ON to OFF transition.

Secondary channel

Data can be sent over a secondary channel (when implemented by the DTE and DCE devices), which is equivalent to the primary channel. Pin assignments are described in following table:

Signal Pin
Common Ground 7 (same as primary)
Secondary Transmitted Data (STD) 14
Secondary Received Data (SRD) 16
Secondary Request To Send (SRTS) 19
Secondary Clear To Send (SCTS) 13
Secondary Carrier Detect (SDCD) 12

Other serial signaling standards may not interoperate with standard-compliant RS-232 ports. For example, using the TTL levels of near +5 and 0 V puts the mark level in the undefined area of the standard. Such levels are sometimes used with NMEA 0183-compliant GPS receivers and depth finders.

20 mA current loop uses the absence of 20 mA current for high, and the presence of current in the loop for low; this signaling method is often used for long-distance and optically isolated links. Connection of a current-loop device to a compliant RS-232 port requires a level translator; current-loop devices are capable of supplying voltages in excess of the withstand voltage limits of a compliant device. The original IBM PC serial port card implemented a 20 mA current-loop interface, which was never emulated by other suppliers of plug-compatible equipment.

Other serial interfaces similar to RS-232:

  • RS-422 (a high-speed system similar to RS-232 but with differential signaling)
  • RS-423 (a high-speed system similar to RS-422 but with unbalanced signaling)
  • RS-449 (a functional and mechanical interface that used RS-422 and RS-423 signals - it never caught on like RS-232 and was withdrawn by the EIA)
  • RS-485 (a descendant of RS-422 that can be used as a bus in multidrop configurations)
  • MIL-STD-188 (a system like RS-232 but with better impedance and rise time control)
  • EIA-530 (a high-speed system using RS-422 or RS-423 electrical properties in an EIA-232 pinout configuration, thus combining the best of both; supersedes RS-449)
  • TIA-574 (standardizes the 9-pin D-subminiature connector pinout for use with EIA-232 electrical signalling, as originated on the IBM PC/AT)

See also

References

  1. ^ Electronics Industries Association, "EIA Standard RS-232-C Interface Between Data Terminal Equipment and Data Communication Equipment Employing Serial Data Interchange", August 1969, reprinted in Telebyte Technology Data Communication Library, Greenlawn NY, 1985, no ISBN
  2. ^ TIA Web site
  3. ^ PC 97 Hardware Design Guide. Redmond,Washington, USA: Microsoft Press. 1997. ISBN 1-57231-381-1.