Current location - Quotes Website - Team slogan - Rs232 interface definition
Rs232 interface definition
RS232 interface is widely used for peripheral connection of computer serial interface. In RS-232C standard, EIA stands for American Electronics Industry Association, RS stands for recommended standard, 232 stands for identification number, and C stands for the third edition of RS232 (1969). Before that, there were RS23B and RS23A. The following is the definition of rs232 interface that I brought to you. Welcome to read!

Rs232 interface definition diagram:

Rs232 interface definition: DB9

Upper left corner 1, lower right corner 9.

RS232 interface

1 DCD carrier detection

2 RXD receiving data

3 TXD sends data.

DTR data terminal 4 is ready.

5 SG signal grounding

The data of 6 DSR is ready

7 RTS request sending

8 CTS allows sending.

9 RI ringing prompt

DB25

1 shielded ground wire

2 TXD sends data.

3 RXD receiving data

4 RTS request sending

5 CTS allows sending.

The data of 6 DSR is ready

7 SG signal grounding

8 DCD carrier detection

9 send Return (+)

10 is undefined.

1 1 data transmission (-)

12~ 17 is undefined.

18 data reception (+)

19 is undefined.

20 data data terminal ready

2 1 undefined.

22 ringing ri

23~24 undefined

25 details of receiving return (-) standard

DB25 to DB9

In RS-232 standard, characters are transmitted one by one in series, which has the advantages of few transmission lines, simple wiring and long transmission distance. The most commonly used encoding format is asynchronous start-stop format, which uses a start bit followed by 7 or 8 data bits, followed by an optional parity bit, and finally one or two stop bits. Therefore, sending a character requires at least 10 bits, which brings a good effect that the total transmission rate and the rate of sending signals are divided by 10. One of the most common alternatives to asynchronous start-stop mode is to use high-level data link control Protocol (HDLC).

In RS-232 standard, logic 1 and logic 0 voltage series, standard transmission rate and connector type are defined. The signal size is between plus and minus 3- 15v. RS-232 stipulates that the level close to zero is invalid, logic one is negative, and the signal state of effective negative level is called signal mark, which means OFF, logic zero is positive, and the signal state of effective positive level is called space spacing, which means on. Depending on the power supply of the equipment, 5, 10,? 12 What else? 15 level is possible.

Mark and blank are terms of teletypewriter. The initial communication of teletypewriter is a simple way to interrupt DC circuit, similar to the signal when dialing with rotary telephone. The marked state indicates that the circuit is off, and the interval state indicates that the circuit is on. A space indicates that a character is about to start sending, and when it stops, the stop bit is being marked. When the line is interrupted, the teletypewriter does not print any valid characters, but periodically receives all-zero signals continuously.

RS-232 was originally designed to be connected to a modem for transmission, so its pin meaning is usually related to modem transmission. The equipment of RS-232 can be divided into two categories: data terminal equipment (such as DTE, PC) and data communication equipment (DCE). This classification defines different lines for sending and receiving signals. Generally speaking, computers and terminal devices have DTE connectors, and modems and printers have DCE connectors. However, this is not always strictly correct. It is often necessary to refer to relevant documents to test the connection with the distribution tap, or to judge whether the cable works by trial and error.

RS-232 specifies 20 different signal connections, and DB-25 connector consists of 25 D-sub pins. Many devices use only a small number of pins. In order to save money and space, many machines use smaller connectors, especially 9-pin D-sub or DB-9 connectors, which are widely used in most PCs and many other devices after IBM's AT machines. DB-25 and DB-9 connectors are female interfaces on most devices, but not all devices are female interfaces. 8-pin RJ-45 connectors are becoming more and more popular, although their pin assignments are quite different. EIA/TIA 56 1 standard stipulates a pin allocation method, but yost serial device wiring standard invented by Dave yost and widely used in Unix computers and many other devices does not adopt any of the above wiring standards.

The following table lists the signal and pin assignments in the widely used RS-232:

DB9 male (pin side) DB9 female (pin side)

- -

\ 1 2 3 4 5 / \ 5 4 3 2 1 /

\ 6 7 8 9 / \ 9 8 7 6 /

