5. RTU over TCP Master Configuration

Modbus RTU over TCP Master Overview

This guide describes how to configure the Edge One™ Modbus module in Modbus RTU over TCP Master mode and it includes the following sections.

  1. Modbus RTU over TCP Overview describes the features of Modbus RTU over TCP.
  2. Requirements for the configuration of Modbus RTU over TCP.
  3. Configuring a Modbus RTU over TCP Master indicates the initial steps for configuring the RTU over TCP Master.
  4. Configuring the RTU over TCP Slaves describes how to add and configure RTU over TCP slaves also called groups.
  5. Configuring registers indicates how to configure the registers of a slave or group.
  6. Configuring a single register indicates on how to add and configure a single register.
  7. Editing a register describes how to edit a single register.
  8. Deleting a register shows how to delete a register.
  9. Adding multiple registers provides instructions on how to add and configure multiple registers with a single command.
  10. Importing registers describes how to import registers from a Tab Delimited Text file.
  11. Exporting registers describes how to export registers in a Tab Delimited Text file.

For instructions on configuring a Modbus Slave or SCADA gateway please refer to its documentation.

Once the project is configured and Saved you must create a Message Router project and configure the cloud access parameters to connect uni-directionally or bi-directionally to CloudPlugs or a supported IoT cloud service.

Modbus RTU over TCP Overview

RTU over TCP provides a method to transmit RTU messages with a TCP/IP wrapper through a gateway onto Ethernet without changing any of the bytes in the message. Standard Modbus RTU is meant for transmission over serial lines. The most common being RS-232 and RS-485. The message starts with a one byte Slave ID and ends with a two byte CRC. In RTU over TCP, the Server does not have a Slave ID and uses an IP Address instead.

It is important to know that Modbus RTU over TCP and Modbus TCP are very different protocols. Here are the main differences:

  1. Modbus TCP has a different specification in which the message bytes are modified to add the 6 byte MBAP header and remove the two byte CRC.
  2. Modbus TCP and Modbus RTU over TCP share the same Protocol Data Unit (PDU) but have a different Application Data Unit (ADU).
  3. Modbus TCP ADU is made up of: MBAP header + PDU.
  4. Modbus RTU ADU is made up of: Slave address + PDU + CRC.
  5. Modbus RTU over TCP, takes the whole standard RTU ADU (as used on serial RTU networks) and sends it over TCP (basically putting the RTU ADU inside a TCP wrapper and transferring it over a TCP interface). The receiving end must then extract the RTU ADU from the TCP layer and pass it to the serial RTU device on the serial network.

Back to Top

Requirements

The following are the requirements to use Modbus RTU over TCP on the Edge One™.

  1. The Edge One™ and the Edge One™ Modbus module need to be installed on the gateway or virtual machine acting as the Modbus Master.
  2. Ethernet communications between Edge One™ and the Modbus slave device(s) or PLC(s).
  3. When using the Edge One™ Modbus module to interface a Modbus device, you need to get documentation from the equipment manufacturer that describes the available registers and how to address them. Modbus protocol does not provide a means for registers to automatically identify themselves. You must consult the equipment manufacturer.
  4. Modbus RTU over TCP requires that you know or define:
  • The slave ID (aka slave address, unit number, unit ID).
  • The IP address of the Slave(s).
  • The TCP port of the Slave(s).
  • The serial baud rate.
  • The data format (data bits, parity, and stop bits).

A mis-match in any of these will result in no communication.

Note:

While the RTU over TCP server does not have a Slave ID, Edge One™ requires to configure one. The Slave ID is not used for addressing in this case, but to identify the Slave in the IoT channel/topic when data is sent to an IoT server or cloud.

To better identify the data source, Edge One™ channels have the structure user_defined_prefix/modbus/project_name/slave_ID/map_ID.

  1. Configuration of a Message Router project and route to send the Modbus data to CloudPlugs, a supported public IoT cloud service or to a local MQTT server.

Back to Top

Configuring a Modbus TCP Master

  1. In the Project tab:
  • Enter a name for the project.
  • Select Master from the Mode dropdown menu.
  • Set the log level.
  • Silent - No logs will be printed on the console.
  • Error - Reports only important and blocking errors that can cause malfunctions.
  • Warning - All warnings for abnormal, non-blocking events as well as Errors will be reported in the logs.
  • Info - All messages relevant to the current system status as well as Warnings and Errors will be reported in the logs.
  • Debug - Full verbose mode. All errors, warnings, and information will be reported on the log console.
  • Select whether or not the project will be started automatically when the Modbus module container is started. To start the project manually using the web interface, set the Manual mode switch to ON.
  • Click on Next to open the Protocol tab.
