Difference between revisions of "Template:Four types of Modbus gateways"

From Waveshare Wiki
Jump to: navigation, search
(4. Models and supported modes)
(4. Models and supported modes)
 
Line 99: Line 99:
 
{| width="800" style="margin-bottom: 10px"
 
{| width="800" style="margin-bottom: 10px"
 
|-
 
|-
! width="150" scope="col" | '''名称'''
+
! width="150" scope="col" | '''Item'''
! width="150" scope="col" | '''型号'''
+
! width="150" scope="col" | '''Product'''
! width="150" scope="col" | '''简单协议转化'''
+
! width="150" scope="col" | ''' Simple protocol conversion'''
! width="150" scope="col" | '''多主机模式'''
+
! width="150" scope="col" | '''Multi-host mode'''
! width="150" scope="col" | '''存储型网关'''
+
! width="150" scope="col" | '''Storage gateway'''
! width="150" scope="col" | '''可配置网关'''
+
! width="150" scope="col" | '''Configurable gateway'''
 
|-
 
|-
! scope="row" | 以太网Modus网关
+
! scope="row" | Ethernet Modus Gateway
 
| RS485 TO ETH (B)
 
| RS485 TO ETH (B)
 
| √
 
| √

Latest revision as of 14:12, 17 November 2021


1 Overview

Modbus gateway is a device that can convert Modubs TCP protocol into Modbus RTU protocol. Modbus is widely used in the field of meters and sensors, and can obtain the data of meters and sensors, but the traditional RS485-based Modbus RTU (or ASCII) has poor speed and scalability, so the network-based protocol, Modbus TCP, appeared later. So the converter of Modbus gateway came into being.

The four Modbus gateways are converted from simple protocols to multi-host gateways, storage gateways, and ZLMB configurable gateways. From simple to complex also reflects its development process, understanding their strengths and weaknesses helps engineers better master their use.

The ZLMB configurable gateway is especially recommended here, which can pre-configure multiple register lists of multiple slave stations that need to be read, and then the network port can read all registers at one time with one command, and the reading efficiency is very high. And the reading speed is very fast. For details, please refer to "Configurable Modbus Gateway ZLMB".

2. Four types of Modbus gateways

2.1. Simple protocol conversion

The original Modubs gateway just needed to solve the conversion of data format. For example, the function code 03 in Modbus RTU (RS485 end), the instruction to read 1 register starting from 00 is: 01 03 00 00 00 01 84 0a, of which 84 0a is the CRC check. And a Modbus TCP command (network side) is 00 00 00 00 00 06 01 03 00 00 00 01. We know that the ordinary serial server is "transparent", that is, the serial port sends 01 03 00 00 00 01 84 0a, and the network port is also 01 03 00 00 00 01 84 0a. In order to realize the function of converting RTU to Modbus TCP, the comparison found that as long as the CRC check 84 0a is removed and the beginning 00 00 00 00 00 06 is enough.

Multi-host conflict for simple protocol conversion

This simple format conversion can indeed meet the requirements initially. But the disadvantages are:

1. Unable to access by multiple hosts: Multiple Modbus TCP hosts cannot be implemented to access the gateway, because the data sent by host A and host B will preempt bus conflicts on the RS485 bus, causing data confusion.

2. Return data interference: The device's response to host A will not only be returned to host A but also to host B, so that there will be interference data in the return data of host B.

Although the conversion of the simple protocol has been eliminated, here is a brief introduction to its setting method: select the conversion protocol to "Modbus TCP to RTU" in the "Device Edit" interface of the ZLVircom configuration tool, and remove the "Multi-Host" in the advanced options. "And "RS485 anti-collision" two tick.

2.2. Multi-host mode

The Modbus gateway in multi-host mode is designed to solve the shortcomings of the "simple protocol conversion" mode. As shown in the above figure, when host A and host B access at the same time, the Modbus gateway will perform bus occupation scheduling to solve the problem of bus conflicts. In addition, the data accessed by host A will not be sent to host B again, which solves the problem of returning data interference. .

The data communication steps are as follows:

1. When the gateway receives the query request from host A, it checks whether the bus is in use, if it is free, it will be sent to the RS485 bus, otherwise it will wait until the bus is free.

2. The gateway records the currently queried host, here is host A.

3. When the data is returned from the RS485 bus, the gateway converts it into Modbus TCP format and forwards it to the corresponding host (here, host A).

The advantage of the multi-host mode is that it realizes the simultaneous access of multiple hosts and solves the problem of bus conflict and return data interference, but there are still shortcomings:

1. Slow data return: It can be seen from the above data communication steps that a host needs to forward the data line from the network to the RS485 bus to obtain data, and then forward it from the RS485 to the network after waiting for the device to return. Since the RS485 bus itself is a slow communication method, the host generally needs to wait 50-100ms to obtain a data.

2. When the number of hosts is large, the waiting is easy to time out: this is another problem caused by slow data return.

For the early ZLAN5142, the default is "multi-host mode"; for ZLAN5143 (version before 1.565), "multi-host mode" is not supported, only "storage type" is supported; for ZLAN5143 (version 1.565 and later), "multi-host mode" is supported , The setting method is: select the conversion protocol as "Modbus TCP to RTU" in the "device edit" interface of the ZLVircom configuration tool, and change the maximum waiting time for RS485 bus conflict to 2 seconds in the advanced options.

2.3. Storage Gateway

The storage gateway is designed to solve the shortcomings of the "multi-host mode". The slow problem of the "multi-host mode" is mainly caused by the slow return of data from the RS485 bus. The "storage type" idea is to obtain in advance Some required data is stored in advance, and can be provided immediately when the data is needed on the network side, thereby reducing data query time.

The storage gateway has two characteristics:

1. Self-learning: The storage gateway does not need to be configured, because it can save this record when the host asks for a query data, and the gateway will automatically learn the data needed by the current network port.

2. Inquiry in advance: After the gateway learns all the registers requested by all hosts, the gateway will inquire one by one in advance and store the results inside the gateway.

In this way, when host A wants the data that it has to use before, the gateway will retrieve the data from its own memory and return it to host A immediately. Since there is no process of forwarding to the RS485 bus, this time is about 1~ 2ms, which is much higher than the previous 50-100ms.

Advantages of storage gateways:

1. Fast return speed: The time for host A query to return data is greatly improved.

2. No need to configure: Because of the self-learning method, no need to configure, there is no difference between operation and "multi-host mode".

Problems with storage gateways:

1. The first command returns slowly: because the gateway obtains the register number requested by the host through learning, it cannot be inquired in advance before obtaining this information. Therefore, the first command sent by the host still needs to be transferred to the RS485 bus to obtain data. The return of the first command is as slow as in multi-master mode.

2. Too fast RS485 bus query may affect the operation of the device: Generally, by default, the RS485 bus will query the contents of the internal registers of the slave device at the fastest speed, and some instruments may not be able to adapt to such a fast query and cause the device to work abnormally. For this point, the "RS485 bus free time" parameter can be increased to solve the problem of too fast query, which can actually be solved.

3. Not the latest data: Since the data is queried and stored in advance, the data found may not be the latest data, although this time is only a few hundred milliseconds, it is also necessary to consider this for some special cases Delay.

4. Timing issues: Some Modbus TCP reading and storage need to operate in accordance with the timing of writing, reading, etc. The "stored" type of pre-storage will disrupt this timing and cause some devices to be incompatible.

The shortcomings 2, 3, and 4 here can all be withdrawn to the "multi-host mode" gateway to solve this problem. Note that the data return will be slower after withdrawing to the "multi-host mode". Note that the new firmware of ZLAN5143 supports two modes of "multi-host mode" and "storage type". And the above shortcoming 1 (the first command is slow to return), will be solved in the later "configurable" gateway.

ZLAN5142 does not support "storage type". The method for setting ZLAN5143 to "storage type" is: select the conversion protocol to "Modbus TCP to RTU" in the "Device Edit" interface of the ZLVircom configuration tool.

2.4. Configurable gateway

In order to solve the problem of slow return of the first command of a "storage type" gateway, a configurable gateway can be used. The configurable gateway also adopts the method of obtaining the contents of the RS485 bus slave station register by querying in advance of the "storage type" gateway. However, it does not use a self-learning method. In order to solve the problem of slow return of the first command, the required register list must be configured inside the gateway in advance. It can pre-configure the address, function code and register list of the Modbus RTU end device and store it inside the gateway. The gateway will automatically collect the data of these configured RTU devices, and then map them to consecutive Modbus TCP register addresses, thereby allowing the Modbus TCP end to read the data of different registers of all devices at once.

ZLAN configurable gateway is also called ZLMB gateway, which has the following advantages:

1. All instructions return fast: even the first instruction is equally fast.

2. Combining instructions to improve efficiency: It is possible to map scattered different station addresses and registers to the same register. In this way, the Modbus TCP end can collect all data with one instruction, including the data of devices with different station addresses, instead of dividing it into several instructions to collect separately, which improves the transmission efficiency of the Modbus TCP end.

3. Address remapping: In some cases, different scattered registers need to be remapped to the entire continuous area. The ZLMB gateway can meet this requirement.

Disadvantages of configurable gateways:

1. Manual configuration is required: If the "storage type" gateway can meet the requirements, the "storage type" can be selected first, because the "storage type" does not require any configuration. In ZLMB mode, you need to manually use ZLVircom to configure the required registers.

2. Problems caused by pre-reading: Like the storage type, there are "not the latest data" and "timing issues".

ZLAN ZLAN5143, ZLAN7144, ZLAN7146, ZLAN8303, etc. all support configurable Modbus gateway function. Among them, ZLAN5143 requires firmware version 1.579 and above, and works with ZLVircom 5.15 and above. The 7144 requires firmware version 1.491 and above. The configuration method is: click the "firmware and configuration" button in the "device edit" interface of the ZLVircom configuration tool, and then in the pop-up "web program download tool" dialog box, select "web directory download", and then click the "ZLMB" button , After the design is completed, click the "download" button to download to the device content. For details, please refer to the detailed introduction of "Configurable Modbus Gateway ZLMB".

3. Comparison of four types of gateways

In general, the configurable gateway is the most advanced Modbus gateway with the highest reading efficiency, but the configuration is more cumbersome; while the storage gateway is the default mode and the easiest mode to use, with multiple hosts and reading speed. Fast and other characteristics; and in some RS485 devices are not suitable for "pre-reading" this kind of situation, you can return to the slow mode of "multi-host" mode. The "simple protocol conversion" mode is generally not used due to bus errors and loss when there are multiple hosts.

4. Models and supported modes

The four Modbus gateway modes and corresponding models are now listed in the following table:

Item Product Simple protocol conversion Multi-host mode Storage gateway Configurable gateway
Ethernet Modus Gateway RS485 TO ETH (B)