Internet Windows Android

Connector pc 232. Pinout of the COM port (RS232)

RS232 is a definition of a standard that describes the interface used to connect data transmission devices to a computer. The standard was first developed and adopted in the 60s of the twentieth century, but still has not lost its relevance. In 1991, its last revision EIA / TIA-232-E was prepared, which is used to this day. The first company to use it in their computers was IBM, and nowadays RS232 is part of the structure of almost every personal computer. It was named Communication port (COM port).

Using RS232 standard a connection is provided between two devices: a computer (Data Terminal Equipment) and the equipment itself for transmitting information (Data Communications Equipment). It is important to know the knowledge of these abbreviated designations (DTE and DCE) in order to be able to understand the technical description and the procedure for connecting and operating specific devices. Any self-respecting programmer is familiar with this standard.

DCE is most often a modem, but RS232 is also suitable for connecting other peripherals such as a printer or mouse. Data transfer is carried out using wires. The hardware implementation of the standard denotes the fact that it always runs on a PC, no matter what operating system is installed on the computer. Programs can interact with a COM port by absolutely any means: using BIOS functions, through operating system components, through direct microprocessor code, and also through high-level language components. RS232 provides connection of a computer to the local Internet network via Ethernet technology, and is also part of the information transfer system between a personal computer and industrial equipment.

In short, the standard RS232 is versatile. But, despite this, it was replaced by other methods of connecting a computer with peripheral devices. These are, for example, USB ports.

What is the difference between RS-232 and USB

The standard differs in ease of programming from USB, so it was quite difficult to implement a data exchange protocol using this more modern technology. Both specialists and radio amateurs were actively involved in this.

The indisputable advantage of RS-232 is the fact that the maximum speed that is possible when exchanging through this interface is unlikely to be blocked by modern wireless communication devices. Recently, there has been a trend towards limiting the power of radio transceivers that are used to communicate over a wireless connection. This does not allow to increase the data transfer rate, which today is a maximum of 9600 baud, and with the RS-232 interface - 115200 baud.

Signal levels used

The RS-232 standard is characterized by two signal levels - 0 and 1. Logical 1 and 0 correspond to different voltage levels - negative and positive, respectively. When passing through the cable, the signal can not only be distorted, but also attenuated. As the cable length increases, the attenuation increases. This can be easily explained by the electrical capacitance of the cable. Therefore, its length is usually limited to 17 meters to ensure sufficient maximum load capacitance, which is 2500 pF. In this case, the data transfer rate will be 9600 bits per second. In principle, it is possible to achieve normal operation of the cable and connection even with a much longer cable length. Experts say that they managed to double the unshielded cable, and the shielded cable five times. In each specific case, a different level of electromagnetic vibrations is taken into account.

A contact-to-contact cable is required to make the connection. Mostly, null modem cable types are used, in which crossover wires are located.

Transfer of information

The RS232 standard is considered a serial interface because the stream is transmitted on a first-in-first-out basis. The information stream is transmitted sequentially, bit by bit. When no information is transmitted over the cable, the line goes into a logical 1 state.

Where RS232 Standard Is Used

The scope of the RS232 standard is wide enough. First of all, these are highly specialized equipment, sensors, built-in appliances, measuring instruments. Despite the fact that you can still find it in some computers, RS232 has practically no prospects for the future. There are still such echoes of the past in some economic and industrial sectors. The standard is gradually being considered obsolete, it is less and less used in modern devices for processing and transmitting information.

The interaction of various devices with computer equipment through the RS-232 interface can be found at enterprises that are engaged in serial tests, conduct scientific experiments. This is due to the exceptional need to automate the processes of obtaining, collecting and analyzing data and results.

RS-232 standard It is actively used in multifunctional measuring devices, for example, an electricity meter equipped with an additional function to control costs at established tariffs. Data reading and transmission is carried out via the RS-232 interface.

Description of the RS-232 interface, format of used connectors and pin assignment, signal designations, data exchange protocol.

general description

