https://ipc2u.com/articles/knowledge-base/complete-faq-about-the-modbus-protocol-conversion/
16:30 17.01.2019
+49 511 807 259-0, sales@ipc2u.com
Cart
Price on request
Discount -
Total:
Favorite products
Call
Authorization
Login:
Password:


Forgot your password? Registration
Forgot your password?
e-Mail::
Forgot your password?
+49 511 807 259-0, sales@ipc2u.com

Complete FAQ about the Modbus protocol conversion

Complete FAQ about the Modbus protocol conversion

The Modbus protocol is widely used in the automation of production, many devices support the Modbus RTU communication protocol, which uses a serial interface. Typically, the devices have an RS-232 or RS-485 interface with a DB-9 connector or a terminal block. Modbus RTU devices are easy to implement and inexpensive to maintain. That's why the Modbus RTU protocol has become so popular. Today, more and more industrial devices are starting to support the Ethernet standard. The complexity and scale of networks are increasing. Many systems already work through Modbus TCP using Ethernet, for example, SCADA. As a result, there are interfacing problems between Modbus RTU and Modbus TCP protocols. The following frequently asked questions and their answers are designed to help you identify and prevent frequent problems with the Modbus protocol conversion.

FAQ:

  1. Do I need a special protocol converter for connecting devices with a serial Modbus RTU interface to an Ethernet network? Is the server of serial devices sufficient?
  2. If several Modbus RTU devices are connected to different serial ports of the gateway, what should be the TCP connection architecture? Can I use a single connection or do I need a separate connection for each serial port?
  3. How can multiple SCADA hosts access the same Modbus RTU devices at the same time using a single gateway?
  4. I have two working Modbus master devices (PLC or HMI). How can I organize data exchange between them?
  5. I have several Modbus RTU devices that need to be polled. I can use several Modbus commands to get register data, but it takes too long. Can the gateway actively receive data and merge them into a single register so that I can get all the data with a single Modbus command?

Do I need a special protocol converter for connecting devices with a serial Modbus RTU interface to an Ethernet network? Is the server of serial devices sufficient?

First of all, you need to determine which Modbus driver on the SCADA host you want to use. There are four possible options:

  1. SCADA host with Modbus TCP driver
  2. SCADA host with Modbus RTU driver - with built-in serial port
  3. SCADA host with Modbus RTU driver - without built-in serial port
  4. SCADA host with the driver «Ethernet Encapsulation»

Option 1: SCADA host with Modbus TCP driver

This version requires a protocol converter. You can use the Modbus TCP protocol to communicate with Modbus RTU devices through the gateway.

In the market of automation devices, many "Modbus gateways" are available that provide connection via Modbus TCP for Modbus TCP slave devices. When the gateway receives a Modbus TCP request, it converts the packet to a Modbus RTU and immediately sends it to the Modbus RTU devices.

Option 2: SCADA host with Modbus RTU driver - with built-in serial port

This option is suitable if you just need to connect an existing SCADA host and Modbus RTU devices to an Ethernet network. If your SCADA host is equipped with a serial port, then using a pair of gateways you can solve this problem.

As shown in the network diagram, the gateway can convert the Modbus RTU package to Modbus TCP and vice versa. If the built-in serial port is missing, this solution does not suit you, use option 3.

Option 3: SCADA host with Modbus RTU driver - without built-in serial port

If you want to use existing SCADA programs and devices, but your SCADA host is not equipped with a serial port, use a serial device server to create a virtual COM port. So you can access remote serial devices through the server, and the functionality will correspond to the real COM port.

To create a "virtual COM port", the serial device server will install the virtual COM port driver on your SCADA host. To activate this port, install the serial device server in virtual COM port mode. All data transmitted through it will be sent to the remote serial port of the serial device server. Since from the point of view of the OS and SCADA virtual COM is identical to the real one, you can send a Modbus RTU request to it directly.

Option 4: SCADA host with the driver «Ethernet Encapsulation»

If your SCADA host does not have a serial port, and you do not want to install a virtual COM port driver, you can use the Ethernet Encapsulation driver instead. Note that the SCADA software must support the «Ethernet Encapsulation type». The use of «Ethernet Encapsulation» drivers is recommended when there is an in-depth knowledge of serial protocols and TCP / IP protocols.

The serial device server must be switched to Raw Socket or Tunneling mode, when sending SCADA Modbus RTU packets to devices, the connection between the host and the serial device server is carried out through a transparent TCP / IP or UDP channel without protocol conversion. The serial device server must be configured correctly, because Modbus RTU defines the end of a packet based on pauses in the transmission. If the Modbus RTU package is divided into two or more TCP / IP or UDP packets, you may encounter some problems. If you cannot properly configure the transmission of packets between serial channels and Ethernet networks, it is recommended to use the option with a gateway (2) or a virtual COM port (3).

