Button scripting

New to Ignition and still struggling with my first project.
I have three states (tags) that I need to control. Manual, Off, and Auto states (A rocker switch operation). Only one state should be active at a time; when neither Manual nor Auto is selected, off should be automatically active. How can I implement this?
image

Hello Roy and welcome.

I have a few suggestions to make your stay here enjoyable for everyone:

1. go through inductive university

This will teach you the basics: How things relate, what components you can use to do one thing or another, etc.
Those basics are ESSENTIAL to understand ignition, and should cover most of your initial questions. Don't even try building projects before you have a basic grasp on how things work, it will only lead to frustration.

2. Make your questions as accurate as possible

In this case it seems pretty clear you want a multi-state button, but we can't help you with how to set it up if we don't know if you're using vision or perspective.
When creating a new thread here, you have the possibility to tag your post with one of those modules. You can also do afterward by editing. I suggest you ALWAYS tag your posts with the relevant information, it will make things easier for everyone.

3. Ignition's doc is GREAT

Assuming you're using perspective, here's the page for the multi state button:
https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Multi-State+Button

It will tell you how to use it and should be enough for most use cases.

4. We like to help but we're not support

If after that you're still stuck on something, we'll gladly do our best to help you find a solution to your problem, granted you keep in mind it's not our job, which is why the 3 points above are important.

5 Likes

Is this Perspective or Vision?

And, I assume that you have an integer "mode" tag and 3 command tags that you set to high to change the mode?

(only somewhat relevant to this post.. But I hear @pturmel 's voice in my head badgering me about those 3 command tags being set by scada and reset by plc. But Phil, how would you set these up so that scada and plc aren't writing to the same tags?
Actually, I think I finally understand where you're coming from regarding it's inherent race condition. If scada sets it and the write goes through at the exact moment that the rung that resets the tag is run, the command will never action anything. Is this the condition you are trying to avoid?)

The most reliable way to do this is to use one tag, not two separate booleans. A short integer that takes the values 0, 1 or 2, perhaps. The PLC would take the two low bits and use opposite contacts to synthesize two booleans that can't be on together. Something like (AB mnemonics):

XIC ModeSINT.0 XIO ModeSINT.1 OTE AutoMode
XIC ModeSINT.1 XIO ModeSINT.0 OTE ManualMode

The PLC never "corrects" the SINT, except perhaps to reset to zero on startup or similar.

In Ignition, the button simply writes the integer for the desired state. One write => no races.

2 Likes

What about if the plc needs to evaluate if it it's in the right state to accept the change? In this case wouldn't the sint bits be left in the wrong states that didn't reflect the mode it's in? Then once the conditions are met in the plc to change mode, it would action it then, but that could be hours later and then be an outdated request. Somehow the sint bits would need to be changed back

1 Like

You simply include such conditions in the generation of the mode booleans. And, when necessary, generate an alarm that the requested mode was refused. Treat the SINT as if represents a physical three-position switch on a control panel. A PLC generally cannot move such a switch, but it can ignore it when necessary, and report that it has ignored it.

(Or Ignition can notice on its own that it was ignored.)

2 Likes