# Write bit to Word using mark

**URL:** <https://forum.inductiveautomation.com/t/write-bit-to-word-using-mark/3669>\
**Category:** Ignition\
**Created:** [November 30, 2011, 3:07pm UTC](https://forum.inductiveautomation.com/t/write-bit-to-word-using-mark/3669 "2011-11-30T15:07:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bach](https://avatars.discourse-cdn.com/v4/letter/b/c89c15/32.png) [@bach](https://forum.inductiveautomation.com/u/bach)\
**Post date:** [November 30, 2011, 3:07pm UTC](https://forum.inductiveautomation.com/t/write-bit-to-word-using-mark/3669/1 "2011-11-30T15:07:44Z")

</div>

Dear everyone  
May you show me how to write a bit with mask to word?.  
You can write for me “start without closing GCB” for an instance with mask: 2000h.  
You can see in the attached file in the red circle.  
Please attache the image.  
Thank you very much  
Best regards,  
Bach

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/1X/96683c2b1a257f0f459f25b7c4a3ed1879363ae9.JPG)

---

<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:** [November 30, 2011, 3:14pm UTC](https://forum.inductiveautomation.com/t/write-bit-to-word-using-mark/3669/2 "2011-11-30T15:14:58Z")

</div>

You just need to convert the mask from hex to binary and see which individual bit number it is masking - then you can address just that bit as a SQLTag and write to it.

8000h == 0x8000 == 0b1000000000000000 == bit 15

---

<div class="post-metadata">

**Author:** ![bach](https://avatars.discourse-cdn.com/v4/letter/b/c89c15/32.png) [@bach](https://forum.inductiveautomation.com/u/bach)\
**Post date:** [December 1, 2011, 1:59am UTC](https://forum.inductiveautomation.com/t/write-bit-to-word-using-mark/3669/3 "2011-12-01T01:59:33Z")

</div>

Hi Travis,  
I tried but it dont operate.  
I am not good at coding. So I dont know what is this error  
I need your help  
Best regards,  
Bach

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/1X/3c23548781565847c137b8b2daff8e5b53a1cb73.JPG)

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [December 1, 2011, 4:23pm UTC](https://forum.inductiveautomation.com/t/write-bit-to-word-using-mark/3669/4 "2011-12-01T16:23:59Z")

</div>

Can you post your code?

---

<div class="post-metadata">

**Author:** ![jay](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@jay](https://forum.inductiveautomation.com/u/jay)\
**Post date:** [December 2, 2011, 8:11am UTC](https://forum.inductiveautomation.com/t/write-bit-to-word-using-mark/3669/5 "2011-12-02T08:11:55Z")

</div>

Kevin says:

You just need to convert the mask from hex to binary and see which individual bit number it is masking - then you can address just that bit as a SQLTag and write to it.

Jay says:

I’ll bet dollars to donuts that the Woodward Governor 3400/3500 Marine Genset doesn’t support Modbus bit-masked writes.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [December 2, 2011, 4:19pm UTC](https://forum.inductiveautomation.com/t/write-bit-to-word-using-mark/3669/6 "2011-12-02T16:19:07Z")

</div>

I talked to bach on the phone. The main problem was using Modbus address templating. You cannot use system.opc.readValue on a templated address so we had to convert all SQLTags to use regular Modbus address.

Secondly, the word he highlighted above was read-only but we could write to other words. Once all of that was figured out it was easy to figure out which bit based on the mask.
