04-28-2010 05:05 PM
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
Solved! Go to Solution.
04-28-2010 05:15 PM
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.
04-28-2010 05:40 PM
Excellent! Thank you! I'd never had the case to use the local variables... yet another weapon for my arsenal!
Thanks!
Chad
04-28-2010 06:16 PM
Don't get too hung up on Local Variables. Beware of Race Conditions. They can cause a world of trouble if not used properly.
04-29-2010 12:54 PM
Will do! Thanks for the tip!
C