-signal DB-25 DB-9 EIA/TIA 56 1 yost.

* * * Grounding 7 5 4 4 5

Send data (TD) 2 3 6 3

Received data (RD) 3 2 5 6

Data Terminal Preparation (DTR) 20 4 3 2

Data ready (DSR) 6 6 1 7

Request to send (RTS) 4 7 8 1

Clear Send (Contact Type) 5 8 7 8

Data carrier detection (DCD) 8 1 2 7

Ringing indicator (RI) 22 9 1-

TXD DTE-& gt; DCE DTE sends data

RXD·DCE->; receive data

RTS DTE-& gt; DCE DTE request sending

DCE China Travel Service->; DTE confirmation of DTE RTS

DSR·DCE->; DCE is ready.

GND

DCD·DCE->; DTE DC detected.

DTR DTE-& gt; DCE DTE is ready

In DCE->; DTE ringing indication

The marking of signals is from the perspective of DTE equipment. TD, DTR and RTS signals are generated by DTE, while RD, DSR, CTS, DCD and RI signals are generated by DCE. All connections share a ground signal. In yost standard, there are two pins outside the ground signal, which are actually the same signal. If the distance between two communication devices is far away, or there are two different power supply systems, the ground signals between the two devices will be different, resulting in communication failure. It is difficult to track and describe this situation.

electric cable

Because of various differences and contradictions in the implementation of RS-232, it is not easy to decide which suitable cable to use to connect two communication devices. Using the same type of connectors to connect DCE and DTE devices requires direct cables and suitable terminals. Concave-convex converter is used to solve the problem of gender mismatch between cable and connector. According to the above table, using different connectors to connect devices requires using different cables to connect the corresponding pins. It is common for a cable to have 9 pins at one end and 25 pins at the other end. Equipment manufacturers that produce RJ-45 connectors usually provide cables with DB-25 or DB-9 connectors (sometimes cables with interchangeable connectors can be used for various devices).

Connecting two DTE devices requires a virtual modem as DCE to exchange corresponding signals (TD-RD, DTR-DSR and RTS-CTS). This can be achieved by a single device plus two cables or one cable. The virtual modem in yost standard is a total reflection line, which flips the 1 pin of one port to 8 pins and connects the 8 pin of another port to the 1 pin (not to be confused with Ethernet twisted pair, which is quite different).

In order to configure and diagnose RS-232 cable, distribution tap can be used. The wiring tap has concave-convex RS-232 connectors, which can be embedded in the connection lines, provide display lights corresponding to each pin, and connect pins with various configurations.

RS-232 cable and many connectors can be found in electronics stores. Cables may have 3 to 25 pins, and typical applications are 4 to 6 pins. Flat RJ (telephone line type) cable can be used with special RJ-RS-232 connector, which is the easiest connector to configure.

Because all signals of RS-232 share a common ground, the bidirectional interface can be made of only three wires. The unbalanced circuit makes RS-232 very vulnerable to the base point voltage shift between two devices. For the rising and falling periods of signals, the control ability of RS-232 is also relatively poor, which is prone to crosstalk problems. It is recommended to use RS-232 for short-distance communication (within 15m). Due to circuit asymmetry, RS-232 interface cable is usually not twisted pair. [3]

Need some more equipment? Shake hands? Agreements, such as the 20-gauge needle, are generally used to express? Is the equipment ready? . The pin can also be skipped or connected back from the connector. For example, a pin of device A sends a signal to ask the other party? Are you ready? If device b does not send such an indication signal. Male handshake pins are 20, 8, 4 and 6.

build

Serial communication requires a number of settings in the software settings. The most common settings include baud rate, parity and stop bit.

Baud rate (also known as baud rate): refers to the baud rate from one device to another, that is, how many bits per second (bit/s). Typical baud rates are 300, 1200, 2400, 9600, 1 15200, 19200, etc. In general, the devices at both ends of communication should be set to the same baud rate, but some devices can also be set to automatically detect the baud rate.

