Robotron Datenbank-Software GmbH Firmenlogo
MIT DATEN MEHR BEWEGEN.
🇩🇪 🇬🇧

Modbus

The Modbus module enables reading from and writing to slave Modbus modules.

The module acts as a master and provides access to Modbus slaves using the TCP and RTU protocol variants for both read and write access. For the data read or written, the module provides automatic conversion functions for various data types.

Multiple servers to be read as well as multiple slaves can be configured, which are polled at a configurable interval with various options (Subscription/Poll Group).

The following Modbus read functions are supported:

  • Read Coils (Function Code 01)

  • Read Inputs (Function Code 02)

  • Read Holding Registers (Function Code 03)

  • Read Input Registers (Function Code 04)

The following Modbus write function is supported:

  • Write Holding-Registers (Function Code 06)

Two transmission protocols are available:

  • TCP

  • RTU

Configuration Parameters

Server

The server configuration for the Modbus module can be adapted to match an existing system or the default configuration can be retained. The following two tables show all configuration parameters for the TCP and RTU connection.

Table 1. Modbus TCP Server Configuration
ParameterDescription

Server Name

Describes the name of the Modbus master to be read. The name can be freely configured using letters and numbers without special characters.

Protocol Variant

Selection of the TCP protocol

IP Adress

Enter the IP address of the Modbus TCP master in the format xxx.xxx.xxx.xxx

Server Port

The default Modbus TCP port is "502". The port can be adjusted according to the server configuration.

Table 2. Modbus RTU Server Configuration
ParameterDescription

Server Name

Describes the name of the Modbus master to be read. The name can be freely configured using letters and numbers without special characters.

Protocol Variant

Selection of the RTU protocol

Port Name

