Write
Purpose: write values to a device's registers or coils.

Pick Write in the Add Step window:
| Field | What it sets |
|---|---|
| Function | 05 single coil, 06 single register, 15 multiple coils, 16 multiple registers |
| Format | Value format (Unsigned, Signed, Long, Float, Double and byte order) |
| Channel | Which channel to use (A or B) |
| Start address / End address | The range to write. The register count is shown on the right |
| Max response | Response time limit, see Common fields |
| Write value | The value to write. For several registers it is a table, one value per row |
JSON
json
{ "write": { "function": 16, "address": "0x0010", "values": [100, 200, 300] } }| Field | Required | Meaning |
|---|---|---|
address | Yes | Start address, 0–65535. Expression allowed |
end_address | No | End address (inclusive). You can use count instead. If neither is given, the number of values decides; otherwise 1 |
count | No | Number of registers (or coils), 1–123 |
function | No | 5, 6, 15 or 16. If omitted, 06 for one register and 16 for several. 10 is treated as 16 |
format | No | Default unsigned. Other formats are in Concepts › 8. Value formats |
value | One of the two | A single value written to every position in the range. Expression allowed |
values | One of the two | A list of values, one entry each (a float entry takes 2 registers) |
channel | No | "A" (default) or "B" |
max_ms | No | See Common fields |
Result
| Result | When |
|---|---|
| PASS | The device accepts the write |
| FAIL | The device returns an exception code (for example, the address does not exist), or the response is slower than max_ms |
| DISCONNECT | The device does not respond |
A Write PASS only means the device accepted the write, not that the value is right. To check the value, add a Read after it.
Example
| Case | What it does |
|---|---|
| FC06 one register | FC06 writes 0x0000 = 0x1234, then reads it back |
| FC16 several registers | FC16 writes 0x0010..0x0012 = 100, 200, 300, then reads them back |
| FC05 one coil | FC05 turns coil 0x0000 ON, read back with FC01 |
| FC15 several coils | FC15 writes 4 coils 1, 0, 1, 1, read back with FC01 |
| Format and expressions | Writes 12.5 as float_abcd, then uses variable i = 3 to compute the address 0x0030 + ${i} and the value ${i} * 100 |

All five cases PASS. In the last case, the Actual column shows [@0x0033], the address the expression worked out to.
Notes
- Coil values are
0(OFF) or1(ON). - Formats other than Unsigned only work with FC16, or with FC06 for single-register formats (such as Signed). They cannot be used with coils.
- Write cannot store a variable (
storeis not accepted).
Download the sample script
Sample script
Before running it, start a Slave window on 127.0.0.1:502 and click Listen, then open the script with Open JSON in Script mode and click Run. See How to use the examples.
