RS485, RS means the abbreviation of Recommended Standard, which is the recommended standard. It is a commonly used half-duplex-asynchronous-serial communication bus. Half-duplex means that when two parties communicate, at the same time, only one of them can send, and the other can only receive, not at the same time.
As a universal industrial application control bus, RS485 is widely used because it has many characteristics:
Generally, a maximum of 32 nodes are supported, and data exchange and device control can be carried out between nodes through Modbus or other industrial control protocols.
This relies on a special differential communication method. This method only requires two signal lines to ensure communication. The voltage difference between the two data lines A/B represents the signal, which represents logic 0 and logic 1. , where the logic 1 signal is represented by the voltage difference between the two lines (A+ and B-) between +2V and +6V, and the logic 0 signal is represented by the voltage difference between the two lines (A+ and B-) between -2V and -6V. expressed between. Usually the limit of the voltage difference between the two is considered to be around 200mv. Signals with a voltage difference lower than 200mv are difficult to detect.
The reason why this method has strong anti-interference performance is also due to the advantages of differential signals, because electromagnetic interference noise will cause some burrs on the level waveform, resulting in the entire waveform after the transmitter transmits it to the receiver. There is some distortion, which has less impact in low-speed communication. However, if this kind of electromagnetic interference is superimposed during high-speed communication, it can easily cause errors in the received information. This is why industrial communication protocols basically have a verification method ( For example, the CRC check of the modbus protocol), but the RS485 differential signal is different. The glitches caused by electromagnetic interference will theoretically affect both communication lines A/B, but the voltage difference signal between the two does not occur. Changes. For example, electromagnetic interference causes the voltage of the A/B line to be 150mv higher than the signal source at a certain moment. Subtracting the two will find that the voltage difference between them has not changed, which is a good way to avoid interference. Influence.
Because you only need to connect two data lines and one ground wire, the wiring is very simple, and the circuit of the 485 bus is also relatively simple. Here is a typical 485 circuit:
There is a GPIO25 here. This is because the 485 conversion chip also distinguishes between hardware 485 and software 485. The 485 communication device can only be in the sending or receiving state at a certain time, so what is the conversion between them?
Generally, devices are in the receiving state by default. For example, device 1 and device 2 communicate. When there is no information communication, both are in the receiving state. When one party needs to send a message, it switches to the sending state and sends data, and the other party Receive, and switch back to the receiving state after sending. Hardware 485 means that the conversion between sending and receiving is done by the rs485 conversion chip without the intervention of the receiver and the sender. It is only responsible for sending and receiving. The software 485 is sent through the software control pin of 485 (that is, GPIO25 in the picture above). GPIO25 outputs high level, RE=DE=0V, and enters the receiving mode; GPIO25 outputs low level, RE=DE=3.3V, and enters Send mode is equivalent to software controlling the interaction process.
It is also a common practice to add a pull-up resistor on the A line and a pull-down resistor on the B line, because when the bus is in a standby state without information exchange, the level is not fixed, usually between -200mv and 200mv. At this time The receiver may receive a high-level signal or a low-level signal, so the level needs to be maintained during the idle period.