Master
  1. In the Protocol tab:
  • Select Modbus RTU over TCP under Protocol Type.
  • Optionally, turn on the Low level debug switch to get information on Modbus low level communications in the log console.
  • Set the Timeout parameters, scheduling interval and the inter slave delay.
  • Click on Next to open the Slave tab and configure your TCP slave(s).
TCP Master

Back to Top

Configuring the RTU over TCP Slave(s)

To configure the Modbus RTU over TCP slave(s):

  1. In the Slaves tab click on Slave.
Slave TCP settings
  1. In the Configure Slave page:
  1. Enter a Group/Slave Name to name your Slave.
  2. Enter a Group ID, which is a number to identify your Slave in the Edge One™ topic that will be used to publish the Modbus data.
  3. Enter a Slave ID, which is a unique unit address from 1 to 247. When the Master requests data, the first byte it sends is the Slave address.

This way, each Slave knows, after receiving the first byte, whether or not to ignore the message.

  1. Enter the Slave IP address.
  2. Enter the Slave’s TCP Port. The most commonly used Modbus server (Slave) TCP port is 502.
  3. Set the RTU parameters.
  1. Baud Rate. Speed of communication over the serial data channel. Supported baud rates in bits per second (bps) are 300 to 230,400.
  2. Data Bits. Data is transmitted as a series of five, six, seven, or eight bits with the least significant bit sent first. At least seven data bits are required to transmit ASCII characters. Eight bits are required to transmit binary data. Five and six bit data formats are used for specialized communications equipment. Supported values are: 5, 6, 7, 8.
  1. Parity. A parity bit, or check bit, is a bit added to a string of binary code to ensure that the total number of 1-bits in the string is even or odd. Parity bits are used to check or detect transmission errors. Supported parity values are: None, Even or Odd.
  1. Stop Bits. In serial communications, stop bits are used to signal the end of a frame. Supported values are 1 or 2.
  2. Set the Polling Interval (optional) for the polling of the Map. Interval is the period between the starts of consecutive polls of a particular Map.
  1. Set Inter Register Delay. This is the optional pause in milliseconds between the polling of two consecutive registers in this Map.
  1. Set Retry Attempts. This is an optional parameter that specifies the number of times to retry polling the registers in the Map in case of errors. Its minimum value is 1.
  1. Optionally, turn the Highest priority setting switch on. This setting gives the polling of this map the highest priority. Use this switch when exact data retrieval intervals are required.
  1. Optionally, turn the Show Stats switch on. This setting enables the display of the results of all the polling attempts on the console log.
Slave TCP settings

A slave created can be deleted with the delete button.

Additional slaves can be added using the Slave button.

  1. Click Next or Save. Next will place you on the Slave tab so you can configure your registers.

  2. Configure registers by clicking on Manage registers on the Map you just created. The next section describes how to configure one or multiple registers.

Back to Top

Configure Register(s)

The register configuration is exactly the same for Modbus RTU, Modbus TCP and Modbus RTU over TCP. To configure registers for the first time:

  1. Click on Manage registers in the Slave tab. This opens the Registers tab. Once one or more registers have been configured, they can be added, edited, or deleted using the Registers tab. You can also search for registers using the search input field.
Registers tab
  1. There are multiple ways to configure registers:
    • Register allows to configure a single register.
    • Multiple Registers allows to configure multiple registers at a time.
    • Import TXT allows to import a Tab Delimited Text register configuration file.
    • Export TXT allows to export the Slave’s registers in a Tab Delimited Text file format so it may be imported into another Slave/Group or another Modbus application.

The sections below describe each one of the register configuration methods.

  1. Once the registers are configured and the Project is Saved, please configure the IoT cloud communications parameters by creating or configuring a Message Router project.

To learn how to delete or edit a register, please refer to the Deleting a Register and Editing a Register sections, respectively.

Back to Top

Configuring a Single Register

To Add a single Register, its Label, Register Address, Object Type, Data Type, Size and Options need to be configured or left with default values. To set up the register with your values:

  1. Open the Registers tab.
Registers tab
  1. Click on the [ Register ] button.
Single Register
  1. Enter a Label to name your register.

  2. Enter a valid 16-bit register address (0 - 65,535).

  3. Configure the Object Type. The following types of registers are supported:

    Object Type Access Size
    Coil Read-write 1 bit
    Discrete Input Read-only 1 bit
    Input register Read-only 16 bits
    Holding register Read-write 16 bits
  4. Configure the Data Parameters.

Select and configure the parameters that apply to your data set.

Please note** that Data Type and Byte order parameters apply only to Input and Holding registers. Coils and Discrete Inputs are only one bit long and, therefore, these parameters do not apply to them. Size applies to all Object types.

  1. Select a Data type:
