As mentioned in the previous section, the Modbus protocol is the most widely used protocol in industrial applications. In a Modbus protocol system, the host is generally PLC, HMI, configuration software, etc., but in a slightly complex system, there are usually multiple hosts at the same time. Since the communication cable is generally RS485, the half-duplex feature leads to a large data delay when multiple hosts collect data at the same time. (Because only one master or slave can send data at the same time, otherwise it will cause data conflicts and form garbled characters).
Therefore, the host generally uses the network port to communicate, which can ensure the timeliness of the data. As mentioned earlier, the serial port server can convert the network port data into serial port data for communication, so that while ensuring full-duplex communication, the data can be connected to the Internet, which greatly improves the communication distance.
Although the network cable can achieve full duplex (sending and receiving at the same time), but for low-latency application scenarios, such one-to-one communication advantages are not very obvious, today I will talk to you about a special function - multi-host gateway mode.
The Modbus multi-master gateway supports multiple Modbus TCP hosts to operate RTU devices at the same time, and uses TCP IP protocol communication to break the limitation that only one host can exist on the RTU data bus at the same time.
The simple protocol conversion mode is only suitable for scenarios where a single master is used to communicate with slaves, because the serial server only converts the data, and the data of the serial port is broadcast to all masters. If multiple hosts send data at the same time, the serial server will send the data directly, which will cause communication timeout or data abnormality.
Serial server - introduction and use of simple protocol conversion.
Compared with simple protocol conversion, the multi-host gateway mode does separate data processing for the scenario of sending data at the same time to multiple hosts. For example, when the host sends data for a short time, the serial port server will intercept the requested data on the network side, and the data will send instructions to the serial port device in order, and the serial port device will return the data to the host after receiving the data, and which host will specify which host to send the data to which host, so as to avoid the abnormal phenomenon of communication and improve the reliability of communication.
The following mainly introduces the application method of multi-host gateway, due to the host-side operation has its own characteristics, this place only uses Modbus Pool and Modbus SL**E as a display, PLC HMI and other link connections with reference to this.
How to configure parameters has been explained in previous articles and will not be covered separately in this section.
Use the ebyte network configuration tool to view the parameters of the current serial server, the IP needs to be modified to the same network segment as the computer, set the serial server to TCP server mode, and record the current local IP and local port.
Open the modbus sl**e software to simulate the slave, use the serial port in connection mode, and select the serial slogan and connection parameters of the serial port server (baud rate, data bit, check bit, stop bit, here the default 115200, 8n1 is used).
The data return content is selected as the slave id as 1, the function code as 03, the register address as 0, and the number as 10 (this parameter is also read later).
Open the Modbus Pool software, select Modbus TCP IP as the connection mode, set the destination IP address to the serial server, and set the destination port to the local port of the serial server (192.).168.0.113 8887) The default timeout period can be used.
The read parameter is also selected as slave ID as 1, function code as 03, register address as 0, and quantity as 10. You can connect up to 6 hosts by referring to this parameter, as shown in the following figure.