The meaning of RS485 interface, and common problems in the practical application of weak current engineering!
First of all, what is the concept of RS485 interface?
Simply put, it is a standard for electrical characteristics, which is defined by the Telecommunications Industry Association and the Electronics Industry Alliance. Digital communication networks using this standard can effectively transmit signals under long-distance conditions and in environments with high electronic noise. RS-485 makes it possible to configure inexpensive local networks and multi-branch communication links.
RS485 has two-wire system and four-wire system. The four-wire system can only realize the point-to-point communication mode, which is rarely used now, and the two-wire connection mode is mostly used now.
In the weak current project, RS485 communication generally adopts the master-slave communication mode, that is, a master with multiple slaves.
If you have a thorough understanding of RS485, you will find that there is indeed a lot of knowledge inside, so we will choose some issues that are usually considered in weak current for everyone to understand and learn.
RS-485 electrical regulations
Since RS-485 is developed on the basis of RS-422, many electrical regulations of RS-485 are similar to RS-422. For example, balanced transmission methods are adopted, and terminating resistors are required to be connected to the transmission line. RS-485 can adopt two-wire and four-wire mode, and the two-wire system can realize true multi-point two-way communication.
The difference between RS-485 and RS-422 is that its common-mode output voltage is different. RS-485 is between -7V and +12V, while RS-422 is between -7V and +7V. RS-485 receiver The minimum input impedance is 12k. Swordfish S-422 is 4k healthy; the old sapling S-485 meets all RS-422 specifications, so RS-485 drivers can be used in RS-422 networks.
RS-485 requires 2 termination resistors, whose resistance value is equal to the characteristic impedance of the transmission cable. There is no need for terminating resistors during moment distance transmission, that is, no terminating resistors are generally required for distances below 300 meters. The terminating resistor is connected to both ends of the transmission bus.
Points for Attention in Network Installation of RS-422 and RS-485
RS-422 can support 10 nodes, RS-485 supports 32 nodes, so multiple nodes form a network. The network topology generally uses a terminal-matched bus structure, and does not support ring or star networks. When building a network, you should pay attention to the following points:
1. A twisted-pair cable is used as the bus, and the nodes are connected in series. The length of the lead wire from the bus to each node should be as short as possible to minimize the influence of the reflected signal in the lead wire on the bus signal.
2. Attention should be paid to the continuity of the characteristic impedance of the bus. Signal reflections will occur at the point where the impedance is discontinuous. The following situations are prone to this discontinuity: different cables are used in different sections of the bus, or too many transceivers are installed close to each other on a certain section of the bus, and too long branch lines lead to the bus.
In short, a single, continuous signal channel should be provided as a bus.
When using the RS485 interface, how to consider the length of the transmission cable?
Answer: When using the RS485 interface, for a specific transmission line, the maximum cable length allowed for the data signal transmission from the generator to the load is a function of the data signal rate. This length data is mainly limited by the influence of signal distortion and noise. . The relationship curve between the maximum cable length and signal rate shown in the figure below is obtained when using 24AWG copper core twisted pair telephone cable (wire diameter is 0.51mm), the bypass capacitor between the lines is 52.5PF/M, and the terminal load resistance is 100 ohms Out.
When the data signal rate drops below 90Kbit/S, assuming the maximum allowable signal loss is 6dBV, the cable length is limited to 1200M. In fact, the curve in the figure is very conservative, and it is possible to obtain a larger cable length in practice.
When using cables with different wire diameters. The maximum cable length obtained is not the same. For example: when the data signal rate is 600Kbit/S, 24AWG cable is used. The figure shows that the maximum cable length is 200m. If 19AWG cable (with a wire diameter of 0.91mm) is used, the cable length can be greater than 200m; if 28AWG cable is used ( The wire diameter is 0. 32mm), the cable length can only be less than 200m.
How to realize RS-485 multi-point communication?
Answer: Only one transmitter can transmit on the RS-485 bus at any time. In half-duplex mode, only one master and slave can send. In full duplex mode, the master station can always send, and the slave station can only send one. (Controlled by and DE)
When communicating with the RS-485 interface, under what conditions do I need to use terminal matching? How to determine the resistance value? How to configure terminal matching resistance?
Answer: In long-line signal transmission, generally in order to avoid signal reflection and echo, it is necessary to connect a terminal matching resistor at the receiving end. The terminal matching resistance value depends on the impedance characteristics of the cable, and has nothing to do with the length of the cable.
RS-485 is generally connected by twisted pair (shielded or unshielded), and the terminal resistance is generally between 100 to 140Ω, with a typical value of 120Ω. In the actual configuration, the two terminal nodes of the cable, namely the nearest end and the farthest end, are each connected to a terminal resistance, and the node in the middle part cannot be connected to the terminal resistance, otherwise it will cause communication errors.
Why does the receiver still output data when the RS-485 interface stops communicating?
Answer: After RS-485 sends data, it requires all sending enable control signals to be turned off and to keep receiving enable valid. At this time, the bus driver enters a high-impedance state and the receiver can monitor whether there is new communication data on the bus .
Since the bus is in a passive driving state at this time (if the bus has terminal matching resistance, the differential level of the A and B lines is 0, the output of the receiver is uncertain, and it is very sensitive to the change of the differential signal on the AB line; if Without terminal matching, the bus is in a high-impedance state, and the output of the receiver is uncertain), which is susceptible to external noise interference. When the noise voltage exceeds the input signal threshold (typical value ±200mV), the receiver will output data, causing the corresponding UART to receive invalid data, making the subsequent normal communication error; another situation may occur when the transmission is turned on/off. At the moment when it can be controlled, making the receiver output a signal will also cause the UART to receive incorrectly. Solution: 1) Use the method of pulling up the non-inverting input terminal (line A) and pulling down the inverting input terminal (line B) on the communication bus to clamp the bus to ensure that the receiver output is a fixed "1" level; 2) Replace the interface circuit with MAX308x series interface products with built-in fail-safe mode; 3) Eliminate by software, that is, add 2-5 starting synchronization bytes in the communication data packet, and start only after the synchronization header is met Real data communication.
The signal attenuation of RS-485 in communication cable
The second factor that affects signal transmission is the signal attenuation during cable transmission. A transmission cable can be seen as an equivalent circuit composed of distributed capacitance, distributed inductance and resistance. The distributed capacitance C of the cable is mainly produced by two parallel wires of the twisted pair. The resistance of the wire here has little effect on the signal and can be ignored.
Influence of Distributed Capacitance on RS-485 Bus Transmission Performance
The distributed capacitance of the cable is mainly produced by two parallel wires of the twisted pair. In addition, there is distributed capacitance between the wire and the ground. Although it is small, it cannot be ignored in the analysis. The influence of distributed capacitance on bus transmission performance is mainly because the fundamental wave signal is transmitted on the bus, and the signal expression is only "1" and "0". In a special byte, such as 0x01, the signal "0" makes the distributed capacitance have enough time to charge, and when the signal "1" comes, it is too late to discharge due to the charge in the distributed capacitance, (Vin+)-(Vin-)- It is also greater than 200mV, and as a result, the connection is mistaken for "0", which eventually leads to a CRC check error and the entire data frame transmission error.
Due to the influence of the distribution on the bus, data transmission errors are caused, which reduces the performance of the entire network. There are two ways to solve this problem:
(1) Reduce the baud rate of data transmission;
(2) Use cables with small distributed capacitance to improve the quality of the transmission line.
- 86-18938645642（Manager Wu）
- Address: unit C, 8 / F, building a, anlibang science and Technology Park, Xitian first industrial zone, Gongming street, Guangming New District, Shenzhen
- Shaanxi Xi'an Office
Contact person: Manager Zhang 02988283137 15389041752