[Modbus TCP] trouble writing to single bit of a holding register

Ignition 8.1.1

I’m facing issues with boolean writes on Holding Registers.
The modbus server is a siemens PLC [s71xxxxpn] defined in Ignition as Modbus TCP device .

Writing to the entire HR seems to work fine:

Integer OPC tag : ns=1;s=[s71xxxxpn]HR160 (corresponding to MW160 in the PLC DB)
- read ok 
- write ok

but I can’t write to any bit of the modbus word

Boolean OPC tag : ns=1;s=[s71xxxxpn]HR160.1 
- read ok 
- write not working -> MaskWriteRegisterRequest - Received response with ExceptionCode: 0x03 (IllegalDataValue)

Here are the >logs<, and below a wireshark capture.
I’m certainly missing something simple… Is there any workaround to this issue ?

Thanks in advance

Since your device doesn’t support the MaskWriteRegister function you’ll have to read, mask, then write the new whole register value via scripting.

An old post describing the scripting approach: Modbus UA

A newer post that uses Derived Tags: Troubles making a Derived Boolean Tag work as a mask for a Short Tag

The derived tag approach can be prone to issues when writing multiple bits at once. It requires that Optimistic Writes be enabled for the Tag Group the OPC tags reside in and there was a race condition we just fixed landing in 8.1.2.

edit: it is strange that the exception code is IllegalDataValue instead of IllegalFunction… can’t see if anything is weird because you didn’t upload the capture or show the request in your screenshot.

1 Like

The derived tag approach worked, thanks !
I’ll keep the scripting approach in mind when I will need mutliple writes at once

Regarding “IllegalDataValue”, attached is a capture file while writing bits to two modbus servers:

  • device 1 ( | One-based | linux modbus simulator): bit HR1.1 is toggled properly
  • device 2 ( | One-based | siemens PLC): bit HR160.1 writing would not work

compare-2-devices_modbus.rar (8.9 KB)

Glad you got it working. As of 8.1.2 you don’t need to worry about writing multiple at once either. Make sure you’ve enabled Optimistic Writes for the tag group the source and derived tags belong to.

1 Like