3. RTU Master Configuration

Modbus RTU Master Overview

This guide describes how to configure and use an Edge One™ Modbus Remote Terminal Unit (RTU) Master. Modbus RTU is one of the more popular modes of using Modbus. It is an open, serial (RS-232 or RS-485) protocol derived from the Master/Slave architecture. It is a broadly accepted protocol due to its ease of use and reliability. There are a large number of Modbus RTU serial devices from diverse vendors for all kinds of applications. The protocol is widely used within Building Management Systems (BMS) and Industrial Automation Systems (IAS) applications.

Modbus RTU messages are a simple 16-bit CRC (Cyclic-Redundant Checksum). The simplicity of these messages is to ensure reliability. Due to this simplicity, the basic 16-bit Modbus RTU register structure can be used to pack in floating point, tables, ASCII text, queues, and other unrelated data.

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

  1. Requirements for installation of Modbus RTU.
  2. Configuring a Modbus RTU Master indicates the initial steps for configuring the RTU Master.
  3. Configuring the RTU Slaves describes how to add and configure RTU slaves also called groups.
  4. Configuring registers indicates how to configure the slave registers of a slave of group.
  5. Configuring a single register indicates on how to add and configure a single register.
  6. Editing a register describes how to edit a single register.
  7. Deleting a register shows how to delete a register.
  8. Adding multiple registers provides instructions on how to add and configure multiple registers with a single command.
  9. Importing registers describes how to import registers from a Tab Delimited Text file.
  10. 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.

Back to Top

Requirements

The following are the requirements to use Modbus RTU 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. Local RS-232 or RS-485 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 requires that you know or define:
    • The slave ID (aka slave address, unit number, unit ID).
    • The baud rate.
    • The data format (data bits, parity, and stop bits).
  5. Configuration of a Message Router project and route to send the Modbus data to CloudPlugs IoT, a supported public IoT cloud service or to a local MQTT server.

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

Back to Top

Configuring a Modbus RTU 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. Manual settings
  • 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 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 Serial tab and set the serial communications parameters.
Master
  1. In the Serial tab:

    • Select an available serial port, or enter a custom port. The list of available ports can be refreshed by clicking the refresh ( ) icon. If a Custom serial port is selected, make sure that it is available for the application to use.

    • 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.
      3. 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.
      4. Stop Bits. In serial communications, stop bits are used to signal the end of a frame. Supported values are 1 or 2.
      5. RTS. Request to Send (RTS) signals are used for flow control.
        • RTS High means that bytes are available for transmission. For example, RTS is used in RS-232 to RS-485 converters. RS-485 is a multiple-access bus on which only one device can transmit at a time, a concept that is not provided for in RS-232. The RS-232 device asserts RTS by setting it to High to tell the converter to take control of the RS-485 bus so that the converter, and thus the RS-232 device, can send data onto the bus.
        • RTS Low is used when a device is ready to receive data.
      6. Serial Mode. Both RS-232 and RS-485 communications are supported.
        • RS-232 is best for short-distance low-speed communication requirements. It is simple and low cost, and plenty of components like line drivers and receivers, UARTs, and connectors are available to build the interface. RS-232 only allows for one transmitter and one receiver on each line. RS-232 uses Simplex or Full-Duplex transmission method. Note: Select RS-232 even when using sensors that are RS-485 enabled since the RS-485 setting is only usable when the devices use a specific RS-485 chipset in their implementation.
        • RS-485 is used for higher speed communications over longer ranges or if duplex networking capability is required. Use this mode only when you are certain that the devices are implemented using a chipset that implements specifically RS-485. Otherwise, set the serial mode to RS-232. RS-485 was made to address the multi-drop limitation of RS-422, allowing up to 32 devices to communicate through the same data line. Any of the slave devices on an RS-485 bus can communicate with any other 32 slave devices without going through a master device.
  2. When finished click Next to continue the configuration and/or Save to save your work. You must only Save & Start when you the project has been completely configured.

  3. You must configure the Master’s Slaves next.

Serial settings

Back to Top

Configuring the RTU Slave(s)

To configure the Modbus slaves:

  1. In the Slaves tab click on Slave.
Add slave
  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, after receiving the first byte, each Slave knows whether or not to ignore the message.

    4. 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.

    5. Set Inter Register Delay. This is the optional pause in milliseconds between the polling of two consecutive registers in this Map.

    6. 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.

    7. 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.

    8. Optionally, turn the Show Stats switch on. This setting enables the display of the results of all the polling attempts on the console log.

Configure map

A slave created can be deleted with the delete button.

  1. Click Next or Save. Next opens the Slaves tab which allows you to edit, delete, and configure registers.
Slave list
  1. Configure registers by clicking on Manage registers on the Slave you just created. The next section describes how to configure one or multiple registers.
Manage 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