The RS-232 interface, quite officially called "EIA / TIA-232-E", but better known as the "COM port" interface, was previously one of the most common interfaces in computer technology. It is still found in desktop computers today, despite the emergence of faster and more intelligent interfaces such as USB and FireWare. Its advantages from the point of view of radio amateurs include a low minimum speed and ease of implementation of the protocol in a homemade device.

The physical interface is implemented by one of two types of connectors: DB-9M or DB-25M, the latter is practically not found in the currently produced computers.

9-pin connector pinouts


9-pin male DB-9M male
Pin numbering from pins side
The direction of signals is indicated relative to the host (computer)
Contact Signal Direction Description
1 CD entrance Carrier detected
2 RXD entrance Received data
3 TXD Output Transmitted data
4 DTR Output Host is ready
5 GND - Common wire
6 DSR entrance The device is ready
7 RTS Output Host is ready to transfer
8 CTS entrance The device is ready to receive
9 RI entrance Call detected

25-pin connector pinouts

Contact Signal Direction Description
1 SHIELD - Screen
2 TXD Output Transmitted data
3 RXD entrance Received data
4 RTS Output Host is ready to transfer
5 CTS entrance The device is ready to receive
6 DSR entrance The device is ready
7 GND - Common wire
8 CD entrance Carrier detected
9 - - Reserve
10 - - Reserve
11 - - Not used
12 SCD entrance Carrier # 2 Detected
13 SCTS entrance Device ready to receive # 2
Contact Signal Direction Description
14 STXD Output Transferred data # 2
15 TRC entrance Transmitter clocking
16 SRXD entrance Received data # 2
17 RCC entrance Receiver clock
18 LLOOP Output Local loop
19 SRTS Output Host ready for transfer # 2
20 DTR Output Host is ready
21 RLOOP Output Outer hinge
22 RI entrance Call detected
23 DRD entrance Data rate determined
24 TRCO Output External transmitter clocking
25 TEST entrance Test mode

The tables show that the 25-pin interface is distinguished by the presence of a full-fledged second transmit-receive channel (signals designated "# 2"), as well as numerous additional control and monitoring signals. However, often, despite the presence of a "wide" connector in the computer, additional signals are simply not connected to it.

Electrical characteristics

Transmitter logic levels:"0" - from +5 to +15 Volts, "1" - from -5 to -15 Volts.

Receiver logic levels:"0" - above +3 Volts, "1" - below -3 Volts.

the input impedance of the receiver is at least 3 kOhm.

These characteristics are defined by the standard as the minimum, guaranteeing the compatibility of devices, however, the real characteristics are usually much better, which allows, on the one hand, to power low-power devices from the port (for example, this is how numerous homemade data cables for cell phones are designed), and on the other hand, to supply at the port entrance inverted TTL level instead of bipolar signal.

Description of the main interface signals

CD- The device sets this signal when it detects a carrier in the received signal. Typically this signal is used by modems, which in this way inform the host that a working modem is found on the other end of the line.

RXD- The line that the host receives data from the device. It is described in detail in the section "Communication protocol".

TXD- Host transmission line of data to the device. It is described in detail in the section "Communication protocol".

DTR- The host asserts this signal when it is ready to exchange data. In fact, the signal is set when the port is opened by the communication program and remains in this state as long as the port is open.

DSR- The device asserts this signal when it is powered on and ready to communicate with the host. This and previous (DTR) signals must be set for data exchange.

RTS- The host sets this signal before starting to transmit data to the device, and also signals that it is ready to receive data from the device. Used for hardware communication control.

CTS- The device asserts this signal in response to the previous (RTS) set by the host when it is ready to receive data (for example, when the previous data sent by the host has been transferred by the modem to the line or there is free space in the intermediate buffer).

RI- The device (usually a modem) sets this tone when it receives a call from the remote system, for example, when it receives a phone call if the modem is set to receive calls.

Communication protocol

In the RS-232 protocol, there are two methods of data exchange control: hardware and software, as well as two transmission modes: synchronous and asynchronous. The protocol allows any of the control methods to be used in conjunction with any transmission mode. It also allows operation without flow control, which means that the host and device are always ready to receive data when communication is established (DTR and DSR signals are established).

