ReferenceDriverModbusRead Task

Modbus read task

Learn how to acquire data from Modbus TCP devices with Synnax.

This task follows the standard task lifecycle.

Task configuration reference

Table

Parameter Type Required Default Description
device string Yes - Key of the Modbus server device
sample_rate number No 10 Samples per second (Hz)
stream_rate number No 5 Rate data is streamed to Synnax (Hz), must be ≤ sample_rate
channels array Yes - List of input channel configurations

Register types reference

Holding Register Input (holding_register)

Reads from 16-bit read/write registers (Function Code 03). Typically used for configuration parameters and analog outputs that can also be read back.

Table

Parameter Type Required Default Description
channel number Yes - Synnax channel key
address number Yes - Modbus register address (0-65535)
data_type string No uint8 Data type: int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64, string
bytes_swapped boolean No false Swap byte order within 16-bit words
words_swapped boolean No false Swap word order for 32-bit+ values
string_length number No 0 Register count to read as a string. 0 reads a number

Data Type Sizes:

  • int8/uint8/int16/uint16: 1 register (2 bytes)
  • int32/uint32/float32: 2 registers (4 bytes)
  • int64/uint64/float64: 4 registers (8 bytes)

Input Register (input_register)

Reads from 16-bit read-only registers (Function Code 04). Typically used for analog sensor values like temperature, pressure, or flow.

Table

Parameter Type Required Default Description
channel number Yes - Synnax channel key
address number Yes - Modbus register address (0-65535)
data_type string No uint8 Data type: int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64, string
bytes_swapped boolean No false Swap byte order within 16-bit words
words_swapped boolean No false Swap word order for 32-bit+ values
string_length number No 0 Register count to read as a string. 0 reads a number

Data Type Sizes:

  • int8/uint8/int16/uint16: 1 register (2 bytes)
  • int32/uint32/float32: 2 registers (4 bytes)
  • int64/uint64/float64: 4 registers (8 bytes)

Coil Input (coil)

Reads from 1-bit read/write coils (Function Code 01). Typically used for discrete output states that can be read back (e.g., relay states, valve positions).

Table

Parameter Type Required Default Description
channel number Yes - Synnax channel key
address number Yes - Modbus coil address (0-65535)

Data Type: Always boolean (0/1)

Discrete Input (discrete_input)

Reads from 1-bit read-only discrete inputs (Function Code 02). Typically used for binary sensor inputs (e.g., limit switches, proximity sensors).

Table

Parameter Type Required Default Description
channel number Yes - Synnax channel key
address number Yes - Modbus discrete input address (0-65535)

Data Type: Always boolean (0/1)

Important rules

  • Software timing -> Samples are timestamped in software with ~100 µs precision, which degrades under heavy load.
  • Byte/word order -> Swap settings must match the server for multi-register data types.
  • Stream rate -> For sample rates under 50 Hz, set the stream rate equal to the sample rate. Above that, keep the stream rate under 50 Hz.

How-to