The commonly used communication method for data acquisition and control is RS485. RS485 is a general communication standard. It can not only link devices to the local network, but also put multiple 485 devices on the same bus, enabling multiple nodes to link to each other.
What is RS485?
RS-485 (also known as TIA/EIA-485) is a standard interface for physical communication. It is a form of serial communication. Typical serial communication standards are RS232 and RS485. RS485 expands the physical function on the basis RS232 interface.
RS-485 adopts balanced transmission and differential reception, so it has the ability to suppress common mode interference. In addition, the bus transceiver has high sensitivity and can detect voltages as low as 200mv, so the transmission signal can be recovered from kilometers away. RS485 advantage is the communication between multi-node systems.
RS-485 wiring methods include two-wire system and four-wire system. Four-wire system can only realize point-to-point communication, which is rarely used now. The two-wire wiring method is mostly used. This wiring method is a bus topology, and can connect up to 32 nodes on the same bus. The commonly used RS485 circuit is shown in the following figure:
RS485 communication principle
The RS485 signal will be decomposed into two lines with positive and negative symmetry (often called A and B signal lines) before transmission. After reaching the receiving end, the two signals are restored to the original signals. The positive level between the sending drivers A and B is +2~6V, which is a positive 1 logic state. The negative level is -2~6V, which is a negative 0 logic state. Another signal ground C. There is also an “enable” terminal in RS485. The “enable” terminal can control the disconnection and connection of the driver and the transmission line. When the “enable” terminal is active, the sending driver is in a high-impedance state, which is the third state different from logic “1” and “0”.
The logic stipulates that the receiving end and the transmitting end connect AA and BB correspondingly through a balanced twisted pair. When there is a level greater than +200mV between (DT)=(D+)-(D-) between the receiving end AB, the positive logic level is output. When less than -200mV, output negative logic level. The level range received by the receiver is usually between 200mV and 6V.
For example: when sending “1”, the driver receives the high level sent by the controller, then the A terminal outputs a high level, and the B terminal outputs a low level. The receiver A side receives a high level, the B side receives a low level, and the two signals are subtracted to get “1”. When sending “0”, the driver receives the low level sent by the control, the receiver A receives the low level, the B side receives the high level, and the two signals are subtracted to get “0”.
Ordinary twisted-pair cables can be used in general situations, and coaxial cables with shielded layers can be used in environments with high requirements. When using the RS485 interface, for a specific transmission line, the line length is inversely proportional to the baud rate. This length data is mainly affected by signal distortion and noise.
In theory, RS485 can transmit up to 1200 meters, but in practical applications, the transmission distance is shorter than 1200 meters, and the specific distance depends on the surrounding environment. During the transmission process, repeaters can be added to amplify the signal, and a maximum of eight repeaters can be added. In this way, RS-485 can transmit up to 9.6 kilometers. If long-distance transmission is required, optical fiber can be used as the propagation medium, and a photoelectric converter is added at the receiving end and the transmitting end. Multimode fiber can transmit up to 5~10 kilometers, while single-mode fiber can transmit 50 kilometers.
After the hardware communication interface is established, a data protocol needs to be agreed between the instruments for data transmission, so that the receiving end can parse the received data, which is the “protocol”. For RS485 signal transmission, the most commonly used communication protocol is Modbus.
What is the Modbus protocol?
MODBUS is an international standard communication protocol that can exchange data from devices of different manufacturers (usually industrial). The protocol can be understood as the “language” mentioned above, which is simply software.
Modbus, a serial communication protocol, was published in 1979 by Modicon Corporation (now Schneider Electric) for communication with programmable logic controllers (PLCs). Modbus has become a standard (De facto) for industrial communication protocols and is now a common connection method between industrial electronic devices. The main reasons why Modbus is more widely used than other communication protocols are:
- Publicly published and without copyright requirements
- Easy to deploy and maintain
- There are not many restrictions for suppliers to modify or move local bits or bytes
Modbus allows multiple (approximately 240) devices connected on the same network to communicate. For example, a temperature and humidity sensor sends measurement data to a computer. In data acquisition and supervisory control system (SCADA), Modbus is usually used to connect supervisory computer and remote terminal control system (RTU).
MODBUS is a kind of communication protocol, just like English is a language for people to communicate, Modbus is a language for communication between machines. The communication process needs a bridge, and this bridge is the transmission medium 485 or 232. The same protocol can use different transmission media such as 485 or 232, but two protocols cannot exist on the same transmission line at the same time.
Difference between RS485 and RS232
RS232 is a single-ended operation, which is an unbalanced transmission method. The logic level of the signal at the transceiver end is relative to the signal ground. RS232 was originally a one-to-one communication between DET (Digital Terminal Equipment) and DCE (Data Communication Equipment), and is generally used for full-duplex transmission. Of course, it can also be used for half-duplex transmission.
|Adopt balanced transmission – differential transmission
|Using unbalanced transmission – single-ended communication
|The transmission distance can reach 3000 meters
|The transmission distance does not exceed 20 meters
|1 to 32 communication
|1 to 1 communication
|+2V~+6V means logic 1, -6V~-2V means logic 0
|-15V-5V means logic 1, 5V~ 15V means logic 0
|Communication rate 20KB/S
|Communication rate 10MB/S
1. Transmission distance
The RS232 signal transmission distance is short, the theoretical transmission distance is 15 meters, and the maximum transmission distance in the actual project is not more than 30 meters. The RS485 signal transmission distance is relatively long, the theoretical transmission distance is 1200 meters, and the actual project can reach 2500 meters.
2. Different signal lines
The RS232 connection method is three wires: a sending wire, a receiving wire and a ground wire. RS485 generally adopts two-wire transmission: A and B two transmission lines. The two RS-485 lines transmit the same signal, but the sender divides the signal into two. The receiver will restore it to the original signal after receiving it. Compare with RS232. RS232 has three wires, one is the ground wire, and the other two have only one wire to transmit data signals. In this way, the 485 receiving end can eliminate interference during signal transmission, while the 232 receiving end cannot. Therefore, the 485 has strong anti-interference ability and can transmit several kilometers, while the 232 can only transmit more than ten meters.
3. Maximum baud rate
The RS232 signal transmission rate is relatively low, and the maximum baud rate is 19200bps. Although the transmission speed is slow, it is still practical in many occasions in engineering. RS485 signal transmission rate is relatively high, up to 10Mbps. The transmission speed is also much faster, and it is mostly used in engineering control signal transmission.
4. Electrical signal technology
The electrical signal technology is an important parameter to judge the anti-noise ability of the two protocols. Using single-ended lines or unbalanced signals in RS232 reduces the standard’s noise immunity to disturbances such as ground loops. RS-485 offers higher noise immunity because it uses balanced differential signaling technology, providing the user with common-mode noise cancellation.
5. Equipment Quantity
Ideally, the more devices we can connect, the better. RS-485 is designed for multipoint systems where multiple drivers and receivers are connected, whereas RS-232 is only used to connect two devices.
6. Network complexity
Connecting multiple devices increases network complexity. RS-232 is easier to implement because there are fewer receivers and drivers to deal with. This is indeed a simple and cheap solution.