Hardware control method implemented using RTS and CTS signals. To transmit data, the host (computer) asserts the RTS signal and waits for the device to set the CTS signal, and then starts transmitting data as long as the CTS signal is asserted. The CTS signal is checked by the host just before the next byte starts to be transmitted, so the byte that has already begun to be transmitted will be transmitted completely regardless of the CTS value. In half-duplex mode of data exchange (the device and the host transmit data in turn, in full-duplex mode they can do it simultaneously) removal of the RTS signal by the host means its transition to the receive mode.

Software control method is for the receiving party to send the special characters stop (character with code 0x13, called XOFF) and resume (character with code 0x11, called XON) of the transmission. Upon receipt of character data, the transmitting side must respectively stop transmission or resume it (if there is data waiting to be transmitted). This method is simpler from the point of view of hardware implementation, however, it provides a slower response and, accordingly, requires an advance notification of the transmitter when the free space in the receive buffer decreases to a certain limit.

Synchronous transmission mode implies continuous data exchange, when bits follow one after another without additional pauses at a given rate. This mode by COM port not supported.

Asynchronous transfer mode consists in the fact that each data byte (and the parity bit, if any) is "wrapped" in a synchronization sequence of one zero start bit and one or more single stop bits. The data flow diagram in asynchronous mode is shown in the figure.

One of the possible algorithms for the receiver next:

  1. Wait for receive signal level "0" (RXD in case of host, TXD in case of device).
  2. Count down half of the bit duration and check that the signal level is still "0"
  3. Count the full bit duration and write the current signal level to the least significant data bit (bit 0)
  4. Repeat the previous step for all other data bits
  5. Count the full duration of a bit and use the current signal level to check the correctness of reception using parity check (see below)
  6. Count the full duration of the bit and make sure that the current signal level is "1".

Strictly speaking, the interface RS 232 is the name of the standard (RS - recommended standard, 232 is its number), which describes the interface for connecting a computer and a data transmission device.

The standard was developed quite a long time ago, in the 60s of the 20th century. The current version of the standard, adopted in 1991 by the associations of the electronics and telecommunications industries, is called EIA / TIA-232-E.

However, most people still use the name RS-232, which is firmly entrenched in the interface itself.

Devices

The RS-232 interface provides connection of two devices, one of which is called DTE (Data Terminal Equipment) - DTE (Data Terminal Equipment), the second - DCE (Data Communications Equipment) - DTE (Data Communication Equipment).

Typically, DTE is a computer, and DCE is a modem, although RS-232 was used to connect peripheral devices (mouse, printer) to a computer, and to connect to another computer, or.

It is important to remember these conventions (DTE and DCE). They are used in the names of interface signals and help to understand the description of a specific implementation.

Connector types

The standard originally described the use of a 25-pin connector, type DB25. DTE-device must be equipped with a plug (male - "male"), DCE-device - a socket (female - "mother"). Later, with the advent of the IBM PC, a truncated version of the interface and 9-pin DB9 connectors, which are most common today, began to be used.

Wiring RS-232

The following table shows the pin assignments for a 9-pin DB9 connector. The table shows the wiring Data Processing Equipment Plugs (DTE), for example, a personal computer. The DCE socket is wired so that the two connectors mate directly, or via a pin-to-pin soldered cable.

1 - Carrier Detect (CD) Carrier frequency

2 -Received Data (RD) Received data

3 - Transmitted Data (TD) Transmitted data

4 - Data Terminal Ready (DTR) OOD readiness

5 - Signal Ground General

6 - Data Set Ready (DSR) OPD readiness

7 - Request To Send (RTS) Transfer request

8 - Clear To Send (CTS) Ready to transmit

9 - Ring Indicator (RI) Call signal

