Detailed explanation of RS485 communication bus

Detailed explanation of RS485 bus

RS-485 is a new balanced transmission standard (Balanced Transmission Standard) also called differential approved by the American Electronics Industry Association (EIA) in 1983. EIA initially used RS (Recommended Standard) as the prefix of the standard, but later it was To facilitate identification of the source of the standard, RS was changed to EIA/TIA, so the current name of the standard is TIA-485. However, engineers are still accustomed to using RS-485 as the name of the bus standard.

1 Introduction

RS-485 is an electrical standard that defines the physical layer standards of the interface such as voltage, impedance, etc., but does not define the software protocol, communication timing, and communication data. Rather, it is defined by the user or a common software protocol. Currently, the common standard protocols (pure software protocols) that can use RS-485 as the physical layer include industrial HART bus, Modbus protocol and Profibus DP protocol.

2. Electrical characteristics

(1) RS485 has two types of wiring: two-wire and four-wire. The four-wire system can only achieve point-to-point communication (one host connects to one slave). It is rarely used now. The two-wire wiring is mostly used (A Line, B line) method, this wiring method is a bus topology. The bus mostly uses shielded twisted pair to transmit data. Up to 32 nodes can be connected to the same bus, that is, one host can connect multiple slaves.

(2) RS-485 uses the voltage difference between the two lines to be +2V to +6V to represent logic 1, and the voltage difference between the two lines to be -2V to -6V to represent logic 0. The interface signal level is lower than RS-232 (RS232 is -15V to +15V), so it is less likely to damage the interface chip than RS-232. At the same time, the RS-485 level is compatible with the TTL level and can be easily connected to the TTL circuit. .

(3) RS-485 uses differential signal transmission, which reduces potential electromagnetic interference EMI. The value of the differential signal is largely GNDindependent of the precise value of , so it can resist interference from the power supply.

(4) A driver that complies with the RS-485 standard can provide a differential output of no less than 1.5V (under a 54 Ohm load). The minimum differential voltage tolerance of RS-485 is 200mV, which means that the receiving end will fail when the differential voltage is lower than 200mV. Logic 0and logic cannot be correctly identified 1.

Please add image description
(5) The maximum data transmission rate of RS-485 is 10Mbps, which means it can transmit 10M bits of data per second, while the transmission rate of RS-232 is only 20Kbps.

(6) The theoretical maximum transmission distance of RS-485 is 3000 meters, but in actual operation the limit distance is only 1200 meters.

(7) RS-485 only supports half-duplex communication, because both communicating parties need to share a pair of differential signal lines to transmit data, but a pair of differential signal lines cannot transmit data from both parties at the same time, so full-duplex communication cannot be supported due to communication line constraints. .

2.1 Understand single-ended/differential transmission

(1) Single-ended transmission (unbalanced transmission): During the transmission process, a wire is used to transmit the potential difference between the ground and the ground (GND). The potential difference is used to represent the data logic sum and the transmission 0value 1. The signal is called a single-ended signal.

(2) Differential transmission (balanced transmission): Differential transmission uses two lines to transmit signals. The signal amplitudes on these two lines are equal, the phase is 180 degrees different, and the polarity is opposite. The signal transmitted on these two lines is a differential signal. The signal receiving end compares the potential difference of the two signals to determine the logic 0and logic of the data sent by the transmitting end 1.

2.2 Differential transmission anti-interference principle

Single-ended transmission method, because the ground will not be interfered, but after the output signal is interfered, the potential difference between the output signal and the ground changes, resulting in contamination of the original signal, and the noise is eventually output together with the output signal.

Please add image description
+In the differential transmission method, the phase of the signal emitted by the source end -is opposite to that of the signal. For common mode noise, it +/-will exist on both lines. Ideally, the noise is of equal amplitude and phase, and the receiving end is equivalent to a subtraction. The useful signal will still be retained after passing through the subtractor due to its opposite phase, while the noise will be canceled out.

Please add image description

3. Timing

RS-485 is very simple in terms of timing. There is no synchronous clock line such as . Since it is a differential data line, we do not need to write a program to control the timing. There is not much to interpret in terms of timing, but we still need to understand RS-485 SPI. I2CThe timing of -485 is as shown below.

Please add image descriptionHowever, the differential data line can be interpreted using a dual-channel oscilloscope. For example, channel one of the oscilloscope is connected to the A line of RS-485, and channel two is connected to the B line of RS-485. To turn on the Math function of the oscilloscope, use channel one minus channel two. Get the actual data waveform.

4. Transceiver

In an RS485 communication network, each bus node device usually uses an RS-485 transceiver to convert the node device's TTL logic levels to RS-485 differential levels.

RS-485 communication requires the use of a microcontroller and the UART interface of the DSP processor. The data is sent to the RS-485 transceiver through the UART, and then the RS-485 converts the data level and sends it to the data receiving end.