Parity is used to verify the correctness of data. Parity is generally not used, and if it is used, parity can be used. Parity works by modifying each transmitted byte (or limiting the transmitted bytes). If the parity is not checked, the data will not change. In even parity, because the parity bit will be set to 1 or 0 (usually the most significant bit or the least significant bit), the data will change so that all transmitted digits (including every digit and parity bit of a character) are? 1? The number of is even; In odd check, among all transmitted numbers (including parity bits of each number and a character)? 1? The number of is odd. The receiver can use parity to check whether the transmission has errors. What if it's in a byte? 1? There is an error in the number of, then there must be an error in the transmission of this byte. If the parity check is correct, then either no error occurred or an even number of errors occurred. If the user chooses that the data length is 8 bits, it is called. Because no extra bits are used as the same bits. Non-parity check .

Stop bit: sent after each byte transmission to help the hardware of the receiver resynchronize.

When transmitting data, RS-232 can transmit data to the other side correctly and smoothly without using another transmission line to transmit synchronization signals, so it is called? Asynchronous transmission? UART (Universal Asynchronous Receiver Transmitter) for short, but it is necessary to add a synchronization signal before and after each data, mix the synchronization signal with the data, and use the same transmission line for transmission. For example, when transmitting data11001010, you need to add two bits of Start (low) and Stop (high) before and after the data. It is worth noting that the start signal is fixed to one bit, but the stop bit can be 1, 1.5 or. D/P/S is a conventional symbol in serial communication software settings. 8/N/ 1 (very common) means 8-bit data without parity, and 1 bit stop bit. Data bits can be set to 7, 8 or 9, parity bits can be set to none (n), odd (o) or even (e), and parity can use bits in data, so 8/E/ 1 means a ***8-bit data bit, and one bit is used as parity bit. The stop bit can be 1, 1.5 or 2 bits (1.5 is used for teletypewriters with baud rate of 60wpm).

Flow control: When handshake signal or data integrity detection is needed, other settings need to be made. Common combinations are RTS/CTS, DTR/DSR XON/XOFF (actually inserting special characters into the data stream without using connector pins).

The receiver sends XON/XOFF signal to the transmitter to control when the transmitter sends data. These signals are transmitted in the opposite direction to the transmitted data. The XON signal tells the sender that the receiver is ready to accept more data, and the XOFF signal tells the sender to stop sending data until it knows that the receiver is ready again. XON/XOFF is generally not used, and RTS/CTS control flow is suggested to be used instead. XON/XOFF is an in-band mode, which works between terminals, but it must be supported at both ends. Sudden startup may cause confusion. XON/XOFF can work on three-wire interface. RTS/CTS was originally designed for half-duplex cooperative communication between teletypewriter and modem, and only one modem can send data at a time. The terminal must send a request signal and then wait until the modem responds to the clear signal. Although RTS/CTS realizes handshaking through hardware, it also has its own advantages.

Automatic transceiver teletypewriter has a paper tape reader. The card reader sends and submits characters when reading data. When ASR teletypewriter receives the XOFF character, it turns off the paper tape reader, and when it receives the XON character, it turns on the paper tape reader. When the remote system needs to slow down the sending and playing rate, it will send out XOFF. In the original system, information must be prepared with paper tape in advance, and the transmission time can be shortened. At that time, the bandwidth was very limited and expensive, and sometimes transmission had to be postponed until evening, which also promoted the development of concise telegraph expression. In some early minicomputers, ASR paper tape reader and paper tape punch were also the only ways to restore the program.

RS232 serial line interface and connection: RS232 serial line is widely used for serial communication between devices. RS232 serial connection depends on the situation.

RS232 serial line is a DB9 pin, and its pin is defined as follows:

Face to face, face up, a row of 5 stitches (upward): male head from left to right 12345, female head from right 2 to left 12345. A row of 4 stitches (downward): male head from left to right 6789, female head from right to left 6789.

The color definition of RS232 serial line is also different, and the definition of each manufacturer is slightly different.

Generally defined by color is:

1 Black 2 Brown 3 Red 4 Orange 5 Yellow 6 Green 7 Blue 8 Purple 9 White

RS232 serial connection modes: direct connection and cross connection.

Under normal circumstances, the connection and communication between equipment and computer need RS232 serial line to connect directly. And the communication between devices will use the cross line of RS232 serial port. When selecting, users should choose different RS232 serial ports according to the actual connection of two devices.

?