The LED display in use suddenly appears garbled due to signal problems. If it is at a major opening ceremony, the loss is irreparable. Therefore, how to improve the reliability and stability of signal transmission has become a subject that engineers have to face.
During transmission, the signal weakens as the distance increases. Therefore, the choice of transmission medium is particularly important. The following points should be paid attention to when using RS-485 as a long-distance data transmission line.
1. Signal attenuation
It is not difficult to understand that no matter what kind of medium the signal is transmitted by, it will be attenuated during the transmission process. We can regard the RS-485 transmission cable as an equivalent circuit composed of several resistors, inductors and capacitors.
The resistance of the wire has very little effect on the signal and can be ignored. The distributed capacitance C of the cable is mainly produced by the two parallel wires of the twisted pair. The loss of the signal is mainly due to the LC low-pass filter composed of the distributed capacitance and distributed inductance of the cable. The higher the communication baud rate, the greater the signal attenuation.
Therefore, when the amount of transmitted data is not very large and the transmission rate requirement is not very high, we usually use a baud rate of 9 600 bps.
2. Signal reflection in the communication line
In addition to signal attenuation, another factor affecting signal transmission is signal reflection. Impedance mismatch and impedance discontinuity are the two main causes of signal reflections on the RS-485 bus.
① Impedance mismatch, the impedance mismatch is mainly the impedance mismatch between the 485 chip and the communication line. The reason why the reflection is caused is that when the communication line is idle, the signal of the whole communication line is chaotic. Once such reflected signal triggers the comparator at the input end of the 485 chip, an erroneous signal will be generated. Our usual solution is to add bias resistors with a certain resistance to the A and B lines of the RS-485 bus, and pull them up and down respectively, so that unpredictable messy signals will not appea
>② Impedance discontinuity, as the name suggests, is similar to the reflection caused by light passing from one medium to another. At the end of the transmission line, the signal suddenly encounters little or no cable impedance, and the signal will cause reflection at this place. The most common way to eliminate this reflection is to connect a terminal resistor with the same size as the characteristic impedance of the cable at the end of the cable to make the impedance of the cable continuous. Since the transmission of the signal on the cable is bidirectional, a terminal resistor of the same size must also be connected across the other end of the communication ca
/>In this way, the influence of signal reflection can be weakened to a certain extent. However, in practical applications, since the characteristic impedance of the transmission cable is related to the application environment such as the communication baud rate, the characteristic impedance cannot be completely equal to the terminal resistance, so we cannot completely avoid the occurrence of signal reflectio
/>3. The influence of distributed capacitance on the transmission performance of RS-485
/>RS-485 transmission cables are usually twisted-pair wires, and capacitance will be generated between two parallel wires of the twisted-pair wires. At the same time, there is also a similarly small capacitance between the cable and the ground. Since the signal transmitted on the RS-485 bus is composed of countless "1" and "0" bits, when encountering special bytes such as 0x01, the level "0" makes the distributed capacitors get sufficient time to charge, And when the level "1" comes suddenly, the charge accumulated in the capacitor cannot be released in a short time, thus causing the deformation of the signal bit, thus affecting the quality of the entire data transmiss
/>Therefore, on the one hand, we should try to use cables with smaller distributed capacitance, that is, better quality cables, as the communication lines; on the other hand, we should try to reduce the baud rate of communication as much as possible, and give the capacitors enough time to discha
/>4. Develop a simple and reliable RS-485 communication prot
/>When the communication distance is short and the interference of the application environment is small, sometimes we only need simple one-way communication to realize all the functions of the project, but most application environments are not so ideal. Whether the comprehensive wiring is professional in the early stage of the project (for example, the signal line and the power line must keep a certain distance), the indeterminacy of the communication distance, the degree of interference around the communication line, whether the communication line uses twisted-pair shielded wire, etc. Normal communication has a huge impact. Therefore, it is particularly important to develop a complete set of communication protoc
/>The specific method is to divide the data into packets and pack the data by adding a frame header and a frame tail to each packet of data, and one byte is reserved at the frame end as a check byte. The lower computer compares the check byte calculated by itself with the check byte transmitted by the upper computer, so as to issue an instruction to the upper computer, whether to resend the packet of data just now or continue to send the next packet of data, just like this After one pack is sent out, the next pack will be sent out until it is finished. Through such a check-and-resend mechanism, we can discard the probability of errors and make the communication system run norma
/>5 Conclu
/>During the rectification process of the whole project, we successively adopted the following methods: Since the distance between the communication line and the power supply line is very close, and projection surface the communication line has no shielding layer, we replaced all the communication cables; both the upper computer and the lower computer Set the communication baud rate to be adjustable, so that an appropriate value can be selected according to the specific conditions in the debugging process; the communication protocol has been optimized; a 120 Ω terminal resistance is added to both ends of the communication cable.
During transmission, the signal weakens as the distance increases. Therefore, the choice of transmission medium is particularly important. The following points should be paid attention to when using RS-485 as a long-distance data transmission line.
1. Signal attenuation
It is not difficult to understand that no matter what kind of medium the signal is transmitted by, it will be attenuated during the transmission process. We can regard the RS-485 transmission cable as an equivalent circuit composed of several resistors, inductors and capacitors.
The resistance of the wire has very little effect on the signal and can be ignored. The distributed capacitance C of the cable is mainly produced by the two parallel wires of the twisted pair. The loss of the signal is mainly due to the LC low-pass filter composed of the distributed capacitance and distributed inductance of the cable. The higher the communication baud rate, the greater the signal attenuation.
Therefore, when the amount of transmitted data is not very large and the transmission rate requirement is not very high, we usually use a baud rate of 9 600 bps.
2. Signal reflection in the communication line
In addition to signal attenuation, another factor affecting signal transmission is signal reflection. Impedance mismatch and impedance discontinuity are the two main causes of signal reflections on the RS-485 bus.
① Impedance mismatch, the impedance mismatch is mainly the impedance mismatch between the 485 chip and the communication line. The reason why the reflection is caused is that when the communication line is idle, the signal of the whole communication line is chaotic. Once such reflected signal triggers the comparator at the input end of the 485 chip, an erroneous signal will be generated. Our usual solution is to add bias resistors with a certain resistance to the A and B lines of the RS-485 bus, and pull them up and down respectively, so that unpredictable messy signals will not appea
>② Impedance discontinuity, as the name suggests, is similar to the reflection caused by light passing from one medium to another. At the end of the transmission line, the signal suddenly encounters little or no cable impedance, and the signal will cause reflection at this place. The most common way to eliminate this reflection is to connect a terminal resistor with the same size as the characteristic impedance of the cable at the end of the cable to make the impedance of the cable continuous. Since the transmission of the signal on the cable is bidirectional, a terminal resistor of the same size must also be connected across the other end of the communication ca
/>In this way, the influence of signal reflection can be weakened to a certain extent. However, in practical applications, since the characteristic impedance of the transmission cable is related to the application environment such as the communication baud rate, the characteristic impedance cannot be completely equal to the terminal resistance, so we cannot completely avoid the occurrence of signal reflectio
/>3. The influence of distributed capacitance on the transmission performance of RS-485
/>RS-485 transmission cables are usually twisted-pair wires, and capacitance will be generated between two parallel wires of the twisted-pair wires. At the same time, there is also a similarly small capacitance between the cable and the ground. Since the signal transmitted on the RS-485 bus is composed of countless "1" and "0" bits, when encountering special bytes such as 0x01, the level "0" makes the distributed capacitors get sufficient time to charge, And when the level "1" comes suddenly, the charge accumulated in the capacitor cannot be released in a short time, thus causing the deformation of the signal bit, thus affecting the quality of the entire data transmiss
/>Therefore, on the one hand, we should try to use cables with smaller distributed capacitance, that is, better quality cables, as the communication lines; on the other hand, we should try to reduce the baud rate of communication as much as possible, and give the capacitors enough time to discha
/>4. Develop a simple and reliable RS-485 communication prot
/>When the communication distance is short and the interference of the application environment is small, sometimes we only need simple one-way communication to realize all the functions of the project, but most application environments are not so ideal. Whether the comprehensive wiring is professional in the early stage of the project (for example, the signal line and the power line must keep a certain distance), the indeterminacy of the communication distance, the degree of interference around the communication line, whether the communication line uses twisted-pair shielded wire, etc. Normal communication has a huge impact. Therefore, it is particularly important to develop a complete set of communication protoc
/>The specific method is to divide the data into packets and pack the data by adding a frame header and a frame tail to each packet of data, and one byte is reserved at the frame end as a check byte. The lower computer compares the check byte calculated by itself with the check byte transmitted by the upper computer, so as to issue an instruction to the upper computer, whether to resend the packet of data just now or continue to send the next packet of data, just like this After one pack is sent out, the next pack will be sent out until it is finished. Through such a check-and-resend mechanism, we can discard the probability of errors and make the communication system run norma
/>5 Conclu
/>During the rectification process of the whole project, we successively adopted the following methods: Since the distance between the communication line and the power supply line is very close, and projection surface the communication line has no shielding layer, we replaced all the communication cables; both the upper computer and the lower computer Set the communication baud rate to be adjustable, so that an appropriate value can be selected according to the specific conditions in the debugging process; the communication protocol has been optimized; a 120 Ω terminal resistance is added to both ends of the communication cable.