LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Switching button default?

Solved!
Go to solution

Can one through the use of "Invoke Node" or "Property Node" change the default of a push button?  I'm attempting to create a switch that works like a button with the mechanical properties "Latched When Pressed", but have the output of "Switched When Pressed"

 

I've searched on here with no results, but maybe I'm looking with the wrong key words...

 

I've attached a VI that simulates what I'm working with right now... the Control 1 and Control 2 simulate a control sequence that I have which controls a valve... Control 1 opens the valve and Control 2 closes the valve.  The counter in the Case Structure is to give me a way to sense "hunting", which is essentially when the valve is moving too fast so it shoots past the set point and has to reverse direction, once it does it so many times, in this case 5 times, a "True"  signal is sent to the Signal LED and what I'm wanting it to do is take that True and have it "click" the Switch so my signals are redirected, and my current thought is to have a flat sequence structure in a event strucutre so I can use a Invoke Node to "Reint to Default" and then change the default so effectivly flipping the switch back and forth. Once I get this part figured out then I'll be shortening the amount of time the signal is being sent to the valve.

 

I've built this thing 20 different ways, but still can't get it to hold... the "True" from the counter is always just a single blip as the while loop runs.  Anyone on here  have any insight or suggestions about how to do this.  All I'm really wanting is the equivalent of a single push button switch... push it once and it's on, push it again and it's off.   ...so single True and it's on, then single True and it's off.  I don't know, maybe I'm just making this way more difficult than it really is.

Thanks!

Chad

 

0 Kudos
Message 1 of 5
(2,448 Views)
Solution
Accepted by topic author chuggins143

Just set the mechanical action to Switched when pressed instead of Latch.  Then use local variables to toggle the state.  In other words, when you get the overtravel condition, write a False to the local variable.  Switch when Pressed is just like a push button switch.  Click it once and it is on, click it again and it is off.  Just watch how you use the local variables so you don't have a race condition.

 

- tbob

Inventor of the WORM Global
Message 2 of 5
(2,442 Views)

Excellent!  Thank you!  I'd never had the case to use the local variables... yet another weapon for my arsenal!

Thanks!

Chad

0 Kudos
Message 3 of 5
(2,433 Views)

Don't get too hung up on Local Variables.  Beware of Race Conditions.  They can cause a world of trouble if not used properly.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 5
(2,422 Views)

Will do!  Thanks for the tip!

C

0 Kudos
Message 5 of 5
(2,390 Views)