The RD and TD circuits are intended for data transmission. The rest of the circuits are intended for device status indication (DTR, DSR), transmission control (RTS, CTS) and line status indication (CD, RI). A complete set of circuits is used only for connecting an external modem to a PC. In other cases, for example, when connecting an industrial controller to a PC, a limited set of circuits is used, depending on the hardware and software implementation of the interface in the controller.

RS-232 cable diagram

As mentioned above, a pin-to-pin cable is required to connect strictly standardized DTE and DCE devices. To connect two DTE devices, so-called null-modem cables are used, in which the wires are "crossed" in accordance with the purpose of the signals. In practice, before unsoldering the cable, you should always read the documentation for both devices to be connected.

The start bit is always at the logical zero level, the stop bit is at one. The state of the parity bit is determined by the transmitter setting. Bit complements the number of single data bits to odd (parity odd), parity (parity even), may not be used (parity none), always be one (mark) or zero (space).

Perspectives

In fact, RS-232 has no prospects. Currently, there are more and more computers that are not equipped with this interface. However, a large number of devices with RS-232 interface are in operation. To dock a PC with such devices, USB - RS-232 adapters are used.

After connecting such an adapter and installing the drivers, a virtual COM port appears in the PC, through which you can communicate with the device.

The RS-232C interface is designed to connect equipment transmitting or receiving data (DTE - data terminal equipment, or ATD - data transmission equipment; DTE - Data Terminal Equipment), to the terminal equipment of data channels (DCE; DCE - Data Communication Equipment). The ADF can be a computer, printer, plotter and other peripheral equipment. The DCE is usually a modem. The ultimate purpose of a connection is to connect two ADF devices. The complete connection diagram is shown in Fig. 1; the interface allows you to eliminate the remote communication channel along with a pair of DCE devices by connecting the devices directly using a null modem cable (Figure 2).

Fig. 1. Complete RS-232C Connection Diagram


Fig. 2. RS-232C connection with null modem cable

The standard describes interface control signals, data transfer, electrical interface, and connector types. The standard provides for asynchronous and synchronous exchange modes, but COM ports only support asynchronous mode. Functionally RS-232C is equivalent to CCITT V.24 / V.28 standard and C2 interface, but they have different signal names.

The RS-232C standard describes single-ended transmitters and receivers - the signal is transmitted with respect to the common wire - the circuit ground (balanced differential signals are used in other interfaces - for example, RS-422). The interface does not provide galvanic isolation of devices. A logical unit (MARK state) at the data input (RxD signal) corresponds to a voltage range from –12 to –3 V; logical zero - from +3 to +12 V (SPACE state). For control signal inputs, the ON state corresponds to the range from +3 to +12 V, the OFF state (“off”) - from –12 to –3 V. receiver hysteresis: the line state will be considered changed only after crossing the threshold (Fig. 3). The signal levels at the outputs of the transmitters should be in the ranges from –12 to –5 V and from +5 to +12 V. The potential difference between the circuit grounds (SG) of the connected devices should be less than 2 V, with a higher potential difference, incorrect perception of signals is possible ... Note that TTL level signals (at the inputs and outputs of UART microcircuits) are transmitted in direct code for the TxD and RxD lines and in inverse code for all others.

The interface assumes a protective earth ground for the devices to be connected if they are both supplied with AC power and have line filters.

ATTENTION

Connecting and disconnecting interface cables of self-powered devices should be done with power off. Otherwise, the difference in unbalanced potentials of devices at the moment of switching may be applied to the output or input (which is more dangerous) interface circuits and damage the microcircuit.

The RS-232C standard regulates the types of connectors used.

It is customary to install DB-25P plugs or a more compact version - DB-9P on ADF equipment (including COM ports). Nine-pin connectors do not have additional signal pins required for synchronous operation (most 25-pin connectors do not use these pins).

On the AKD equipment (modems), DB-25S or DB-9S sockets are installed.

This rule assumes that the DCE connectors can be connected to the ADF connectors either directly or through female-to-male straight through cables that have one-to-one pins connected. Adapter cables can also be adapters from 9 to 25-pin connectors (Fig. 4).

