# MODBUS writing problems

**URL:** <https://forum.inductiveautomation.com/t/modbus-writing-problems/77366>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [August 3, 2023, 1:50pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366 "2023-08-03T13:50:49Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Malachi\_Henry](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Malachi\_Henry](https://forum.inductiveautomation.com/u/Malachi_Henry)\
**Post date:** [August 3, 2023, 1:50pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/1 "2023-08-03T13:50:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 3, 2023, 1:53pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/2 "2023-08-03T13:53:15Z")

</div>

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

{ Not enough information to point blame yet. }

---

<div class="post-metadata">

**Author:** ![Malachi\_Henry](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Malachi\_Henry](https://forum.inductiveautomation.com/u/Malachi_Henry)\
**Post date:** [August 3, 2023, 2:09pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/3 "2023-08-03T14:09:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Malachi\_Henry](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Malachi\_Henry](https://forum.inductiveautomation.com/u/Malachi_Henry)\
**Post date:** [August 3, 2023, 2:11pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/4 "2023-08-03T14:11:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 3, 2023, 2:12pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/5 "2023-08-03T14:12:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Malachi\_Henry](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Malachi\_Henry](https://forum.inductiveautomation.com/u/Malachi_Henry)\
**Post date:** [August 3, 2023, 2:14pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/6 "2023-08-03T14:14:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 3, 2023, 2:14pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/7 "2023-08-03T14:14:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Malachi\_Henry](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Malachi\_Henry](https://forum.inductiveautomation.com/u/Malachi_Henry)\
**Post date:** [August 3, 2023, 2:16pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/8 "2023-08-03T14:16:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 3, 2023, 2:16pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/9 "2023-08-03T14:16:34Z")

</div>

> [@Malachi\_Henry](#):
>
> as that's a holding register. It still tells me it's bad though.

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.)

---

<div class="post-metadata">

**Author:** ![Malachi\_Henry](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Malachi\_Henry](https://forum.inductiveautomation.com/u/Malachi_Henry)\
**Post date:** [August 3, 2023, 2:18pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/10 "2023-08-03T14:18:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 3, 2023, 2:19pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/11 "2023-08-03T14:19:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Malachi\_Henry](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Malachi\_Henry](https://forum.inductiveautomation.com/u/Malachi_Henry)\
**Post date:** [August 3, 2023, 2:26pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/12 "2023-08-03T14:26:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 3, 2023, 2:33pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/13 "2023-08-03T14:33:09Z")

</div>

Not in the Designer.

From scripting, Python supports binary and hex literals:

```auto
>>> 0xCAFE
51966
>>> 0b0101
5
>>> 

```

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.

---

<div class="post-metadata">

**Author:** ![Malachi\_Henry](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Malachi\_Henry](https://forum.inductiveautomation.com/u/Malachi_Henry)\
**Post date:** [August 3, 2023, 2:35pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/14 "2023-08-03T14:35:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Magnus\_Henriksen](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@Magnus\_Henriksen](https://forum.inductiveautomation.com/u/Magnus_Henriksen)\
**Post date:** [February 26, 2026, 2:36pm UTC](https://forum.inductiveautomation.com/t/modbus-writing-problems/77366/15 "2026-02-26T14:36:05Z")

</div>

Got the same error, came here via google, and wouldn’t you know, it’s because we’re writing to bit fields. Thanks!
