My PLC is setup to accept a momentary command to open a valve, and a different momentary command to close the valve. I want to use a SINGLE button that will momentarily command open IF the valve is closed, and momentarily command close IF the valve is open. There is a single tag that indicates if the valve is presently open or closed.
So…
if tag state is OPEN, then momentarily command closed when pushed
If tag state is CLOSED, momentarily command open when pushed
Is there a way to do this with one of the standard components?
Can be done with scripting, read the state of the valve, if it’s open write to your valve actuator tag a close command value and if its closed do the opposite.
You can also do this with a few custom properties and an expression binding and indirect tag binding.
Custom properties:
on tag - string
off tag - string
stat tag - boolean
ctrlValue - string
Put the tag paths in the on and off custom properties and bind the status to the status tag.
Use an expression binding on ctrValue, update for the naming you used.
if({Root Container.Momentary Button.Stat}, {Root Container.Momentary Button.Off},{Root Container.Momentary Button.On})
Lastly create a bidirectional indirect tag binding on the momentary button’s control value using your custom property ctrlValue.
This is the method I've used in the past, there may be cleaner ways to accomplish it. Also, there’s a lot of information on the forums about the potential problems with using momentary buttons that you may want to check out.
Don’t do this in Ignition. That’s a function for the PLC to handle. Simple code in the PLC instead of hidden and convoluted scripting in Ignition.
Xic button xic valve_open ONS Close Valve OTU button
Xic button xic valve_close ONS Open Valve OTU button
Simply set the button in Ignition to 1
1 Like
Thanks for the response, and the warning. I do see several good posts with warnings about momentary buttons such as this one: Momentary button is latching on bit