Derived tag, multiple bit to modbus tag

Hi all,

Need some advice on how to solve this. We use derived tags to set and reset bits in a modbus int, command word. This works as long as we do bit by bit. But… I got some buttons that is intended to alter 3 bits at once. It seems that we run into some timing issues, as only the last instruction is done.

I have tried both system.tag.write and system.tag.writeAll on my 3 derived tags.

Button 1
Set bit 10
Res bit 11
Res bit 12

Button 2
Res bit 10
Set bit 11
Res bit 12

Button 3
Res bit 10
Res bit 11
Set bit 12

Example derived tag:

Read expression:

Write expression:
toInt({source}) | (1 << 12),
toInt({source}) & ~(1 << 12))

IGN 8.0.9

Thanks in advance.

Enable the “Optimistic Writes” option for the tag group these tags belong to.

Hi Kevin,

We tried this with no luck.

Hi Kevin,

Restored the gateway on our test server and connected to a PLC on my desk.

Enabling optimistic write does nothing, first when we change optimistic write timeout from 0 to 3000 we see a difference. It works better, meaning two or more bit is not high at the same time - but the first press will most times only disable bits. It will require a second or more click to enable the bit we would like to set.

3 buttons, 3 bits that needs to be altered. All of them belong in a UDT. Tried to add derived tags without a UDT but still the same.

Script, event:

system.tag.write("[TKV_TagProvider]D52_HFS_Kjoling/HFS/OBJ/Kommando/Pri P2",False)
system.tag.write("[TKV_TagProvider]D52_HFS_Kjoling/HFS/OBJ/Kommando/Pri Alt",False)
system.tag.write("[TKV_TagProvider]D52_HFS_Kjoling/HFS/OBJ/Kommando/Pri P1",True)

Also tried writeAll, still the same.

It works for me when using writeBlocking:

tags = [

values = [1,1,1,1]

system.tag.writeBlocking(tags, values)


system.tag.writeBlocking(["[default]IntBits_Instance/Bit0"], [1])
system.tag.writeBlocking(["[default]IntBits_Instance/Bit1"], [1])
system.tag.writeBlocking(["[default]IntBits_Instance/Bit2"], [1])
system.tag.writeBlocking(["[default]IntBits_Instance/Bit3"], [1])

It didn’t work with individual async writes, though, and I’m not sure if that’s correct behavior or not. I’ll have to open a ticket and get someone to look into it this week.

Hi Kevin, thanks for writing back.

I tried using writeBlocking now. Its maybe a bit improved. I had to swap about 8-9 times before it failed again. My command word is set to zero.

Looking forward to what the ticket brings. Have a nice day.

Hi Kevin,

Do you have any news for us? :slightly_smiling_face:

Sorry, this fell off my radar. I just wrote up a ticket so it won’t get forgotten.

1 Like