If the ADF equipment is connected without modems, then the device connectors (plugs) are interconnected by a null-modem cable (Zero-modem, or Z-modem), which has sockets at both ends, the contacts of which are cross-connected according to one of the diagrams shown in Fig. 5.


Rice. 3. Receiving RS-232C signals

Rice. 4. Cables for connecting modems


Rice. 5. Null-modem cable: a - minimum, b - full

If an outlet is installed on any ADF device, this is almost 100% of the fact that it should be connected to another device with a straight cable, similar to the modem connection cable. The socket is usually installed on those devices for which a remote connection via a modem is not provided.

Table 1 shows the purpose of the contacts of the connectors of the COM ports (and any other equipment for transferring data from the ADF). The pins of the DB-25S connector are defined by the EIA / TIA-232-E standard, the DB-9S connector is described by the EIA / TIA-574 standard. For modems (DCE), the names of circuits and contacts are the same, but the roles of signals (input-output) are reversed.

Table 1. Connectors and signals of the RS-232C interface

Chain designation

Connector pin

PC cable wire No.

Direction

1 8-bit multicard ribbon cable.
2 Ribbon cable for 16-bit multicards and ports on motherboards.
3 Port ribbon cable option on motherboards.
4 Wide ribbon cable to 25-pin connector.

Let's consider a subset of RS-232C signals related to asynchronous mode from the point of view of the PC COM port. For convenience, we will use the mnemonics of names adopted in the descriptions of COM ports and most devices (it differs from the impersonal designations RS-232 and V.24). Recall that the active state of control signals (“on”) and the zero value of the transmitted data bit correspond to a positive potential (above +3 V) of the interface signal, and the “off” state and a single bit correspond to a negative potential (below –3 V). The purpose of the interface signals is shown in table. 2. The normal sequence of control signals for the case of connecting a modem to a COM port is illustrated in Fig. 6.

Table 2. Purpose of RS-232C interface signals

Appointment

Protected Ground - protective ground, connects to the body of the device and the shield of the cable

Signal Ground - signal (circuit) ground, relative to which the signal levels act

Transmit Data - serial data - transmitter output

Receive Data - serial data - receiver input

Request To Send - data transfer request output: the “on” state notifies the modem that the terminal has data for transmission. In half duplex mode, used for direction control - the “on” state signals the modem to switch to transmit mode.

Clear To Send - input allowing the terminal to send data. The off state prohibits data transmission. The signal is used for hardware flow control

Data Set Ready - ready signal input from the data transmission equipment (the modem is connected to the channel in operating mode and has completed actions as agreed with the equipment at the opposite end of the channel)

Data Terminal Ready - signal output of the terminal ready for data exchange. The “on” state keeps the dial-up link in a connected state

Data Carrier Detected - remote modem carrier detection signal input

Ring Indicator - call indicator input. In a switched channel, the modem signals the acceptance of the call with this signal.


Rice. 6. Sequence of interface control signals

  1. By setting DTR, the computer indicates that it wants to use the modem.
  2. By setting DSR, the modem signals its readiness and connection establishment.
  3. With the RTS signal, the computer requests permission to transmit and declares its readiness to receive data from the modem.
  4. With the CTS signal, the modem notifies of its readiness to receive data from the computer and transmit it to the line.
  5. By removing the CTS, the modem signals the impossibility of further reception (for example, the buffer is full) - the computer must suspend data transmission.
  6. With the CTS signal, the modem allows the computer to continue transmission (space has appeared in the buffer).
  7. Removing RTS can mean both the filling of the computer's buffer (the modem must suspend the transfer of data to the computer), and the lack of data to transfer to the modem. Usually, in this case, the modem stops sending data to the computer.
  8. The modem confirms the removal of the RTS by resetting the CTS.
  9. The computer re-sets the RTS to resume transmission.
  10. The modem confirms its readiness for these actions.
  11. The computer indicates the completion of the exchange.
  12. The modem responds with an acknowledgment.
  13. The computer picks up the DTR, which is usually a signal to disconnect (hang up).
  14. The modem by resetting the DSR signals the disconnection.

