La norme RS232


Reference and Sources:

  • COLFAX INTERNATIONAL
  • Interfacing the PC (www.beyondlogic.org)
  • RS-232 was created for one purpose, to interface between Data Terminal Equipment (DTE) and Data Communications Equipment (DCE) employing serial binary data interchange. So as stated the DTE is the terminal or computer and the DCE is the modem or other communications device.

    HISTORY

    RS-232 was originally adopted in 1960 by the Electronic Industries Association (EIA). The standard evolved over the years and in 1969 the third revision (RS-232C) was to be the standard of choice of PC makers. In 1987 a fourth revision was adopted (RS-232D also known as EIA-232D). In most part of this new revision, they added 3 additional test lines. In this document we will see several parts of the original RS-232C standard and mostly the ones used in the PC world.
    Most equipment using RS-232 serial ports use a DB-25 type connector even if the original documents didn't specify a specific connector, many PCs today use DB-9 connectors since all you need in asynchronous mode is 9 signals. But take note that the document does specify the amount of pins and there assignment, 20 affected to different signals, three are reserved and two are not affected. Normally the male connector is on the DTE side and the female connector is on the DCE side even if this is not always the case.

    SERIAL COMMUNICATIONS

    The concept behind serial communications is as follows, data is transferred from sender to receiver one bit at a time through a single line or circuit. The serial port takes 8, 16 or 32 parallel bits from your computer bus and converts it as an 8, 16 or 32 bit serial stream. The name serial communications comes from this fact; each bit of information is transferred in series from one locations to another.
    In theory a serial link would only need two wires, a signal line and a ground, to move the serial signal from one location to another. But in practice this doesn't really work for a long time, some bits might get lost in the signal and thus altering the ending result. If one bit is missing at the receiving end, all succeeding bits are shifted resulting in incorrect data when converted back to a parallel signal. So to establish reliable serial communications you must overcome these bit errors that can emerge in many different forms.

    SERIAL TRANSMISSION METHODS

    Two serial transmission methods are used that correct serial bit errors. The first one is synchronous communication, the sending and receiving ends of the communication are synchronized using a clock that precisely times the period separating each bit. By checking the clock the receiving end can determine if a bit is missing or if an extra bit (usually electrically induced) has been introduced in the stream. Here is an example of this method of communication, lets say that on a conveyor belt a product is passing through a sensing device every 5 seconds, if the sensing device senses something in between the 5 second lap it assumes that whatever is passing is a foreign object of some sorts and sounds an alarm, if on the 5 second lap nothing goes by it assumes that the product is missing and sounds an alarm. One important aspect of this method is that if either end of the communication loses it's clock signal, the communication is terminated.
    The alternative method (used in PCs) is to add markers within the bit stream to help track each data bit. By introducing a start bit which indicates the start of a short data stream, the position of each bit can be determined by timing the bits at regular intervals, by sending start bits in front of each 8 bit streams, the two systems don't have to be synchronized by a clock signal, the only important issue is that both systems must be set at the same port speed. When the receiving end of the communication receives the start bit it starts a short term timer. By keeping streams short, there's not enough time for for the timer to get out of sync. This method is known as asynchronous communication because the sending and receiving end of the communication are not precisely synchronized by the means of a signal line.
    Each stream of bits are broke up in 5 to 8 bits called words. Usually in the PC environment you will find 7 or 8 bit words, the first is to accommodate all upper and lower case text characters in ASCII codes (the 127 characters) the latter one is used to exactly correspond to one byte. By convention, the least significant bit of the word is sent first and the most significant bit is sent last. When communicating the sender encodes the each word by adding a start bit in front and 1 or 2 stop bits at the end. Sometimes it will add a parity bit between the last bit of the word and the first stop bit, this used as a data integrity check. This is often referred to as a data frame.
    Five different parity bits can be used, the mark parity bit is always set at a logical 1, the space parity bit is always set at a logical 0, the even parity bit is set to logical 1 by counting the number of 1's bits in the complete envelope and determining if the result is even, in the odd parity bit, the parity bit is set to logical 1 if the number of 1's bits in the complete envelope is odd. The later two methods offer a means of detecting bit level transmission errors. The data bits in each character are inspected prior to transmission and the parity bit computed, the receiver can then recompute the parity for the received character and determine whether any transmission errors have occurred. Note that you don't have to use parity bits, thus elliminating 1 bit in each frame, this is often reffered to as non parity bit frame.
    Asynchronous Serial Data Stream
    Asynchronous Serial Data Frame (8E1)
    In the example above you can see how the data frame is composed of and synchronised with the clock signal. This example uses an 8 bit word with even parity and 1 stop bit also refered to as an 8E1 setting.

    BIT RATES

    Another important part of every asynchronous serial signal, is the bit rate at which the the data is transmitted. The rates at which the data is sent is based on the minimum speed of 300 bps (bits per second), you may find some slower speeds of 50, 100 and 150 bps, but these are not used in todays technologie. Faster speeds are all based on the 300 bps rate, you merely double the the preceding rate, so the rates are as follows, 600, 1200, 2400, 4800, 9600, 19200 and 38400 which is the fastest speed supported by todays BIOSs. Note that a few years ago the fastest speed was of 19200 bps, because of all the strain exercised on the CPU because of the software control used to control the serial port. Today with the new Micro Channel, EISA, VL Bus and PCI motherboards, the new systems take advantage of bus mastering DMA control which have pushed rates up to 38400 by eliminating microprocessor overhead.
    By bypassing the BIOS all together and controlling the hardware directly, you can obtain speeds up to 155200 bps and greater but with the venue of new intelligent ports you can obtain these new speeds without compromising on control. These new high speeds are beeing introduced because of new high rate modems. But this is all about to change with the new Universal Serial Bus that should start appearing around the last quarter of 1996.
    Here is the list of all signals specified in the RS232C standard. Each signal is identified by its letters, V.24 equivalent (CCITT), pin number on a DB-25 and DB-9 connector and its signal name. The circuit letters associated to each signal are devised by the following:


    25 PIN D-SUB MALE 25 broches D-SUB male coté PC (DTE)

    25 PIN D-SUB FEMALE 25 broches D-SUB femelle coté périphérique (DCE)


    Pin Name ITU-T Dir Description
    1 GND 101 ------ AA: Protective Ground
    2 TXD 103 OUT BA: Transmit Data
    3 RXD 104 IN BB: Receive Data
    4 RTS 105 OUT CA: Request to Send
    5 CTS 106 IN CB: Clear to Send
    6 DSR 107 IN CC: Data Set Ready
    7 GND 102 ------ AB: Signal Ground
    8 CD 109 IN CF: Carrier Detect
    9 -   - RESERVED - Positive test
    10 -   - RESERVED - Negative test
    11 STF 126 OUT Select Transmit Channel
    12 S.CD 122 IN SCF: Secondary Carrier Detect
    13 S.CTS 121 IN SCB: Secondary Clear to Send
    14 S.TXD 118 OUT SBA: Secondary Transmit Data
    15 TCK 114 IN DB: Transmission Signal Element Timing
    16 S.RXD 119 IN SBB: Secondary Receive Data
    17 RCK 115 IN DD: Receiver Signal Element Timing
    18 LL 141 OUT Local Loop Control
    19 S.RTS 120 OUT SCA: Secondary Request to Send
    20 DTR 108 OUT CD: Data Terminal Ready
    21 RL 140 OUT Remote Loop Control
    22 RI 125 IN CE: Ring Indicator
    23 DSR 111/112 OUT CH/CI: Data Signal Rate Selector
    24 XCK 113 OUT DA: Transmit Signal Element Timing
    25 TI 142 IN Test Indicator

    Note: Direction is DTE (Computer) relative DCE (Modem).
    Note: Do not connect SHIELD(1) to GND(7).

    AA: Protective ground

    This line is connected to the power ground of the serial adapter. It should not be used as signal ground. Connect this line to the screen of the lead wire (if applicable). By connecting this line on both sides you make sure that no large currents flow through the signal ground in case of an insulation defect or other defect on either side. On the other side, when two devices are seperated by great dinstances you may not wish to use tis signal, because of different ground potential and it is possible that it may carry a substantial current as a ground loop. If it is great enough, it may cause electrical interference.

    AB: Signal ground

    This is the logical ground which is used as a point of reference for all signals received or transmitted. This signal is very important and must be present for all communications.

    BA: Transmitted data

    This line is used to transmit data from the DTE to the DCE. It is maintained at a logical 1 state when nothing is transmitted. The terminal will start to transmit when a logical 1 is present on all of the following lines:

    BB: Received data

    This circuit is used to receive data from the DCE to the DTE.The terminal will start to transmit when a logical 1 is present on all of the following lines:

    CA: Request To Send

    On this line, the DTE will send a signal when it wants to receive data from the DCE.

    CB: Clear To Send

    Here the DCE will send a signal when it's ready to receive data from the DTE. (ex. When your local modem connects to an other modem via telephone lines).

    CC: Data Set Ready

    At a logical level of 1, this line indicates to the DTE that the DCE is ready to send data. (ex. When a modem has established a connection with a remote modem and is in transmission mode).

    CD: Data Terminal Ready

    When a logical level 1 is sent from the DTE the DCE can start to send and receive data. When this line passes to logical level 0 the DCE will stop all communications. (ex. A modem would stop all communications and would disconnect from the line, you will often see "DROP DTR" in communication programs).

    CF: Data Carrier Detect

    On this line the DCE indicates to the DTE that it has established a carrier with a remote device.

    CE: Ring Indicator

    This line is used mostly by communications software when the modem is not in "auto answer" mode and will indicate to the the software that a remote device is calling. This is signal is optional when not using software that will answer a phone call automatically.

    CG: Signal quality

    This line although rarely used serves to indicate to the DTE that the quality of the signal is poor or just not good enough to keep a good connection.

    CH: Data signal rate selector

    In the case where a modem able of multiple connection rates, the DTE could choose the speed at which it is connected. Usually this line is kept a logical level 0 which selects the highest speed.

    CI: Data signal rate selector

    This signal is the same as CH but in this case the modem selects the speed at which the DTE communicates.

    Timing circuits

    In synchronous mode, it is necessary to have some way to exchange clock signals, here are three timing circuits used in the RS-232 protocol.

    Using this chart you should be able to make a cable from any device, to any computer.

    Function Pin connections
    Mac name RS-232 name Mac DB-25 DB-9 RJ-45
    RxD RD 5 3 2 5
    TxD TD 3 2 3 6
    Ground SGND 4,8 7 5 4
    HSKi CTS 2 5 8 7
    HSKo RTS 1 4 7 8
      DTR 1 20 4 3
    GPi DCD 7 8 1 2
      RI   6 9 1
      DSR     6  

    Notes:
    There are two ground pins on the Mac, 4 and 8
    Both RTS and DTR are wired to pin 1 on the Mac
    Not all Macs support DCD via pin 7
    RI and DSR are not supported on the Mac
    DSR is not supported on the RJ-45