# Modbus Boolean Register - Bit Read Expression Binding to String

**URL:** <https://forum.inductiveautomation.com/t/modbus-boolean-register-bit-read-expression-binding-to-string/96259>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 20, 2024, 8:50pm UTC](https://forum.inductiveautomation.com/t/modbus-boolean-register-bit-read-expression-binding-to-string/96259 "2024-09-20T20:50:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [September 20, 2024, 8:50pm UTC](https://forum.inductiveautomation.com/t/modbus-boolean-register-bit-read-expression-binding-to-string/96259/1 "2024-09-20T20:50:45Z")

</div>

I am trying to read a Modbus Boolean register that has multiple bits under the register with alarm points of a devices. I am trying to figure our a way to script a Text Area Persepctive component to read a register and add an IF statement to display a string of text based of if any bit is true. Any suggestions on how to accomplish this? Here is the register map, I would like to read register 9 and any bits 0-15 read true, display the string/text based on the last right column. I currently am connected to this device via UDT and here is my verification of an active alarm "ns=1;s=[{deviceName}]{unitId}.HR10.5" (Bit 5 is active and = TRUE).

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/4/74f5cd354ebdc471b2d82cd37fe6ebb21d5409ce.png)

I have also given the following Expression Binding a try, I am 100% sure bit 5 is TRUE, but this expression returns "No Alarms Present":  
coalesce(  
if (getBit({[Sample\_Tags]STM Facility/RSF/RSF1-UPS23-DC/PowerMod-Bkr-Alarms},4), "Power Module is Disabled", None),  
if (getBit({[Sample\_Tags]STM Facility/RSF/RSF1-UPS23-DC/PowerMod-Bkr-Alarms},5), "Power Module Lifetime Error: Close to End",None),  
"No Alarms Present"  
)

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [September 20, 2024, 8:52pm UTC](https://forum.inductiveautomation.com/t/modbus-boolean-register-bit-read-expression-binding-to-string/96259/2 "2024-09-20T20:52:47Z")

</div>

Oh, I forgot one IMPORTANT comment, I don't want to create 16-Qty Modbus UDT's for register 9.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [September 20, 2024, 11:26pm UTC](https://forum.inductiveautomation.com/t/modbus-boolean-register-bit-read-expression-binding-to-string/96259/3 "2024-09-20T23:26:49Z")

</div>

Tip: post your code as preformatted text with the `</>` button.

Is it possible to have more than one of those alarms active at a time, and if so how would you want to handle that?

I am not clear on exactly how your tags are setup but my first thought as to read that register as a Boolean array, then create a string array memory tag and put your descriptions in the corresponding elements. I played around with this for a few min and to handle the idea of multiple alarms i settled on using the markdown component instead of a label, with this expression binding.

```python
concat('<html>',
if({[default]wordTag[0]},{[default]desc[0]} + '<br>', ''),
if({[default]wordTag[1]},{[default]desc[1]} + '<br>', ''),
if({[default]wordTag[2]},{[default]desc[2]} + '<br>', ''),
if({[default]wordTag[3]},{[default]desc[3]} + '<br>', ''),
if({[default]wordTag[4]},{[default]desc[4]} + '<br>', ''))

```

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [September 23, 2024, 2:18pm UTC](https://forum.inductiveautomation.com/t/modbus-boolean-register-bit-read-expression-binding-to-string/96259/4 "2024-09-23T14:18:01Z")

</div>

Yes, it is possible to have more than one active alarm present withing that boolean. My first step was to get the alarm text to populate with my one current alarm, then work on generating a list of some sort that would populate one after the other......but how to do that is another piece to this post.

I will give the Boolean array a try today.

---

<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:** [September 23, 2024, 3:09pm UTC](https://forum.inductiveautomation.com/t/modbus-boolean-register-bit-read-expression-binding-to-string/96259/5 "2024-09-23T15:09:23Z")

</div>

Consider just adding bit condition alarms to the single integer tag.

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [September 23, 2024, 8:27pm UTC](https://forum.inductiveautomation.com/t/modbus-boolean-register-bit-read-expression-binding-to-string/96259/6 "2024-09-23T20:27:05Z")

</div>

> [@pturmel](#):
>
> bit condition alarms to the single integer tag

Can this be accomplished with a UDT to the "Alarms" category? I found an article on how to do that...This what you were thinking @pturmel?

> [@Tag Type Boolean Array to set up Alarm Bit State. Am I doing it right?](https://forum.inductiveautomation.com/t/tag-type-boolean-array-to-set-up-alarm-bit-state-am-i-doing-it-right/73998):
>
> Hi there, I am trying to set up alarms on each individual bit using the BIT State condition on a BOOLEAN Array tag (in PLC it is DINT). When my bit 3 is high, I don't see the alarm Is Active? See images below. It might be a silly mistake I am doing but can't really make sense of it. Maybe use DINT Array? Looks like it is not looking at the bit state in the array but the whole DINT itself. [image] Thanks!

---

<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:** [September 23, 2024, 9:01pm UTC](https://forum.inductiveautomation.com/t/modbus-boolean-register-bit-read-expression-binding-to-string/96259/7 "2024-09-23T21:01:15Z")

</div>

Not required to be a UDT, but not forbidden. You would simply define per-bit alarms on the integer tag or UDT member. (Not an array.)
