banner
Home » Knowledge » Content
Product Categories

PDA RS232 interface

- Apr 11, 2018 -

RS232 interface

The RS-232 interface conforms to the serial data communication interface standard defined by the Electronic Industries Alliance (EIA). The original serial number is EIA-RS-232 (232, RS232). It is widely used for computer serial interface peripheral connections. Connect cables and mechanical, electrical characteristics, signal functions, and transmission processes.

In the RS-232 standard, characters are transmitted serially one by one in a serial bit string. The advantage is that there are few transmission lines, the wiring is simple, and the transmission distance can be far. The most commonly used encoding format is the asynchronous start-stop format, which uses a start bit followed by 7 or 8 data bits, followed by optional parity bits, and finally one or Two stop bits. Therefore, sending a character requires at least 10 bits, and a good effect is to divide the transmission rate by 10 at the rate of the transmission signal. One of the most common alternatives to asynchronous start and stop is the use of Advanced Data Link Control Protocol (HDLC).

The logic level 1 and logic 0 voltage levels are defined in the RS-232 standard, as well as the standard transmission rate and connector type. The signal size is between positive and negative 3-15v. RS-232 specifies that the level close to 0 is invalid, logic 1 is defined as a negative level, the signal state of a valid negative level is called mark marking, its functional meaning is OFF, logic 0 is defined as a positive level, effective positive charge The flat signal state is called space spacing and its function meaning is ON. Depending on the device power supply, levels such as ±5, ±10, ±12, and ±15 are possible.

Mark and space are terms from Teletype. The original communication of the teletypewriter is a simple interrupted DC circuit mode, similar to the signal in a dial with a round dial telephone. The Marking state means that the circuit is disconnected, and the spacing state means that the circuit is switched on. A space indicates that there is a character to start sending. When the corresponding stop occurs, the stop bit is marking. When the line is interrupted, the teletypewriter does not print any valid characters and receives all 0s continuously in a periodic manner.

The RS-232 design was originally used to connect a modem for transmission, and its pin meaning is therefore usually related to modem transmission. RS-232 equipment can be divided into data terminal equipment (DTE), data communication equipment (DCE), and data communication equipment (DCE). This classification defines different lines for sending and receiving. signal. In general, computers and terminal devices have DTE connectors, and modems and printers have DCE connectors. However, this is not always strictly true. Testing the connection with a wiring tap, or using trial and error to determine if the cable is working, often requires reference to the relevant documentation.

RS-232 specifies 20 different signal connections, DB-25 connectors consisting of 25 D-sub (mini D-type) pins. Many devices only use a small number of pins. For reasons of saving money and space, many machines use smaller connectors, especially the 9-pin D-sub or DB-9 connectors are widely used. Uses most PCs and many other devices behind IBM's AT machines. DB-25 and DB-9 type connectors are female on most devices, but not all of them are. Recently, the 8-pin RJ-45 connector has become more and more popular, although its pin assignments are very different. The EIA/TIA 561 standard specifies a pin assignment method, but the Yost Serial Device Wiring Standard widely used by Dave Yost on Unix computers and many other devices No one of the above connection standards has been adopted.

cable

Due to various differences and contradictions in the implementation of RS-232, it is not easy to decide which suitable cable to use to connect the two communication devices. Connecting the DCE and DTE devices with the same type of connector requires a straightforward cable with a suitable end point. Bump converters are used to solve gender mismatches between cables and connectors. To connect devices with different connectors, use the different cables to connect the corresponding pins according to the above table. It is common for one end of the cable to have 9 pins and the other end to have 25 pins. Equipment manufacturers that use the RJ-45 type connector usually provide DB-25 or DB-9 connector cables (sometimes the connectors are interchangeable). The cable can be used for a variety of devices.

Connecting two DTE devices requires a virtual modem to act as the DCE exchange corresponding signal (TD-RD, DTR-DSR, and RTS-CTS). This can be done with a separate device plus two cables or with a single cable. In the YOST standard, the virtual modem is an all-in-one. It flips the 1-to-8 pin of one port to the 8-to-1 pin of the other port. Stranded wiring is very different).

For configuring and diagnosing the RS-232 cable, a wire tap connector can be used. Wiring taps have a concave-convex RS-232 connector that can be embedded in the connection line, and provide a corresponding display lamp for each pin, you can also connect the pins in various configurations.

RS-232 cables and many connectors can be found in electronics stores. Cables may be 3 to 25 pins, typically 4 to 6 pins. The flat RJ (phone line type) cable can be used with a dedicated RJ-RS-232 connector, which is the easiest connector to configure.

