Skip to content

Modbus TCP protocol

Modbus TCP is a variant of the Modbus protocol that uses the TCP/IP network (usually ethernet) for communication between devices. It is widely used in industrial settings for interfacing with meters, inverters, energy counters with RJ45 port. It allows reading and writing variables (registers) on connected devices.

The AL300 Gateway can act as a Modbus TCP master, querying slave devices connected to the Ethernet network.

Configuration

  1. Choose the data source Generic Modbus TCP

    Pick

  2. Enter the IP address of the modbus slave. You can test the network connection by pinging the device (using the Ping button) and verify that the modbus slave is up and running (TCP port open) using the TCP connect button. To proceed, you need to have the documentation (register table) provided by the Modbus slave manufacturer.

    Connection

  3. Choose whether to use register (1-based) or address (0-based) numbering and set the byte order and, if necessary, word order (in the documentation they are indicated as big endian/little endian or LSB (least significant byte)/MSB (most significant byte)). Endianness

  4. Click on Add variable. To import or modify the table massively, see bulk configuration. For each variable of interest, you can set:

    • Name and metadata (see here for more details)
    • Topic. It can be:
      • Info: connection information (device disconnected variable and read error variable)
      • Holding registers: modbus functions 3 (read) and 6/16 (write)
      • Input registers: modbus function 4 (read)
      • Coils: modbus functions 1 (read) and 5/15 (write)
      • Discrete inputs: modbus function 2 (read)
    • Slave ID: identifier of the modbus slave to query. It is often ignored by TCP slaves, but in some cases (e.g. modbus TCP/Rs485 converters) it must be set correctly.
    • Address/Register: It can be expressed in decimal or hexadecimal and can be indicated as address (0-based) or register (1-based) depending on the Addressing setting above the table. For each register, you need to set the correct encoding (data type). The available data types are:
      • 8bit_uint: unsigned integer of 8 bits
      • 16bit_uint: unsigned integer of 16 bits
      • 32bit_uint: unsigned integer of 32 bits
      • 64bit_uint: unsigned integer of 64 bits
      • 8bit_int: signed integer of 8 bits
      • 16bit_int: signed integer of 16 bits
      • 32bit_int: signed integer of 32 bits
      • 64bit_int: signed integer of 64 bits
      • 8bit_bsint: signed integer of 8 bits, most significant bit indicates the sign (0=positive, 1=negative)
      • 16bit_bsint: signed integer of 16 bits, most significant bit indicates the sign (0=positive, 1=negative)
      • 32bit_bsint: signed integer of 32 bits, most significant bit indicates the sign (0=positive, 1=negative)
      • 64bit_bsint: signed integer of 64 bits, most significant bit indicates the sign (0=positive, 1=negative)
      • 16bit_float: floating point number of 16 bits (half-precision)
      • 32bit_float: floating point number of 32 bits (single-precision)
      • 64bit_float: floating point number of 64 bits (double-precision)
      • string: string of ASCII characters (you need to specify the length in characters)
      • bits: array of bits (you need to specify the index from 0 to 15 of the bit within the register)
    • Scale (see here for more details)
    • Save to (see here for more details)

    Variable

  5. Perform a read test of the variable just created by clicking on the Read button in the action column. If the reading is successful, the value read will be shown in the column.

    Test read

  6. Repeat steps 4 and 5 for all variables of interest, then click on Next to go to the Metadata tab.

  7. Here you can give a name and an optional description to the data source. You can also indicate where to insert the data source within the device hierarchy. In this way, you can organize devices into logical groups (e.g. departments, production lines, buildings, etc).

    Metadata

  8. Click on Save. Once the window is closed:

    • if you are using the local web interface, the changes have been successfully applied
    • if you are operating through the cloud, the configuration has been saved and placed in a sending queue. Until the configuration is applied, a ⚠ yellow triangle will be shown at the top of the AL300 configuration page.
      • if the AL300 is online, it is sent immediately to the AL300.
      • if the AL300 is offline, it will be sent when the connection is re-established.