Showing results for 
Search instead for 
Did you mean: 

Button/switch as control AND indicator

Go to solution



I'm nowhere near completing this VI, but here's eventually what will happen: There are 6 valves connected by pneumatic logic controllers. In my VI, there are buttons that will control sets of valves (for example, a button might set valves 1, 3, 4 ON and 2, 5, 6 OFF), but I also want to be able to switch the valves individually. Currenty, I have it set up so the valve controls are slide switches (Switch when pressed, & colored differently for ON and OFF) and the buttons to control sets of valves are text buttons (Latch when pressed). There is also an OFF button that stops the whole VI (it is all within a while loop controlled by this button).


Anyways, the main issue that I am trying to address is: I would like the slide switches to switch when the text buttons are pressed. However, as I understand it, this would force these slide switches to be both a control AND and indicator. Is there a way to do this?


[Also, I'm having issues with the text buttons not returning to the unpressed state after they are pressed. Possibly because they are within the while loop, so they don't reset…]




0 Kudos
Message 1 of 12

This is one of those rare times when it is OK to use a local variable to write a value to a control. 


Be careful with booleans though.  The mechanical action cannot be any "Latch" type (For good reason--- if you think about it)  In your case you only need to write to the switchers anyway.


Now about those Latchers that are not resetting.  They won't reset until they are actually read!  That means they have to be in a block diagram area that will execute.  If you are using an event structure, put the latching booleans in the case that handles the value change event.

"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 12
Actually there is at least two ways I know of to do this: 1> Use a local variable to update your control as an indicator. This way you can set your control's state with the feedback information. 2> Use a mouse down (or other) event on your indicator to determine when the user clicked on it. This way the state of the indicator shows the feedback but the program responds to clicks on the indicator. I prefer the second one for cases like this. Wire Warrior
Wire Warrior

Behold the power of LabVIEW as my army of Roomba minions streaks across the floor!
0 Kudos
Message 3 of 12

I was able to automate some of the pneumatic switches using local variables, but the buttons still don't latch properly. For example, I have a "Close All" button, which closes all of the valves. The button is able to close all of the valves, but does not return to its initial state. With my understanding, the buttons should latch back to the original state after the case with the local variables runs.


[Found a solution:]

I did this by having the case set the button to FALSE after it changed the 6 switches, using a local variable. Is this an okay solution? I mean, it does what I want it to do, but I'm wary of setting a boolean to false within its own case structure…

0 Kudos
Message 4 of 12

I would think the "close all" button could be latch action. Why would that need a local variable?

0 Kudos
Message 5 of 12

Here's a quick example how it could be done (LabVIEW 8.2). Modify as needed. Remember to use arrays whenever practical to reduce clutter.

Message 6 of 12

@Quevvy wrote:

[Also, I'm having issues with the text buttons not returning to the unpressed state after they are pressed. Possibly because they are within the while loop, so they don't reset…]

In order for the buttons to reset, they need to be read by the code. As long as they are in the while loop, they should reset. If they don't, show us some code. (They will not reset if you place them outside the loop, because they would only get read once at the start of the program, and never again.)

0 Kudos
Message 7 of 12
If you have a local variable to write to that boolean is not a latching mechanical action. the compiler would break any code with a write local or write value property node linked to a latching boolean.

"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 12

"First Attempt" is what I wrote out. I have a few parts in the works, so I disabled those. I am using local variables, not the event structure that "" used (I also am not using arrays, sorry.), so it may be a bit confusing. I may work on making it an array so it's more manageable…


On another note, my VI can no longer access the pneumatic switches as it used to. Whenever I run my VI, all the valves close, but then cannot be changed. "kpcipiodirectio" is the example VI to write/read from an instrument I'm using. Yesterday, the instrument was able to be written to, but cannot today. I have not touched the computer at all over night; nobody has. All I did was copy the block diagram to my VI and change the inputs to constants.


Also, I'm fairly new to LabVIEW, so I don't know how to use event structures well yet…

Download All
0 Kudos
Message 9 of 12

I tried using an array. It does look neater, but I'm still having issues with the instrument actually reading the number that it has sent. This might be why the buttons aren't popping back up. There's now an indicator showing the number that the array sends to the instrument (in binary, each digit represents a valve); this number is the correct number, but is not getting to the machine correctly.


I'm going to add a wait time to check if that's the problem.

0 Kudos
Message 10 of 12