If you use FPGA to use RS-485, you need to implement an IP module that supports serial port transceiver. You can even use GPIO to simulate UART timing to communicate with an RS-485 transceiver, but this requires a lot of CPU resources to send and receive the underlying data bits.

5. Matching resistor

When there are few devices and short distances, the entire network can work well even without using terminal load resistors. However, as the distance increases, the communication quality gradually decreases.

In theory, when sampling at the midpoint of each received data signal, matching can be disregarded as long as the reflected signal attenuates low enough at the beginning of sampling. But this is difficult to grasp in practice. The American MAXIM company mentioned an empirical principle that can be used to judge what data rate and cable length need to be matched: when the signal conversion time (rise or fall time) exceeds the electrical signal When the time required for one-way transmission along the bus is more than 3 times, the matching resistor does not need to be added.

Generally, the terminal resistor method is used for terminal matching. For RS-485, terminal resistors should be connected in parallel at the beginning and end of the bus cable. The terminating resistor is 120 Ohm in the RS-485 network. Resistance equivalent to the characteristic impedance of the cable, because the characteristic impedance of most twisted pair cables is approximately 100Ohm-120Ohm.

The terminal matching method is simple and effective. The only disadvantage is that the matching resistor consumes a large amount of power, which is not suitable for systems with strict power consumption restrictions. Another more power-saving matching method is RC matching. Using a capacitor C to block the DC component can save most of the power. However, the value of capacitor C is difficult and requires a compromise between power consumption and matching quality. There is also a matching method using diodes. Although this solution does not achieve true matching, it uses the clamping effect of the diode to quickly weaken the reflected signal, improve the signal quality, and has a significant energy saving effect.

6. Interface design

RS-485 transceivers are products covered by most chip companies, such as TI, Microchip and other manufacturers. When choosing an interface chip, you need to consider whether the chip's power supply voltage input logic is compatible with the level of the processor and DSP used. In addition, whether the impedance of the RS-485 transceiver receiving circuit complies with the RS-485 standard input impedance.

When designing the interface circuit, you also need to consider EMC requirements. There is really strong interference at some equipment sites. For example, there are inductive loads such as high-power motors running on the power grid. These loads may interfere with the equipment. In addition, there may also be space radiation interference. This You can consider using shielded twisted pairs.

7. Isolation design

In many industrial sites, there may be high-current switching equipment, motor inductive equipment, etc., and noise is likely to be coupled into the equipment through the communication ground. Especially in industrial equipment, interface circuits are generally designed with isolation. In order to reduce ground noise, it is necessary to design an isolation interface. You can consider choosing a chip with isolation function, such as ADI's

iCoupler technology products ADM2481, ADM2485. Of course, you can also use optocoupler plus ordinary RS-485 transceiver. The only thing that needs attention is that you need to design an isolated power supply to supply power to the circuits on both sides of the isolation.

8. ESD protection

In industrial applications, lightning strikes, power fluctuations, and electrostatic discharge will produce large transient voltages and cause damage to the RS-485 transceiver, so a protection circuit needs to be installed at the RS-485 port.

The protection circuit can use external clamping devices (such as TVS diodes). The TVS clamps the voltage on the bus to the common-mode voltage range of the RS-485 transceiver (-7V–12V). For higher voltage transients, a series resistor (10-20 Ohm) can be added between the protected device and the input pin for added protection.

9. Common land issue

Since RS-485 adopts differential transmission, it has stronger anti-interference ability and longer communication distance than RS-232. RS-485 communication is generally half-duplex and only requires 2 signal lines. If it is full-duplex, 4 signal lines are required.

In fact, RS485 requires three wires: A, B and GND. GND is used to ground the equipment on both sides of the communication. However, since RS485 uses differential transmission, GND is generally considered unimportant, and is often omitted or even used as a two-core cable or a video cable to transmit RS485 signals. Although it can work normally in many situations without a ground wire, the following two problems may occur:

(1) Common mode interference problem : The RS-485 interface uses a differential method to transmit signals. It does not need to detect the signal relative to a certain reference point. The system only needs to detect the potential difference between the two lines. However, the RS-485 transceiver has a certain common-mode voltage range, and the general voltage range is -7V to +12V. Only when the above conditions are met, the entire network can work normally. If there are many nodes on the bus, when the common mode voltage in the network line exceeds this range, the stability of the communication will be affected.

(2) EMI electromagnetic compatibility problem : The common mode part in the output signal of the transmitting driver needs a return path. If there is no low-resistance return path like the signal ground, the common mode part in the signal will return to the source end in the form of radiation. The bus radiates electromagnetic waves like an antenna.

The above are the technical details about RS-485. The actual hardware interface design requires the use of an RS-485 transceiver. There are commonly used RS-485 transceivers, and SN75176BDRtheir schematic diagram is as follows:

Please add image descriptionDuring actual use, pay attention to designing the interface protection circuit to prevent damage to the transceiver chip.

Guess you like

Origin blog.csdn.net/jf_52001760/article/details/129136838