Name of the data source in the format /*/*
For RoboGate Devices powered by Turck this is /dev/ttyO1 by default.

Baudrate

Serial interface: data rate (specified by Modbus slave)

Data Bits

Serial interface: number of data bits (specified by Modbus slave)

Stop Bits

Serial interface: number of stop bits (specified by Modbus slave)

Parity

Serial interface: parity setting (specified by Modbus slave)

Slaves

Within the connection variants of the servers it is possible to access multiple slaves. This is particularly useful for Modbus RTU servers, where multiple slaves with the same connection parameters can be addressed. The distinction between different slaves is made via the Slave ID. It should therefore be unique within a group for each slave. Each Slave ID group can contain its own Poll, Subscription or Setup Groups.

ParameterDescription

Slave Name

Name of the Modbus slave

Slave ID

The ID (0 - 255) of the Modbus slave to be read.

Setup Groups

Using the Setup configuration, Modbus registers can be written. The setup configuration can be performed for both Modbus TCP and Modbus RTU. On startup or when the configuration changes, the specified values are written to the data registers once. Until all values have been written, all other groups within a slave are paused. The process is executed only once.

Table 3. Setup Configuration
ParameterDescription

Setup Name

Name of the setup

Parameter Name

The name can be freely configured using letters and numbers without special characters.

Write Address

Address of the Modbus register to be written

Type

Standard data types (UInt16, UInt32, UInt64, Int16, Int32, Int64) are preconfigured. Selection is made via a dropdown menu.

Value

Value to be written.

Little Endian

Memory structure toggle (if checked = true, Little Endian is used; otherwise Big Endian)

Poll Groups

Each Poll Group generates a message (payload type Model). The model corresponds to a message containing values from multiple data points.

Table 4. Configuration of Poll Groups in the Modbus Module
ParameterDescription

Poll Group Name
(Scope)

Name of the poll group, freely configurable using letters and numbers without special characters. This name corresponds to the name of the area to be read. The name is provided under Scope in evaluations.

Source

The following source modes are available:

  • "UseServerName"

  • "UseSlaveName"

  • "UseBoth"

The selected mode specifies which name is written to the SourceHeader. With "UseBoth", the combination ServerName.SlaveName is used in the SourceHeader.

Interval (ms)

Interval in milliseconds specifying the cycle at which values are polled.

Output Topic

Name of the output topic. The name can be freely configured using letters and numbers without special characters.

Field Name

Label of the value to be read. The name can be freely configured using letters and numbers without special characters.

Function Code

The following function codes are available:

  • 01 Read Coils (automatically Boolean data type)

  • 02 Read Inputs (automatically Boolean data type)

  • 03 Read Holding Registers

  • 04 Read Input Registers

Start Register

Register address

Type

Standard data types are preconfigured. Selection is made via a dropdown menu.

Length

Number of 16-bit registers to be read

Endian Mode

Memory structure toggle. The following options are available:

* bigEndian * littleEndian * bigEndianByteSwapped * littleEndianByteSwapped

Value Adjust Gain/Offset

Value post-processing: constant scaling by factor and summand (offset)

Test

Retrieve the current value.

The register length and the data type must be consistent. For standard data types, the length is determined automatically based on the preconfiguration. Only the Raw Hex data type is configurable.

Subscription Groups

With the Subscription Group, the slave node is polled at a configured Publishing Interval. Depending on the configuration, data packets are only generated if there has been a change in the timestamp.

This is not a subscription in the sense of the OPC UA specification. Instead, the slave is continuously polled with the resulting load on the slave, master, and network side!

Table 5. Configuration of Subscription Groups
ParameterDescription

Subscription Group Name
(Scope)

The name can be freely configured using letters and numbers without special characters. The name is provided under Scope in evaluations. Clicking "Create" creates a new group.

Source

The following source modes are available:

  • "UseServerName"

  • "UseSlaveName"

  • "UseBoth"

The selected mode specifies which name is written to the Source Header. With "UseBoth", the combination ServerName.SlaveName is used in the Source Header.

Publishing Interval (ms)

Interval in milliseconds specifying the cycle at which values are polled.

Republishing Interval (ms)

Interval in milliseconds specifying the cycle at which the last read values are sent again.

On Change:
Submit Full Model

Active: If the Modbus server reports a change, the changed data point is transmitted together with the last read values of the other data points as a model message.
CAUTION: Simultaneous changes to multiple data points within the Subscription Group are handled individually.
Inactive: If the Modbus server reports a change, only the changed data point is transmitted as an event message.

On Republish:
Submit Full Model

Active: During republishing, the data points are sent as a single data model message.
Inactive: During republishing, the data points are each sent as an individual message (event). A republish message always receives the current time as the message timestamp.

Output Topic

Name of the output topic. The name can be freely configured using letters and numbers without special characters.

Field Name

Label of the value to be read.

Function Code

The following function codes are available:

  • 01 Read Coils (automatically Boolean data type)

  • 02 Read Inputs (automatically Boolean data type)

  • 03 Read Holding Registers

  • 04 Read Input Registers

Start Register

Register address

Type

Standard data types are preconfigured. Selection is made via a dropdown menu.

Length

Number of 16-bit registers to be read

Endian Mode

Memory structure toggle. The following options are available:

* bigEndian * littleEndian * bigEndianByteSwapped * littleEndianByteSwapped

Value Adjust Gain/Offset

Value post-processing: constant scaling by factor and summand (offset)

Test

Retrieve the current value.

Configuration in the UI

After selecting the Modbus module on the start page or via the left menu bar of the RoboGate Edge UI, you will be taken to the Modbus module configuration. The following descriptions are based on the example of a Modbus TCP server.

Configuring a Server

By clicking add New in the left menu bar, a new Modbus server can be created and configured (Figure 1). In the first step, the Server Info and Connection must be configured for the new Modbus server. This also includes creating Modbus slaves.

modbus addServer
Figure 1. Adding a New Modbus Server

Once this configuration is saved save, the Module State section at the bottom of the page shows whether the module was able to establish a connection to the Modbus server.

One or more Setup, Poll or Subscription Groups can then be created separately for each slave.

Configuring a Group

After entering a name for the corresponding group, a new group is created by clicking "Create". The groups can then be configured with their configuration parameters. The following figures show example configurations for a Setup, Poll and Subscription Group for the created Modbus TCP server and slave.

To check whether a data block has been configured correctly, it can be tested using the arrow in the "Test" column. The read result is displayed after clicking the arrow refresh or updated when changes are made. Initially, no values are displayed.

modbus configSetupGroup
Figure 2. Configuration of the Setup Group
modbus configPollGroup
Figure 3. Configuration of the Poll Group
modbus configSubscriptionGroup
Figure 4. Configuration of the Subscription Group

Once the Modbus server configuration is complete, it can be saved using the "Save Configuration" button save in the horizontal menu bar at the top right of the module ([img-modbus-saveConfig]). Saving the complete Modbus module configuration makes it available in RoboGate Edge.

Deleting a Data Field

Within the Modbus server configuration, data fields in the group configurations can be deleted. The data field to be deleted is removed using the delete button close. The new Modbus server configuration must then be confirmed using the "Save Configuration" button save. The updated configuration is now available in RoboGate Edge.

Deleting a Group

Within the Modbus server configuration, entire groups can be deleted from the configuration. The group to be deleted is removed using the "Remove" button (Figure 5). The new Modbus server configuration must then be confirmed using the "Save Configuration" button save. The updated configuration is now available in RoboGate Edge.

modbus deletePollgroup
Figure 5. Deleting a Poll Group

Deleting a Server

Within the Modbus server configuration, a Modbus server can be deleted. Clicking the "Remove" button in the server configuration section deletes the selected server (Figure 6). Saving the Modbus configuration afterwards confirms the deletion.

modbus deleteServer
Figure 6. Deleting a Modbus Server

Resetting the Configuration

The "Reset" button reset in the horizontal menu bar can be used to easily reset the complete module configuration to factory settings. After clicking the button, a confirmation dialog with "Yes" and "No" appears, asking whether the operation should actually be performed.

This also deletes the entire history on the RoboGate Edge!