Rika Sensor is a weather sensor manufacturer and environmental monitoring solution provider with 10+ years of industry experience.
RS485 communication basics and detailed communication applications
To understand RS485 communication, we must first understand what communication is. Communication is the transmission of 0 and 1 codes between two devices, 0-low level, 1-high level.
For example: PLC transfers data to inverter slave 1 and inverter slave 2. First, the inverter slave 1 and inverter slave 2 must be connected by cable (hardware connection). If the inverter slave 1 and the inverter slave device send a series of codes such as 101010, then the inverter slave 1 will generate the high and low level combination as shown in the figure below on his communication port, through the cable as the medium inverter The communication port of the slave 2 device will receive the combination of high and low levels sent by the A device, and at the same time it will translate the received high and low level combination into 101010, which completes the PLC to the two inverters and the slave 1 device data Of delivery. Description of concepts related to communication:1. Full-duplex and half-duplexFull-duplex is a communication port that can receive data while sending data. Half-duplex refers to that the communication port can only send data or can only receive data at the same time. In layman’s terms:Full duplex: Both parties can talk when making a callHalf duplex: Just like a walkie-talkie, only one person can speak and the other listen at the same time Single-duplex: Only the device can send data, and the other device can only receive the device and does not have the sending function.2. Communication rate: The communication rate is also called the communication baud rate, which is the communication port within 1S. Send the number of 0 and 1 codes (or high and low levels). For example: we say that the communication rate is 9.6Kbps, which means that the communication port sends 9600 bits of data per second, that is, 9600 high and low levels can be generated per second (note: the high and low levels add up to 9600 )Bit transmission rate The amount of information transmitted through the channel per second is called the bit transmission rate, denoted as rb. The unit is bit per second (b/s), abbreviated as bit rate. 3. Master-slave communication Master-slave communication refers to a station in a communication network as the master station and other stations as slave stations. Data can be transferred directly between the master station and the slave station, but data cannot be directly transferred between the slave station and the slave station. If you need to exchange data between slave stations, it must be forwarded through the master station. Speaking in layman's terms, there are three main differences between the master station and the slave station: different commands, different uniqueness, and different docking. 1. Different commands are issued.1. Master station: The master station can take the initiative to issue commands. 2. Slave station: The slave station will not take the initiative to issue instructions. Second, the uniqueness is different 1. Master station: The master station is unique. 2. Slave station: Slave station is not unique, there can be more than one. 3. Different docking 1. Master station: The master station can dock with multiple slave stations. 2. Slave station: Slave station can only connect to one master station. After understanding the basic concepts of communication, it is relatively easy to understand 485 communication. Below we will introduce 485 communication from four aspects: communication medium, communication method, communication type, and physical layer. Communication medium: The communication medium is shielded twisted pair, which is the two-core cable with shielding layer that we usually use. Communication method: half-duplexCommunication type: master-slave communicationPhysical layer: 9-pin interface, it should be noted that the 9-pin interface for 485 communication in the case of passing, only needs two cores The cable is connected to pin 3 and pin 8, 3 signal '-' and 8 signal '+' Let’s talk about a simple example: two people make a call, the phone is at the physical layer, and the person talking The language is the agreement. The same physical layer can transmit different protocols, just like the people on both sides of the phone can speak both Chinese and English. Chinese is one type of agreement, and English is another type of agreement. 485 is like a telephone, which is the physical layer. The physical layer of 485 can transmit the modbus protocol and the Profibus protocol. This is the relationship between the communication protocol and the physical layer. RS485 is a standard that defines the electrical characteristics of drivers and receivers in a balanced digital multipoint system. The standard 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. RS485 makes it possible to configure low-cost local networks and multi-branch communication links. RS485 has two-wire and four-wire connections. The four-wire system can only achieve point-to-point communication. It is rarely used now, and it is used more now. It is a two-wire wiring method. This wiring method is a bus topology structure and up to 32 nodes can be connected on the same bus. In the RS485 communication network, a master-slave communication method is generally adopted, that is, a master with multiple slaves. In many cases, when connecting the RS-485 communication link, simply use a pair of twisted pair to connect the 'A' and 'B' ends of each interface, and ignore the signal ground connection. This connection method is used in many The occasion can work normally, but there are great hidden dangers. Reason 1 is common mode interference: the RS-485 interface adopts the differential mode to transmit the signal, and it does not need to detect the signal relative to a certain reference point. The system only It is enough to detect the potential difference between the two wires, but it is easy to overlook that the transceiver has a certain common-mode voltage range. The common-mode voltage range of the RS-485 transceiver is -7 to +12V. Only when the above conditions are met, the entire network It can work normally; when the common mode voltage in the network line exceeds this range, it will affect the stability and reliability of the communication, and even damage the interface; the second reason is the problem of EMl: the common mode part of the output signal of the driver needs a return path, if there is no one The low-resistance return channel (signal ground) will return to the source in the form of radiation, and the entire bus will radiate electromagnetic waves outward like a huge antenna.