By looking at this sequence, the DTR-DSR and RTS-CTS connections on null modem cables are clear.

Asynchronous transfer mode

Asynchronous transfer mode is byte-oriented (character-oriented): the smallest unit of information transmitted is one byte (one character). The format of sending a byte is illustrated in Fig. 7. The transmission of each byte begins with a start bit signaling the receiver to start sending, followed by data bits and possibly a parity bit. Completes the transmission with a stop bit, which guarantees a pause between transmissions. The start bit of the next byte is sent at any moment after the stop bit, that is, pauses of arbitrary length are possible between transmissions. The start bit, which always has a strictly defined value (logical 0), provides a simple mechanism for synchronizing the receiver with the signal from the transmitter. It is assumed that the receiver and transmitter operate at the same baud rate. The receiver's internal clock uses a reference frequency divider counter that is reset when the start bit is received. This counter generates internal strobes that the receiver latch on to subsequent received bits. Ideally, strobes are located in the middle of the bit intervals, which allows data to be received even with a slight mismatch between the receiver and transmitter rates. Obviously, when transmitting 8 data bits, one control bit and one stop bit, the maximum allowable speed mismatch, at which the data will be recognized correctly, cannot exceed 5%. Taking into account the phase distortion and discreteness of the internal synchronization counter, a smaller frequency deviation is actually permissible. The smaller the division factor of the reference frequency of the internal oscillator (the higher the transmission frequency), the greater the error in aligning the strobes to the middle of the bit interval, and the requirements for frequency consistency become more stringent. The higher the transmission frequency, the greater the influence of edge distortions on the phase of the received signal. The interaction of these factors leads to an increase in the requirements for the consistency of the frequencies of the receiver and transmitter with an increase in the exchange frequency.


Fig. 7. Asynchronous transmission format RS-232C

The asynchronous send format allows you to detect possible transmission errors.

  • If a drop is received, signaling the beginning of a message, and a logic-one level is fixed by the start-bit strobe, the start-bit is considered false and the receiver switches to the waiting state again. The receiver may not report this error.
  • If a logic zero level is detected during the stop bit time, a stop bit error is generated.
  • If parity is used, a check bit is transmitted after the data bit has been sent. This bit pads the number of single data bits to odd or even, depending on the accepted convention. Reception of a byte with an incorrect check bit value leads to an error fixation.
  • The format control allows detecting a line break: as a rule, upon a break, the receiver “sees” a logical zero, which is first interpreted as a start bit and zero data bits, but then the stop bit control is triggered.

For the asynchronous mode, a number of standard baud rates are accepted: 50, 75, 110, 150, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600 and 115200 bps. Sometimes baud is used instead of bit / s, but this is not correct when considering binary transmitted signals. In baud, it is customary to measure the frequency of the line state change, and with a non-binary coding method (widely used in modern modems) in the communication channel, the bit rate (bit / s) and signal changes (baud) can differ several times.

The number of data bits can be 5, 6, 7, or 8 (5- and 6-bit formats are not very common). The number of stop bits can be 1, 1.5 or 2 (“one and a half bits” means only the length of the stop interval).

Data flow control

To control the flow of data (Flow Control), two protocol options can be used - hardware and software. Sometimes flow control is confused with handshaking. Handshaking involves sending a notification that an item has been received, while flow control involves sending a notification that data can or cannot be received later. Often, flow control is based on a handshake mechanism.

Hardware flow control (RTS / CTS) uses the CTS signal to stop data transmission if the receiver is not ready to receive it (Figure 8). The transmitter “releases” the next byte only when the CTS line is on. A byte that has already begun to be transmitted cannot be delayed by the CTS signal (this guarantees the integrity of the message). The hardware protocol provides the fastest transmitter response to receiver status. Asynchronous transceiver microcircuits have at least two registers in the receiving part - a shift register, for receiving the next message, and a storage register, from which the received byte is read. This makes it possible to implement exchange using the hardware protocol without data loss.


Fig. 8. Hardware flow control