Although serial device servers can be used to connect Modbus RTU devices to an Ethernet network, the gateway option (2) is the most preferred and satisfies almost all system requirements. Your host must support the Modbus TCP protocol, but this rarely causes problems; This protocol is very popular and widely distributed. Here are some situations in which you need to use the presented version with the gateway:

Multiple host devices or network redundancy

Connecting via Ethernet allows not only to use remote access, but also supports several connections. Most gateways support up to 32 connections, i.e. 32 SCADA hosts can simultaneously request data from Modbus RTU devices. In this situation, it is rather difficult to provide redundancy of the network using a serial device server, because Most servers do not support several leading devices, on the other hand, the use of gateways will not cause any problems.

One connection for multiple Modbus RTU devices

Sometimes it is necessary to use one connection on the SCADA host to poll several Modbus RTU devices connected to different serial ports. The gateway is the only solution that can implement such a routing mechanism. Gateways with multiple serial ports can be configured to send a Modbus request to the appropriate serial port, taking into account the unique identifiers of the slaves.

The north of serial devices cannot cope with such a difficult task.

Simultaneous access to the device from the old Modbus RTU controller and the new Modbus TCP SCADA

Although the Ethernet protocol makes it easy to configure remote access, it is sometimes necessary to save existing local connections to the controller or HMI. The problem is that the serial port on the device is already connected to the gateway, so there is no serial port for HMI connection. To solve this problem, some gateways are equipped with the "Serial Redirector" function. This system is very similar to a router in that the gateway can send a request between different serial ports based on the slave ID.

Conclusion

There are many variants of Modbus conversion between serial interface and Ethernet. Although in this case, such a simple option as transparent data transmission between serial and Ethernet ports can be used, when working with industrial protocols, for example, Modbus, a special gateway fits much better. The use of such a gateway may require a large initial investment, but it provides a more stable link in the long term and is able to recognize Modbus packages for proper processing.

Back to FAQ


If several Modbus RTU devices are connected to different serial ports of the gateway, what should be the TCP connection architecture? Can I use a single connection or do I need a separate connection for each serial port?

Most gateways provide flexible TCP connection settings for accessing multiple Modbus RTU devices connected to different serial ports on the gateway. There are three different methods based on the routing mechanism:

  1. Connect the serial port to a unique TCP port
  2. Connection of the serial port to a unique IP address
  3. Using the routing table

Method 1: Connect the serial port to a unique TCP port

The most popular method for planning the gateway topology. In the gateway configuration, each serial port will be connected to a separate TCP port. For example, 4001 is serial port 1, 4002 is serial port 2, and so on. If you want to connect Modbus RTU devices to serial port 1, establish a Modbus TCP connection with 4001. The gateway will send Modbus TCP packets between TCP port 4001 and serial port 1.

In this topology, the SCADA driver must create multiple Modbus TCP connections.

Method 2: Connect the serial port to a unique IP address

This option is very similar to option 1, but the gateway uses different IP addresses to identify the serial ports.

For example, 192.168.2.1 - to serial port 1, 192.168.2.2 - to serial port 2, etc. If you want to connect Modbus RTU devices to serial port 1, establish a Modbus TCP connection with 502. The gateway will send Modbus TCP packets between 192.168.2.1:502 and serial port 1. In this topology, the SCADA driver also needs to create several Modbus TCP connections. Although the topology requires multiple IP addresses, some Modbus TCP clients only allow TCP port 502. In this case, option 1 is not suitable for you, and you will have to use option 2.

Method 3: Using the Routing Table

In this topology, routing is used to communicate with multiple devices. For a request to be sent to the correct serial port, the gateway and routing direction must be configured correctly. For example, serial port 1 processes all Modbus packages that have slave IDs from 1 to 10, serial port 2 identifiers 11 to 20, and so on.

Because In the topology, only one connection is used, communication will be slower than options 1 and 2. However, with budgetary and technical limitations, one connection may be an appropriate option if sufficient performance is provided.

Note:

If you connect multiple devices to the same serial port or bind multiple serial ports to the same TCP connection, the Modbus polling time will increase. To increase the polling rate, you need more TCP connections, so you need to consider the capabilities of SCADA.

Back to FAQ


How can multiple SCADA hosts access the same Modbus RTU devices at the same time using a single gateway?

