07-07-2010 02:05 PM
Is there a switch property node that will programmatically turn a toggle switch to the off position upon exiting a while loop? I can set the value (signal) property node to false but the switch still shows as being on on the front panel when the program stops. I want to switch to physically show as being in the off position. thanks in advance.
Solved! Go to Solution.
07-07-2010 02:11 PM
You either write a False to the value or value (signalling) property node, or a false to a local variable of the switch.
If it isn't working for you, then you must have something wired wrong, or have something wrong with the order of execution of your wiring.
Post your VI so we can see what you are doing and suggest a better way.
07-07-2010 02:31 PM
attached .vi as requested.
07-07-2010 02:41 PM - edited 07-07-2010 02:42 PM
I assume you are talking about the Data switch. Create a local variable of the data switch by right clicking and selecting Create - Local Variable. Put the local outside the loop on the right side. Put a False constant inside the loop near the right border. Wire the constant through the loop to the local. That't it.
Comments about your VI. You have a false constant wired to the loop stop sign. The VI will run forever unless you press the Abort button. This is not the way to stop a vi. If you stopped it this way, the data switch would never get set back to false because you aborted the vi before it had a chance to write false to the local variable. You should use a stop button instead. Wire the stop button to the stop sign. Use the Stop button from the boolean palette because it has the mechanical action set to latch when released. The boolean will reset itself to false after you press it and the code reads it.
Another comment. Why is there so much space between your code. You have to scroll all over the place to see all the code. Make it fit on one screen.
07-07-2010 03:34 PM
Bob;
I'm not sure how an older version of the vi was saved under the same name but here is the attached file that I'd like to be reviewed. Please disregard the previous attachment. I think I was doing what you suggested but it didn't work. If possible could you take a moment and look at this one? thanks in advance.
07-07-2010 03:42 PM
Changed it exactly how you said and it worked. Thanks for taking the time to review this.
07-07-2010 04:01 PM
That last VI you posted wouldn't work because the writing of the false to the property node would happen at the very beginning of the program, either right before, or at the same time as the while loop is running.
With tbob's instructions, you guarantee it happens at the end of the program after the while loop is stopped because of the data dependency of the local variable or property node getting its value from the while loop.
07-07-2010 04:11 PM
@GSO wrote:
Changed it exactly how you said and it worked. Thanks for taking the time to review this.
You didn't do it exactly as I said. Read my instructions again. I don't see how the Servo ON/OFF will go back to false after you click on it. You need to learn about data dependency. The flat sequence structure you added after the loop has no wires going into it. This means it will execute as soon as you run the vi. My instructions were clear, and it said nothing about creating a flat sequence structure. When you run the vi, the false will be sent to the Val(sgnl) property. (I specified a local variable, not a property node). Then the next frame will execute, which is a 1 second delay. This serves no purpose whatsoever. Just becuse the flat sequence is placed after the loop doesn't mean that it will execute after the loop. Nope, it will execute as soon as you press the run button. So the False gets send to the property node, then at some time you press the Servo button and it will stay true.
Re-read my instructions and do it exactly as I stated. And your block diagram is still too large. Lots of wasted space. I still have to scroll all over to see all the code. This makes it difficult to examine your code. Please clean it up.