Skip to content

Modbus RTU protocol

Modbus RS485 (also commonly called Modbus RTU) is a widely used serial communication protocol in industrial settings, especially for interfacing with meters, inverters, energy counters, and other automation devices. The RS485 bus allows multiple devices (up to 32) to be connected on a single serial line, using a daisy-chain connection capable of covering long distances. It allows reading and writing variables (registers) on connected devices.

The AL300 Gateway can act as a Modbus master, querying slave devices connected to the RS485 bus.

Physical connection

AL300 has two independent RS485 ports, allowing it to behave as a Modbus master and query Modbus slave devices.

RS485

Port 1:

  • A1
  • B1
  • GND

Port 2:

  • A2
  • B2
  • GND

Configuration

  1. Choose the data source Generic Modbus RTU

    Pick

  2. Select the serial port to use (1 or 2) and the id of the Modbus slave to query. To modify the serial port parameters (Baudrate, parity, stop bits) see here. 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)
    • 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.