ReferenceDevice driversModbusWrite task

Modbus write task

Learn how to send commands to Modbus TCP devices with Synnax.

This task follows the standard task lifecycle.

Task configuration reference

Parameter Type Required Default Description
device string - Key of the Modbus server device
channels array - List of output channel configurations

Register types reference

Holding register output (holding_register)

Writes to 16-bit read/write registers (Function Code 06/16). Typically used for setpoints, control values, and configuration parameters.

Parameter Type Required Default Description
channel number - Synnax command channel key
address number - Modbus register address (0-65535)
data_type enum uint8 Data type: int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64
bytes_swapped boolean false Swap byte order within 16-bit words
words_swapped boolean false Swap word order for 32-bit+ values

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 output (coil)

Writes to 1-bit read/write coils (Function Code 05/15). Typically used for binary control signals like relay states and valve positions.

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

Data type: Always boolean (0/1)

Important rules

  • Byte/word order -> Ensure swap settings match your server configuration for multi-register data types.
  • Read-only registers -> Input registers and discrete inputs cannot be written to.

How-to

When you create channels with a client library, give each command channel its own index channel. A writer that holds several commands on one index must write all of them in every frame.