# How to use Multi State Button when there are two control tags

**URL:** <https://forum.inductiveautomation.com/t/how-to-use-multi-state-button-when-there-are-two-control-tags/68714>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [January 18, 2023, 5:36am UTC](https://forum.inductiveautomation.com/t/how-to-use-multi-state-button-when-there-are-two-control-tags/68714 "2023-01-18T05:36:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lina\_Su](https://avatars.discourse-cdn.com/v4/letter/l/7ba0ec/32.png) [@Lina\_Su](https://forum.inductiveautomation.com/u/Lina_Su)\
**Post date:** [January 18, 2023, 5:36am UTC](https://forum.inductiveautomation.com/t/how-to-use-multi-state-button-when-there-are-two-control-tags/68714/1 "2023-01-18T05:36:49Z")

</div>

I am adding my Omron PLC logic to Ignition. The PLC logic is:  
There are two input IO signals , one is control turn on & and another control turn off  
It will trigger the output IO , to On / Off.

So I have 3 tags load from my PLC  
Tag0.0 = control the turn on  
Tag0.1 = control turn off  
Tag100.1 : Output , indicate the current state.

So when use 3 components in Ignition vision design  
two buttons + 1 multi state indicator , I can realize what I need.  
The first button will set the value of Tag0.0 , and send to PLC, PLC handle the logic, change value of Tag100.1 from 0 to 1  
The Second button will set the value of Tag0.1 , and send to PLC, PLC handle the logic, change value of Tag100.1 from 1 to 0.  
Screen is like below.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/c/0c846d685775b7970321470c8277451e4edef442.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/b/0b7b715c91f8779d824fa85166d566fb7f1637e9.png)

I want use one "Multi State Button" to replace above " two buttons + 1 multi state indicator ", I link Indicator Tag with Tag100.1 , it works fine , can reflect current state properly.  
I have trouble when link "Control value" , it only allow to link with one tag, if I link with Tag0.0, I only can realize then turn on function, I can't control Tag0.1 to switch it off.

I tried to add script on the Multi State Button , set the different tag value based on it's "Indicator value" , seems does not work.

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/0/10d456ba3a4e4a1fb3ad3ad1ae8b9131dcd0f3c8.png)

Can anyone give some advice ?

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [January 18, 2023, 8:41am UTC](https://forum.inductiveautomation.com/t/how-to-use-multi-state-button-when-there-are-two-control-tags/68714/2 "2023-01-18T08:41:29Z")

</div>

Use indirect binding on Control Value, Tag0.0 value as params. It looks like you want to change different tags based on tags value.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [January 18, 2023, 9:02pm UTC](https://forum.inductiveautomation.com/t/how-to-use-multi-state-button-when-there-are-two-control-tags/68714/3 "2023-01-18T21:02:29Z")

</div>

Start by attaching your indicator value to the Tag100.1 tag.

Add a custom string property to the button that is bound to the indicator with an expression. Something like:

```auto
if({[source]Tags/Tag100.1},"Tag0.1","Tag0.0")

```

,but use your tag paths, or whatever you need to to build your indirect tag path.

Then, use that string in your control value binding as an indirect tag path.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fb7c91632cc8f6110b594c7f1e9b295eff2ec90c.png)

Now, as the indicator value changes it will change the tag path that is written to when the button is pressed.

Alternatively, you could just use two buttons and no indirect tag binding.  
1 button to write the value of Tag0.0  
1 button to write the value of Tag0.1

Add a custom property to both buttons, bind this property to Tag100.1, and use the customizer to set the appearance for Tag100.1=0 and Tag100.1=1 for each.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 18, 2023, 10:08pm UTC](https://forum.inductiveautomation.com/t/how-to-use-multi-state-button-when-there-are-two-control-tags/68714/4 "2023-01-18T22:08:14Z")

</div>

To avoid a race condition:

Use two custom properties in the multistate indicator, each bound to Tag0.0 and Tag0.1 and bidirectional. Then use a property change script:

```python
if event.propertyName == 'controlValue':
	event.source.startBit = event.newValue
	event.source.stopBit = not event.newValue

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/e/ce14bac6aa1294ce001376d2009adf1b841fdd00.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/36a992871a52262951c93eb3fb0b277e81c87f59.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/b/db73426d1c255dc68720263748bad98a97ac57db.png)

---

<div class="post-metadata">

**Author:** ![Lina\_Su](https://avatars.discourse-cdn.com/v4/letter/l/7ba0ec/32.png) [@Lina\_Su](https://forum.inductiveautomation.com/u/Lina_Su)\
**Post date:** [January 19, 2023, 1:02am UTC](https://forum.inductiveautomation.com/t/how-to-use-multi-state-button-when-there-are-two-control-tags/68714/5 "2023-01-19T01:02:39Z")

</div>

I tried your solution , have little issues, here is my understanding:  
When Tag100.1 value =0 (means off), control value binding tag = Tag0.0 , when click the button, it will send to 1 to Tag0.0, then PLC execute program and trigger Tag100.1 from 0-\>1 . This is fine.

When Tag100.1 value =1 , control value binding tag = Tag0.1 ,when click the button, it will send to 0 to Tag0.1. This has issue, because PLC always accept 1 for both Tag0.0 & Tag0.1 to trigger Tag100.1.

Please point it out if my understanding is incorrect.

The two buttons solution is what I am using now, I want to simply this using Multi State Button.

---

<div class="post-metadata">

**Author:** ![Lina\_Su](https://avatars.discourse-cdn.com/v4/letter/l/7ba0ec/32.png) [@Lina\_Su](https://forum.inductiveautomation.com/u/Lina_Su)\
**Post date:** [January 19, 2023, 1:41am UTC](https://forum.inductiveautomation.com/t/how-to-use-multi-state-button-when-there-are-two-control-tags/68714/6 "2023-01-19T01:41:58Z")

</div>

It works !  
Thanks, really expend my knowlege.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [January 19, 2023, 2:14pm UTC](https://forum.inductiveautomation.com/t/how-to-use-multi-state-button-when-there-are-two-control-tags/68714/7 "2023-01-19T14:14:14Z")

</div>

I see what you're saying here. I overlooked the fact that the control value would still toggle between 0 and 1, and sending a 0 on either tag does nothing.