The hardware protocol is useful when connecting printers and plotters if they support it. When connecting two computers directly (without modems), the hardware protocol requires an RTS to CTS crossover.

With a direct connection, the transmitting terminal must have an “on” state on the CTS line (by connecting its own RTS-CTS lines), otherwise the transmitter will be “silent”.

The 8250/16450/16550 transceivers used in the IBM PC do not process the CTS signal in hardware, but only show its state in the MSR register. The implementation of the RTS / CTS protocol is assigned to the BIOS Int 14h driver, and it is not entirely correct to call it “hardware”. If the program using the COM port interacts with the UART at the register level (and not through the BIOS), then it handles the processing of the CTS signal to support this protocol itself. A number of communications programs allow the CTS signal to be ignored (unless a modem is used) and do not require the CTS input to be connected to the output of even their RTS signal. However, there are other transceivers (for example, 8251) in which the CTS signal is processed in hardware. For them, as well as for "honest" programs, the use of the CTS signal on the connectors (and even on the cables) is mandatory.

The XON / XOFF software flow control protocol assumes a bidirectional data link. The protocol works as follows: if the device receiving the data detects the reasons why it cannot receive them further, it sends the XOFF byte-symbol (13h) on the reverse serial channel. The opposite device, having received this character, suspends the transmission. When the receiving device becomes ready to receive data again, it sends an XON (11h) character, upon receipt of which the other device resumes transmission. The response time of the transmitter to a change in the state of the receiver in comparison with the hardware protocol increases, at least by the time of transmission of a character (XON or XOFF) plus the response time of the transmitter software to receive a character (Fig. 9). It follows from this that lossless data can only be received by a receiver that has an additional buffer of received data and signals that it is not ready in advance (having free space in the buffer).


Fig. 9. XON / XOFF software flow control

The advantage of the software protocol is that there is no need to transmit interface control signals - the minimum cable for two-way exchange can have only 3 wires (see Fig. 5, a). The disadvantage, in addition to the mandatory presence of a buffer and a longer response time (reducing the overall performance of the channel due to waiting for the XON signal), is the complexity of the implementation of the full-duplex exchange mode. In this case, flow control symbols must be extracted (and processed) from the received data stream, which limits the set of transmitted symbols.

In addition to these two common standard protocols supported by both the CP and the OS, there are others.

Rs-232 Is the name of the standard (RS is the recommended standard, 232 is its number), which was developed in the 60s of the last century for connecting external devices (printer, scanner, mouse, etc.) to a computer, as well as connecting computers with each other. The RS-232 interface was designed to connect two types of devices: terminal and communication. Terminal equipment (DTE), such as a computer, can send or receive data over a serial interface. Communication equipment (DCE) is understood as a device that can practically implement serial data transmission.

Most often, a modem is used as a DCE, which organizes the exchange of information using telephone lines. It is also possible to connect two DTE devices, for example, computers, directly using the RS-232 interface without using modems. The RS-232 standard describes the types and parameters of signals, methods of their transmission, types of connectors.

ConnectorsRs-232. The 25-pin DB-25 connector or the smaller 9-pin version of the DB-9 is used.

SignalsRs-232. The standard provides for asynchronous and synchronous exchange modes, but currently only asynchronous is used in practice, especially since COM ports support only asynchronous mode. The interface has two lines of serial data signals: TxD - transmitted and RxD - received, as well as several lines of control signals: RTS and CTS - the first pair of handshake, DTR and DSR - the second pair of handshake, DCD and RI - modem status signals. There is a common SG-signal ground and PG-protective ground (housing).

The interface uses an unbalanced signaling method with single-ended transmitters and receivers. The connection of the transmitter and receiver is shown in Fig. 14.1, where the following conventions are adopted: T (Transmitter) - transmitter; R (Receiver) - receiver; TI (TransmitterInput) - digital input of the transmitter; RO (ReceiverOutput) - digital output of the receiver; UT - line voltage at the output of the transmitter and U R - at the input of the receiver.

Rice. 14.1. Connecting transmitter and receiver in the RS-232 interface