The bidirectional interface can only require 3 wires because all signals of RS-232 share a common ground. The unbalanced circuit makes RS-232 very easy to be affected by the voltage offset between the two devices. For the rising and falling periods of the signal, the RS-232 also has relatively poor control capability, and it is prone to crosstalk problems. RS-232 is recommended to communicate between short distances (within 15m). Because of the asymmetrical circuit, the RS-232 interface cable is usually not made of twisted pairs.

Some devices also require a "handshake" protocol. For example, pin 20 is generally used to indicate "device is ready". Pins can also be skipped or pulled back from the connector. For example, a pin of device A sends a signal asking the other party "Are you ready?" if device B did not send such an indicator. The common handshaking pins are 20, 8, 4 and 6.

Settings

Serial Communications Several settings are required in the software setup. The most common settings include Baud Rate, Parity Check, and Stop Bit.

Baud rate (also called baud rate): It refers to the baud rate sent from one device to another device, that is, how many bits per second (bit/s) per second. The typical baud rate is 300, 1200, 2400, 9600, 15200, 19200 and other bit/s. Generally, both ends of the communication device must be set to the same baud rate, but some devices can also be set to automatically detect the baud rate.

Parity: It is used to verify the correctness of data. Parity is not normally used. If it is used, Odd Parity or Even Parity can be used. Parity Check It works by modifying each send byte (which can also limit the number of bytes sent.) If you do not do parity, then the data will not be changed. In even parity, because the parity bit will be Is set to 1 or 0 (usually the most significant bit or the least significant bit), so the data will be changed so that the number of "1"s in all transmitted digits (including the digits and the check digits of the characters) is an even number; During the verification, the number of “1”s in all transmitted digits (including digits and check digits of characters) is an odd number.Parity check can be used by the receiver to check if the transmission sends a raw error—if a byte If there is an error in the number of "1," then there must be an error in the transmission of the byte. If the parity is correct, then either no error or an even number of errors occurs. If the user chooses a data length of 8 Bit Then since no extra bits can be used as an Laid, therefore it is called "bit (Non Parity)".

Stop bit: It is sent after each byte transmission. It is used to help accept signal side hardware resynchronization.

When RS-232 transmits data, it does not need to use another transmission line to transmit the synchronization signal, and it can correctly transmit the data to the other party. Therefore, it is called "Asynchronous Transmission", or UART (Universal Asynchronous Receiver Transmitter), but it must be A synchronization signal is added before and after each piece of data. After the synchronization signal is mixed with the data, the same transmission line is used for transmission. For example, when data 11001010 is transmitted, two bits, Start (Low) and Stop (High), need to be added before and after the data. It is worth noting that the Start signal is fixed to one bit, but the Stop stop bit can be 1, 1.5 or It is 2 bits, which is selected by both RS-232 transmission and reception, but it must be noted that the choice of both transmission and reception must be the same. D/P/S is a regular symbolic representation in the serial communication software setup. 8/N/1 (very common) indicates 8 bit data, no parity, 1 bit stop bit. The data bit can be set to 7, 8 or 9, the parity bit can be set to none (N), odd (O), or even (E). The parity can use the bits in the data, so 8/E /1 represents a total of 8 data bits, one of which is used to make a parity bit. The stop bit can be 1, 1.5 or 2 bits (1.5 is used on teletypes with a baud rate of 60 wpm).

Flow control: Other settings need to be made when it is necessary to send handshaking signals or data integrity checks. The common combination is RTS/CTS, DTR/DSR, or XON/XOFF (In practice, connector pins are not used and special characters are inserted in the data stream).

The receiver sends the XON/XOFF signal to the sender to control when the sender sends data, which is in the opposite direction of the transmission of 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 recipient is ready again. XON/XOFF is generally deprecated and it is recommended to replace them with RTS/CTS control streams. XON/XOFF is an in-band method that works between terminals, but it must be supported at both ends and may be confusing at sudden startup. XON/XOFF can work on the 3-wire interface. RTS/CTS was originally designed for half-duplex cooperative communications between teletypewriters and modems, and it can only send data from one modem each time. The terminal must send a request to send a signal and wait until the modem responds to clear the transmission. Although RTS/CTS achieves handshaking through hardware, it has its own advantages.

The ASR (Automatic Send Receive) teletypewriter has a tape reader. When the reader reads the data, the characters are sent to it. The ASR teletypewriter receives an XOFF character and turns off the tape reader. The reader receives an XON character and activates the tape reader. XOFF is issued when it is necessary for the remote system to reduce the transmission rate. In the original system, messages were pre-prepared with tapes and the time for delivery was shortened. At that time, the bandwidth was very limited and expensive. Sometimes the transmission had to be postponed until the evening, which also promoted the development of the express telegram. In some early minicomputers, the ASR tape reader and tape puncher were also the only methods to restore the program