Modbus is a general industrial standard. Control devices produced by different manufacturers can be connected to an industrial network through Modbus for centralized monitoring.
Modbus TCP and Modbus RTU are two common transmission methods of Modbus, Modbus RTU is serial communication, Modbus TCP is TCP communication, the two are very similar in protocol, but due to the reliability of the TCP protocol, no verification is required in the Modbus TCP protocol. , and one more application header than the Modbus RTU protocol.
As an IoT edge industrial protocol gateway software that supports dozens of industrial protocol conversions, Neuron has also implemented the function of TCP transmission based on the Modbus RTU protocol. At the same time, in the Modbus protocol, Neuron optimizes the strategy according to the configured points, which can realize the function of automatically collecting device data in batches.
This article will introduce how to use Neuron to access Modbus TCP and Modbus RTU under the environment of Ubuntu 20.04.3 and X86_64.
Introduction to Neuron
Neuron is an industrial protocol gateway software that can run on various IoT edge gateway hardware. It aims to solve the problem of difficult unified access to device data in the context of Industry 4.0. By converting data of different protocol types from complex and diverse industrial equipment into unified standard IoT MQTT messages, the interconnection between devices and industrial IoT systems and between devices is realized, and remote direct control and information acquisition are carried out. Intelligent manufacturing provides data support.
Neuron supports one-stop access and MQTT protocol conversion for multiple different communication protocol devices and dozens of industrial protocols at the same time. It only takes up ultra-low resources, that is, it can be deployed in X86, ARM, RISC-V, etc. in the form of native or container in various edge hardware of the architecture. At the same time, users can realize online gateway configuration management through the Web-based management console.
Configuration environment description
Please download Neuron software from the official website https://neugates.io/zh/downloads and execute the following instructions to install Neuron software.
sudo apt install ./neuron-2.0.1-linux-amd64.deb
Then use the following command to check the Neuron status
sudo systemctl status neuron
- Please download the Modbus simulator from the PeakHMI official website and install it, then open the Modbus TCP slave Ex.
For getting started with Neuron, please refer to: Neuron Quick Tutorial .
Operating procedures
Two plug-ins, modbus-plus-tcp and modbus-rtu, will be used in Neuron. The following will introduce how to connect to Modbus TCP.
Example of connecting to Modbus TCP
The first step is to create a node card
- Click
添加设备
; - Fill in the device name, such as modbus-plus-tcp-1;
- Select from the drop-down box
modbus-plus-tcp
plugin.
The second step, device configuration
Click the 设备配置
button in the node card to enter the device configuration interface.
Fill in the IP address where the Modbus simulator is started;
- Started neuron and modbus simulator should be under the same network segment;
- The windows where the Modbus simulator is located should close the firewall as much as possible, otherwise it may not be able to connect to Neuron.
- Fill in the port number of the Modbus simulator, generally the default is 502;
- Set the timeout time for Neuron to connect to the device;
- Select the connection method, Neuron now supports two connection modes as Client and Server, and the Client connection method is selected by default;
- Click
提交
to complete the device configuration and open the card working state.
The third step, create a Group group
Click any blank space of the node card to enter the Group* list interface.
- Click
创建
; - Fill in the Group name in the pop-up box, such as group-1;
- Fill in the time interval for Neuron to read data from the device and upload data in the pop-up window, for example, 3000;
- Click
创建
to complete the creation of the Group;
*Note: Group can be understood as a type of sensor. For example, if multiple temperature sensors and multiple humidity sensors are connected to one device, a "temperature" group can be set to unify all temperature sensors into one group. Data reporting and reading are in groups, and users can group points according to business needs.
Note:
When configuring Modbus points of different stations on the Neuron, it is recommended to include only the points of one station under the same Group, or only include the points of the same data area under one station to obtain higher configuration collection efficiency.
The fourth step, create a Tag
Click Tag 列表
→ 创建
in the Group to manually add tags.
- Fill in the Tag name, such as tag1;
- Fill in the Tag address, such as 1!40001 (for detailed address configuration rules, please refer to the extended knowledge below);
- Drop-down selection properties, such as Read, Write;
- Drop down to select the data type, for example, select INT16;
- Click
创建
to add a Tag; - You can also click
添加
, add multiple Tags at a time and then click创建
;
After the creation is completed, the Tag list will display the created Tag information, then return to the southbound device management interface, wait for about 15s, and check whether the connection status of the Modbus node card displays 已连接
, as shown in the following figure.
If the connection is not connected for a long time, please perform the following troubleshooting:
- Check whether the host and port of the device configuration are incorrectly filled against the simulator. You can execute the telnet command on the terminal running the Neuron server to check whether the remote server and port can be accessed;
- In the terminal running the Neuron server, check whether port 502 is occupied;
Check whether the port number of the emulator is 502, and check the Port Number in file → settings, as shown in the following figure.
The fifth step, data monitoring and viewing data
After successfully connecting to the Modbus simulator, you can open the data monitoring interface to view the data collected by Neuron from the Modbus simulator.
Example of connecting to Modbus RTU
The steps are like Modbus TCP, but because Modbus RTU is serial communication, so 设备配置
is different from Modbus TCP.
- Device, the path of the serial port connection;
- Stop, stop bit;
- Parity, check digit;
- Baud, bit rate;
- Data, data bits;
Neuron already supports Modbus RTU-based TCP transmission function, and the application configuration is shown in the figure below.
knowledge extension
The general configuration format of Modbus point address in Neuron is SLAVE!ADDRESS
, among which:
- SLAVE stands for Slave ID;
- ADDRESS refers to the PLC address:
block | Modbus block number |
---|---|
coils | 0 |
input registers | 3 |
Discrete input (Input) | 1 |
hold registers | 4 |
The function code and register addressing address are used in the instruction. The register addressing address starts from 0. Different function codes correspond to different blocks. The PLC address is block number + register addressing address + 1. For example, if the function code 0x03 is used, the addressing address is 0, and the corresponding ADDERESS in neuron should be 40001.
Epilogue
So far, we have completed the entire process of using Neuron to access Modbus TCP and Modbus RTU protocol devices. As an edge industrial protocol gateway software for the "connection" of the Industrial Internet of Things, Neuron also supports access to other industrial protocols such as OPC UA and Siemens, helping to build an efficient Industrial Internet of Things platform.
Copyright statement: This article is original by EMQ, please indicate the source when reprinting.
Original link: https://www.emqx.com/zh/blog/connecting-modbus-tcp-and-modbus-rtu-protocol-devices-with-neuron
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。