# Get bit from int Tag , can read and write bit?

**URL:** <https://forum.inductiveautomation.com/t/get-bit-from-int-tag-can-read-and-write-bit/90844>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 24, 2024, 12:55am UTC](https://forum.inductiveautomation.com/t/get-bit-from-int-tag-can-read-and-write-bit/90844 "2024-05-24T00:55:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [May 24, 2024, 12:55am UTC](https://forum.inductiveautomation.com/t/get-bit-from-int-tag-can-read-and-write-bit/90844/1 "2024-05-24T00:55:23Z")

</div>

Modbus TCP:  
I add a int Tag: status.  
Bit 15 can control a valve.  
I add a Expression Tag of getbit 15.

 ![01d597550bfecad575abe77dd1769bc](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/b/8b76a537a86fbbfb8698904e1b3d33b9a1752118.png)

But when I write it , it shows error?

 ![2e3a6a0a2dc46928270372c3141dcb7](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/1/c18ae2f675a440f713e865a09da92e18c381b86c.png)

Expression Tag is just for reading?  
Like this, what kind type tag can I add?  
Let it can read and write bit 15?

---

<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:** [May 24, 2024, 2:27am UTC](https://forum.inductiveautomation.com/t/get-bit-from-int-tag-can-read-and-write-bit/90844/2 "2024-05-24T02:27:43Z")

</div>

Expression tags are read-only.

To write to bits of holding registers, make a boolean tag with an OPC path of the form `[device]HR123.15`. As long as the device supports Modbus function code 22, the boolean will be writable.

If the device doesn't support function 22, you will need to use a **derived** tag, and have the write path merge the changed bit into the target integer, which then writes the whole integer. Racy if anything other than Ignition can change any bits in the integer.

---

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [May 24, 2024, 2:35am UTC](https://forum.inductiveautomation.com/t/get-bit-from-int-tag-can-read-and-write-bit/90844/3 "2024-05-24T02:35:11Z")

</div>

> [@pturmel](#):
>
> To write to bits of holding registers, make a boolean tag with an OPC path of the form `[device]HR123.15`. As long as the device supports Modbus function code 22, the boolean will be writable.
> 
> If the device doesn't support function 22, you will need to use a **derived** tag, and have the write path merge the changed bit into the target integer, which then writes the whole integer. Racy if anything other than Ignition can change any bits in the integer.

Yeah! **Derived** Tag is right!

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/a/9a57f830ef99910a47b26d9ec6fff66657b7b8fc.png)
