MODBUS writing problems

Not sure if I'm missing something here, but I have a MODBUS I/O block that I am testing with, and I have no problems reading from it. I have buttons connected and mapped and it works just fine. I connect a light to it and attempt to write to it and I get "Error writing to Light_0.value: Bad". Is this a MODBUS problem on my end, or did I mess something up in Ignition? If it's a me problem let me know, but if it's an Ignition problem I'm kinda stuck.

Can you show your code that performs the write? Address information?

{ Not enough information to point blame yet. }

That's my bad, I should have provided more information. I'm just trying to manually write the boolean value by directly editing the tag from the tag browser.

This is the address that properly reads from the header: [I/O header]IRUS5.0

I have tried multiple address combinations, i.e. changing the designator, changing the actual address of the value, etc. I am an intern at an industrial integration company so I'm simply inexperienced with MODBUS. It could very well be an improper address, I simply don't know.

Eventually I would like to write directly to the tag using system.tag.writeBlocking(), but I can't even manually get the tag value to change. I was getting the "[Bad_NotWritable]: The access level does not allow writing to the Node.” error until I changed the designator, so I don't know if that has something to do with it as well.

Modbus does not allow writes to inputs. Only Holding Registers and Coils.

1 Like

Gotcha. The address I'm currently trying is "[I/O header]HRUS4.2", as that's a holding register. It still tells me it's bad though.

Check the logs in the gateway after writing to that address.

That’s a bit inside a register, it’s common that devices don’t support the Mask Write Register function necessary to write to a bit.

1 Like

Yup. "MaskWriteRegisterRequest Received response with ExceptionCode: 0x01 (IllegalFunction)."

What brand is this? (Hopefully not Schneider--they don't implement the Masked Write function code, which is needed to write to bits of holding registers.)

It's TURCK. Still throwing the previously mentioned mask write register request though. Do I need to try writing hex values? Binary?

You have to assemble a whole 16-bit value containing the bits you want and write to the base register address.

Then hope nobody else or the device logic isn’t also changing bits such that you clobber them.

There’s some scripting and derived tag solutions floating around the forum if you search. I can’t look them up right now, too difficult on mobile.

When manually assigning the tag value in Ignition, is there a way to feed it a binary value without converting to base 10? Can I feed the tag something like 0b'XXXX for base 2 or 0Xxx for base 16? Different languages and programs accept different syntax and I can't find anything for Ignition other than the Jython syntax.

Not in the Designer.

From scripting, Python supports binary and hex literals:

>>> 0xCAFE
>>> 0b0101

If you are building a UI you'll probably have to figure out how to decode the text input value into a base 10 integer before using the value.

Alright, I'll keep messing around with it. Thank you for the help!