The signal levels at the outputs of the transmitters should be in the range from -15 to -5 V to represent a logical 1 and in the range from +5 to +15 V to represent a logical 0. In practice, the voltage of the logical signal levels does not exceed ± 12 V.

Data transfer formats. The RS-232 interface uses an asynchronous serial data transfer method. In the absence of transmission of messages, the data lines are in the state of logical 1. Messages are transmitted in frames. Each frame consists of a start bit, data bits, a parity bit, and stop bits. The start bit always has a logic level 0. The number of data bits according to the standard can be 5, 6, 7 and 8. Most often 8 or 7 bits are used. Number of stop bits: 1 or 2. Stop bits are always at logic level 1. Data bits are transmitted starting with the least significant one. The baud rate in RS-232 can be selected from the range: 110, 150, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 bps. Synchronization of the receiver's generator is carried out at the moment the start-bit arrives from the communication line from the transmitter.

To convert parallel data to serial and vice versa, devices connected to the RS-232 interface must have a universal asynchronous UART transceiver module. This module works, as a rule, with TTL-level signals. Transmitters and receivers are used to convert these signals to RS-232 levels and vice versa.

Connecting interface devices. The RS-232 standard assumes direct connection of the pins of the connectors of DTE and DCE devices. If DTE equipment, for example, two computers are connected without modems, then their connectors are connected together with a null modem cable. In this case, several connection options are possible. In fig. a shows a connection with a complete handshake protocol. It requires 7 wires of the cable. In fig. b is an example of a null modem connection that requires only three cable wires for bidirectional communication. In order for devices to transmit data over the interface, their RTS outputs are connected to their CTS inputs, and their DTR outputs to their DSR and DCD inputs. Thus, both DTE-1 and DTE-2 will always be ready for transmission.

Connecting computers with a null modem cable:

a) - with a complete acknowledgment protocol; b) - without acknowledgment signals

Data flow control means the ability to stop and then resume data transmission without losing it. Two protocol options can be used: hardware and software.

The hardware flow control protocol typically uses an RTS / CTS handshake signal pair. In this case, the RTS pin of the connector of one device is connected to the CTS pin of the connector of the other device. In fig. 14.3, a shows a diagram of connecting a DTE-1 device (for example, a computer) to a DTE-2 device (for example, a printer or controller) in one-way transmission.

When the receiver (DTE-2) is ready to receive, it asserts a signal on its RTS connector pin. The transmitter (DTE-1), having received this signal on the CTS pin of its connector, transmits the next data byte. If the CTS signal at the transmitter connector is cleared, it stops transmitting. A message that has already begun to be transmitted cannot be delayed by the CTS signal. If bidirectional transmission (full duplex) is required, then the hardware protocol requires a cross-connect of the RTS and CTS lines, as shown in Fig. 14.3, b.

The software flow control protocol consists of the receiving end sending the special characters to stop transmission XOFF and resume transmission XON. This assumes the presence of a bidirectional data exchange channel. The operation of this protocol can be described as follows. The transmitter sends data to its TxD pin, and the receiver receives it from the RxD pin of its connector. If the receiving device cannot receive data, then it sends an XOFF byte-symbol to the communication line (TxD pin). The transmitter, having received this character from the RxD pin, stops the transmission. Then, when the receiving device is ready to receive data again, it sends an XON byte character. Having received it, the transmitting device resumes transmission.

Rice. 14.3. Connection of two DTEs with RTS / CTS hardware flow control protocol: a) - with one-way transmission; b) - with two-way transmission

Length of the connecting cable. The length of the cable affects the maximum data transfer rate. The maximum length of a standard cable is 15 meters at a baud rate of 19200 bps. By reducing the transmission speed, the cable length can be significantly increased.

Advantages of the interface Rs -232 : a large fleet of operating equipment using this standard; simplicity and low cost of the connecting cable; simplicity and availability of software for working with the interface.

Disadvantages of the interface : low exchange rate; short length of the connecting cable; low noise immunity; the interface is designed to connect, as a rule, only two devices (transmitter and receiver).