Although the gateway can handle this, remember that the serial port bandwidth remains unchanged. If multiple requests are received through one serial port, a delay may occur. The gateway processes the earlier requests first. Therefore, if you want to allow multiple master devices to simultaneously access the Modbus RTU device, you first need to select the appropriate polling time.

Nevertheless, the solution described above is not the only one. Some gateways support the "agent" mode, which is actively and constantly receiving data from the connected devices.

Updating data is stored in the internal memory, which is used to respond to host requests. Although this solution is faster and more efficient, the data obtained will not be the most relevant.

For example, if one request is 100 ms, then 5 connections will cause a delay of at least 100 msec (5-1) = 400 ms before sending the next request. This means that the scan cycle of each SCADA host should be 400 ms (plus some tolerance).

Back to FAQ


I have two working Modbus master devices (PLC or HMI). How can I organize data exchange between them?

To exchange data between two Modbus master devices, a gateway is required that can support the master-master mode. In this mode, the gateway will work as a slave device for both sides. One master device can write data to the internal memory of the gateway, and another - to receive them, thereby providing an exchange. Depending on the gateway you are using, you can provide Modbus RTU and Modbus TCP support for both sides, or Modbus RTU support for one and Modbus TCP for the other.

Back to FAQ


I have several Modbus RTU devices that need to be polled. I can use several Modbus commands to get register data, but it takes too long. Can the gateway actively receive data and merge them into a single register so that I can get all the data with a single Modbus command?

In order for the gateway to actively receive data from several Modbus RTU devices and put them in a single register, the gateway agent must store the data in the internal memory. The gateway must also interrogate each Modbus RTU device in turn. All data will be located in one block in the internal memory of the gateway, so you can get them with a single read command.

Back to FAQ


Glossary

Serial device server

A serial device server is a stand-alone device that has at least one Ethernet port and one or more serial ports. Serial device servers are equipped with an embedded network operating system and allow computers to access serial devices on the network. They can transparently transfer data between the serial interface and Ethernet, while converting them accordingly.

Modern serial device servers also support the "virtual COM port" function for computers that do not have an additional serial port, converting the Ethernet connection to the COM port. In addition to these core functions, more complex servers can even support PPP over serial lines or Telnet - in Ethernet networks. The serial device server can be used for console management of network and server equipment (which is why some manufacturers call it "console") or remote terminal management in old banking systems (therefore sometimes called "terminal").

Virtual COM port, virtual COM port driver

A virtual COM port is not a real (non-physical) COM port on the computer. Instead, a virtual COM port driver is installed on the computer, completely emulating the behavior of the local COM port. The driver manages the ports on a serial device server that is connected over a TCP / IP network. The serial port on the remote serial device server will function in the same way as the local COM port. A virtual COM port is attached to a specific port on a specific serial device server. For example, COM3 is a serial port 1 on a remote serial device server with an IP address of 192.168.2.1. Therefore, when data passes through this port, they will be sent by the driver to "192.168.2.1@serial port 1" (192.168.2.1 to serial port 1). All requests for this virtual COM port will be forwarded to "192.168.2.1@serial port 1". Because New host computers often have insufficient number of built-in serial ports, virtual COM ports are an invaluable tool for connecting existing industrial automation equipment.

Transparent gateway

Transparent gateway is the main method of using the Modbus gateway. Because Modbus RTU and Modbus TCP protocols have the same PDU (data block), and the difference is only in the header, the gateway can easily transfer data between such devices. Thus, when a gateway receives a Modbus TCP packet from an Ethernet network, it can simply replace the address field in accordance with Modbus RTU requirements and immediately send the packet to the serial port. When the gateway receives a response from the Modbus RTU device, it will respond to the Modbus TCP client.

Gateway agent

A gateway agent is another method of using the Modbus gateway to transfer data between Modbus TCP and Modbus RTU devices. The gateway agent is equipped with its own internal memory for temporary data storage and continuously polls connected devices. When a request is received from the SCADA driver, the gateway uses the data stored in the internal memory to respond. Therefore, the gateway acts as an agent for actively polling devices. This function can be used to convert protocols if:

  1. The two protocols use a different packet structure. For example, PROFIBUS and Modbus, Ethernet / IP, PROFINET, etc.
  2. Two protocols use different cycle times. Some protocols, for example, PROFIBUS, PROFINET and Ethernet / IP, exchange data for very short time cycles, in which a transparent gateway cannot meet

Get more information, please contact our sales team! sales@ipc2u.com

Related


https://ipc2u.com/articles/knowledge-base/complete-faq-about-the-modbus-protocol-conversion/
16:30 17.01.2019