ReferenceDriverModbusRead Task

Modbus Read Task

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

For task lifecycle management, see the Task Basics page.

Task Configuration Reference

ParameterTypeRequiredDefaultDescription
namestringYes-Human-readable task name
devicestringYes-Key of the Modbus server device
sample_ratenumberYes-Samples per second (Hz)
stream_ratenumberNosample_rateRate data is streamed to Synnax (Hz), must be ≤ sample_rate
data_savingbooleanNofalseEnable permanent storage in Synnax
auto_startbooleanNofalseAutomatically start task after configuration
channelsarrayYes-List of input channel configurations

Register Types Reference

Holding Register Input (holding_register_input)

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

ParameterTypeRequiredDefaultDescription
channelnumberYes-Synnax channel key
addressnumberYes-Modbus register address (0-65535)
data_typeenumNofloat32Data type: int16, uint16, int32, uint32, float32
swap_bytesbooleanNofalseSwap byte order within 16-bit words
swap_wordsbooleanNofalseSwap word order for 32-bit+ values

Data Type Sizes:

  • int16/uint16: 1 register (2 bytes)
  • int32/uint32/float32: 2 registers (4 bytes)

Input Register (register_input)

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

ParameterTypeRequiredDefaultDescription
channelnumberYes-Synnax channel key
addressnumberYes-Modbus register address (0-65535)
data_typeenumNofloat32Data type: int16, uint16, int32, uint32, float32
swap_bytesbooleanNofalseSwap byte order within 16-bit words
swap_wordsbooleanNofalseSwap word order for 32-bit+ values

Data Type Sizes:

  • int16/uint16: 1 register (2 bytes)
  • int32/uint32/float32: 2 registers (4 bytes)

Coil Input (coil_input)

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

ParameterTypeRequiredDefaultDescription
channelnumberYes-Synnax channel key
addressnumberYes-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).

ParameterTypeRequiredDefaultDescription
channelnumberYes-Synnax channel key
addressnumberYes-Modbus discrete input address (0-65535)

Data Type: Always boolean (0/1)

Important Rules

  • Sample rates: All channels in a task sample at the same rate. Create separate tasks for different rates.
  • Software timing: Modbus tasks use software timing with ~100 μs precision (may degrade under heavy load).
  • One running task per channel: A channel can only receive live data from one task at a time.
  • Stream rate optimization: For low-rate tasks (< 50 Hz), set the stream rate to the sample rate. For high-rate tasks, keep the stream rate less than 50 Hz for better performance.
  • Byte/word order: Ensure swap settings match your server configuration for multi-register data types.

How-To

Console

Python

TypeScript