0.60

ReferenceHardwareModbusWrite task

Modbus write task

Write command channel values to the coils and holding registers of a Modbus server.

A Modbus write task writes the values of command channels to the coils and holding registers of one Modbus server. For example, a button on a schematic can start a pump through a coil of a PLC. Modbus write tasks have no state channels.

Each command writes every address from the lowest to the highest address of the task. Addresses between your channels get the values that the task read at its first command, until you configure the task again. If that first read fails, they get zeros. Keep the addresses of a write task together, or use one task for each group of addresses.

The Driver writes coils with function code 15 and holding registers with function code 16. A device that supports only function codes 05 and 06 cannot be written. One request can hold at most 123 registers or 1968 coils.

Before you start, you need a connected server.

Create a Modbus write task

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

Enterprise
  1. In the devices toolbar, right-click the server and select Create write task.
  2. Click Add channel. Select Coil or Holding register, then enter the address. For a holding register, select the Data type.
  3. Click (Start).

The Console creates a command channel and an index channel for each output. For the server Pump skid PLC, a coil at address 3 gives Pump_skid_PLC_coil_output_3_cmd and Pump_skid_PLC_coil_output_3_cmd_time. To use a different name, right-click the channel and select Rename before you start the task.

The task has the options Data saving and Auto start. See task options. Python WriteTask has no data_saving_disabled argument.

Channel reference

Each channel has an address, from 0 to 65535, and a channel, the command channel. Each table shows the Console label of a setting, with its Python field under it.

Coil

Python CoilWriteChannelTypeScript coil

Writes a coil. A command of 0 turns the coil off. Any other value turns it on.

Troubleshooting

A command changed a register that the task does not use

The register is between two addresses of the task. See the warning at the top of this page.

“Illegal function”

The device does not support function code 15 or 16. The Driver cannot write to it.

“Too many data”

The addresses of the task span more than one request can hold. Move the channels closer together, or split them into two tasks.

The task stopped when the connection dropped

The task stops on any connection error. Start the task again when the server is back.

For other problems, see Connect a Modbus server and Troubleshoot hardware.