Data Type Description
Bitfield16 Packed data structure that holds a sequence of 16-bits. A single value represents the 16-bits.
Bitfield16 (unpacked) Unpacked data structure with a sequence of 16-bits. Allows to add a label to every one of the 16 bits.
Bitfield32 Packed data structure that holds a sequence of 32-bits. A single value represents the 32-bits.
Bitfield32 (unpacked) Unpacked data structure with a sequence of 32-bits. Allows to add a label to every one of the 32 bits.
Byte [<n>] An array of raw values with no defined meaning.
Double64 Double precision floating point values.
Float32 32-bit floating point values.
Int16 16-bit integer.
Int32 32-bit integer.
Int64 64-bit integer.
String[<n>] Array of character values.
Uint16 Unsigned 16-bit integer.
Uint32 Unsigned 32-bit integer.
Uint64 Unsigned 64-bit integer.
  1. Configure the byte order parameters.
  • To use Big Endian and send the most significant byte first, turn on the Big Endian switch. The default is Little Endian.
  • To reverse the byte order, turn on the Reverse Byte order switch. The default is normal order.
  1. Configure the Register size.
  • Register sizes are expressed in number of words. Words are 2 bytes, or 16 bits long. The register will start at the address specified, and will have the size set by this parameter.
  • Please note that the size must be multiple of the data type selected. For example, for Double64, the minimum size is 4 and any size set must be a multiple of 4. For Int32 the minimum size is 2, and any size set must be a multiple fo 2. For Bitfield16, the minimum size is 1, and the size is any multiple of 1.
  1. Configure the Connection Parameters.

The following connection parameters can be configured.

  1. Retry Attempts. Number of times the master will retry to poll the register when there are errors.
  1. Response Timeout. Time interval in microseconds to wait for the response from a Modbus slave.
  1. Byte Timeout. Time interval in microseconds to wait for a byte from a Modbus slave.
  1. Once you have completed configuring the register, you have multiple options:
Register Configuration
  1. Click Delete to delete the register you just created.
  1. Save to save your work.
  1. Save and Restart to save your configuration and run the Modbus module. If the module was previously configured and running, it will be stopped and restarted with the new configuration.
  1. Click Next to view your register in the Registers tab. In this page you can:
  1. Edit a register by pressing the button.
  2. Delete a register by pressing the button.
  3. Cancel the Project if it was not saved.
  4. Save or Save and Restart the project
register list
  1. Configure the IoT cloud communications parameters by creating or configuring a Message Router project.

Back to Top

Editing a Register

To edit a register:

  1. Open the Registers tab.
Registers list
  1. Select the register to edit and click on the Edit ( ) icon.
Edit a register
  1. Configure the register as indicated in the Configuring a Single Register section.

  2. Press the Save button to save the changes, or the Save and Restart button to save and run the Modbus module. If the module was previously configured and running, it will be stopped and restarted with the new register configuration.

Back to Top

Deleting a Register

There are two ways to delete a register:

  1. Deleting it from the Register list.
  1. Open the Register tab.
Register Tab
  1. Select the register.
  2. Click on the Delete ( ) icon.
Delete register from list
  1. Opening the register and deleting it.
  1. Open the Register tab.
Register Tab
  1. Select the register.
  2. Click on the Edit ( ) icon.
  3. Click on the Delete button on the lower left hand side of the register configuration panel. Notice that here we are deleting a Coil register and, therefore, there is no Data Type or Big Endian and Byte Order switches.
Delete register from list

Back to Top

Adding Multiple Registers

The Modbus module allows to configure multiple registers with similar characteristics with one set of parameters.

When adding multiple registers, their Labels, Number of Registers, starting Register Address, Object Type, Data Type, Size, Object Type and Options need to be configured or left with default values, if applicable.

Once the registers are added, they can be individually edited by selecting them from their Map’s register list and clicking on the Edit icon ( ) to configure specific parameters, if desired.

To add multiple registers:

  1. Open the Registers tab.
Register Tab
  1. Click on the [ Multiple Registers ] button to open the Multiple Registers page.
Add Multiple Registers
  1. Enter a Label to name your registers. The register labels will have labels of the format Label#, where # is replaced by the register number.
  2. Enter the number of registers to be created.
  3. Enter a valid 16-bit starting address (0 - 65,535). The new registers will have addresses including and following the starting address.
  4. Configure the Object Type. The following types of registers are supported:
Object Type Access Size
Coil Read-write 1 bit
Discrete Input Read-only 1 bit
Input register Read-only 16 bits
Holding register Read-write 16 bits
  1. Configure the Data Parameters.

Select and configure the parameters that apply to your data set.

Please note that Data Type and Byte order parameters apply only to Input and Holding registers. Coils and Discrete Inputs are only one bit long and, therefore, these parameters do not apply to them. Size applies to all Object types.

  1. Select a Data type:
Data Type Description
Bitfield16 Packed data structure that holds a sequence of 16-bits. A single value represents the 16-bits.
Bitfield16 (unpacked) Unpacked data structure with a sequence of 16-bits. Allows to add a label to every one of the 16 bits.
Bitfield32 - Packed data structure that holds a sequence of 32-bits. A single value represents the 32-bits.
Bitfield32 (unpacked) Unpacked data structure with a sequence of 32-bits. Allows to add a label to every one of the 32 bits.
Byte [<n>] An array of raw values with no defined meaning.
Double64 Double precision floating point values.
Float32 32-bit floating point values.
Int16 16-bit integer.
Int32 32-bit integer.
Int64 64-bit integer.
String[<n>] Array of character values.
Uint16 Unsigned 16-bit integer.
Uint32 Unsigned 32-bit integer.
Uint64 Unsigned 64-bit integer.
  1. Configure the byte order parameters.
  • To use Big Endian turn on the Big Endian switch. The default is Little Endian.
  • To reverse the byte order, turn on the Reverse Byte order switch. The default is normal order.
  1. Configure the Register size.
  • Register sizes are expressed in number of words. Words are 2 bytes, or 16 bits long. The register will start at the address specified, and will have the size set by this parameter.
  • Please note that the size must be multiple of the data type selected. For example, for Double64, the minimum size is 4 and any size set must be a multiple of 4. For Int32 the minimum size is 2, and any size set must be a multiple fo 2. For Bitfield16, the minimum size is 1, and the size is any multiple of 1.
  1. Configure the Connection Parameters.

The following connection parameters can be configured.

  1. Retry Attempts. Number of times the master will retry to poll the register when there are errors.
  1. Response Timeout. Time interval in microseconds to wait for the response from a Modbus slave.
  1. Byte Timeout. Time interval in microseconds to wait for a byte from a Modbus slave.

The resulting configuration will be similar to the one shown below:

Multi register config
  1. Click Add Registers to create the registers.

  2. Confirm that the registers were created successfully in the Registers tab.. In the example below, there was one existing register called Temperature, and we added 8 registers starting with address 2. Registers Temp2 through Temp9 were correctly added.

Multi register list
  1. Save to save your Project, or

  2. Save and Restart to Save your configuration and Run your Modbus Project. If the Modbus Project was previously configured and running, it will be stopped and restarted with the new configuration.

  3. Configure the IoT cloud communications parameters by creating or configuring a Message Router project.

Back to Top

Importing Slave/Group Registers

You can import register configurations from a Tab Delimited Text file.

WARNING!

Any existing registers will be deleted and replaced by the imported registers.

To preserve existing registers, Export them as a CSV file and add the exported data to the file to be imported.

The file must conform to the following data structure and must have a header row whose values are ignored, where <tab> is the tab character.

	Register Label<tab>Register Address<tab>Object Type<tab>Data Type<tab>Enable Big Endian<tab>Reverse Byte Order<tab>Register Size<tab>Number of Retries<tab>Response Timeout<tab>Byte Timeout

Only tab “\tab” separators are supported, and there can only be one tab between each field. The import function is used for multiple modules and some of the connector variables support support value strings with commas; therefore, only Tab Delimited Text files are supported.

Note that any existing registers in the Group / Slave selected for the import will be replaced by the imported registers.

To import a register configuration file:

  1. Open the Registers tab.
Register Tab
  1. Click on the [ Import ] button to open the Import Registers tab.

  2. Read the Instructions and click on the [ Upload file ] button.

  3. Select a valid Tab Delimited Text file and complete the upload.

Select Tab Delimited Text file

The text file has the tab delimited data shown below, and it was created with a standard text editor.

Text file content
  1. Verify that the registers were imported correctly by opening the Registers tab.
Register Tab
  1. Configure the IoT cloud communications parameters by creating or configuring a Message Router project.

Back to Top

Exporting Slave/Group Registers

You can export register configurations in a Tab Delimited Text file.

The file will conform to the following data structure and will have a header row, where <tab> is the tab character.

	Register Label<tab>Register Address<tab>Object Type<tab>Data Type<tab>Enable Big Endian<tab>Reverse Byte Order<tab>Register Size<tab>Number of Retries<tab>Response Timeout<tab>Byte Timeout

Only tab “\tab” separators are supported, and there will only be one tab between each field.

To export a register configuration file:

  1. Open the Registers tab.
Register Tab
  1. Click on the [ Export ] button to open the Export Registers tab.

  2. Read the Instructions and click on the ( Download file ) button.

  3. Enter a name for the Tab Delimited Text file, or use the default and Click OK to initiate the download.

Select Tab Delimited Text file

The text file has the tab delimited data shown below. It was open with a standard text editor.

Text file content

Back to Top

Still need help? Get in touch!
Last updated on 6th May 2021