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

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

image

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.

Can anyone give some advice ?

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

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:

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.

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.

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:

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

4 Likes

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.

It works !
Thanks, really expend my knowlege.

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.