From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
12-19-2012 05:05 PM
I've searched tutorials and can't seem to find an answer that translates into what I'm working on.
Consider the example located here: http://digital.ni.com/public.nsf/allkb/A882E27D1D7A949386256E0D0066B91A
How can I create a Stop button on the subvi that, when pressed, also executes the stop button on the main vi? At the same time, I'd like to be able to press the button on the main vi without executing the button on the subvi.
Thanks in advance for your help!
12-19-2012 08:20 PM
Hi,
You can pass the main vi stop button reference into sub vi, there you need to to write the value signaling property of the main VI stop button, upon activation of the sub vi stop button. Which in turn causes the activation of the main vi stop button.
In order to set the value of a Boolean control programatically you suppose to have proper latching action. I.e. you suppose to have latching action as "switch when pressed" or any, which is compatible to set the value of Boolean button programmatically.
12-20-2012 07:56 AM
Hi
This a good example that I wrote in the past in order to do explain how that works. See the attached file, open the main.vi and sub.vi, run the main.vi and it will start the sub.vi, while both are running, clic in the stop button and it will stop both VIs. Use this example within your code, let me know if this is helpful for you.
12-20-2012 08:51 AM
@maheshyt wrote:
Hi,
You can pass the main vi stop button reference into sub vi, there you need to to write the value signaling property of the main VI stop button, upon activation of the sub vi stop button. Which in turn causes the activation of the main vi stop button.
In order to set the value of a Boolean control programatically you suppose to have proper latching action. I.e. you suppose to have latching action as "switch when pressed" or any, which is compatible to set the value of Boolean button programmatically.
Careful there!
To clairify .... You cannot set the value property of a latching boolean. You can set the value property of a switching boolean
12-20-2012 10:00 AM
Thank you all for the input. Diego: your code was saved as LV2012 format, would you be able to re-post it for LV2011? I'd like to see your example if possible.
12-20-2012 10:35 AM
@p3psi wrote:
I've searched tutorials and can't seem to find an answer that translates into what I'm working on.
Consider the example located here: http://digital.ni.com/public.nsf/allkb/A882E27D1D7A949386256E0D0066B91A
How can I create a Stop button on the subvi that, when pressed, also executes the stop button on the main vi? At the same time, I'd like to be able to press the button on the main vi without executing the button on the subvi.
Thanks in advance for your help!
I don't understand exactly what you are trying to achieve. Is the subVI looping or waiting on events? Maybe it's time for some code?
12-20-2012 10:41 AM
Sure, here it is
12-20-2012 12:58 PM - edited 12-20-2012 01:02 PM
Bill: The mainVI controls two subVIs: subVI A & subVI B. MainVI contains a play button that begins executing both subVIs simultaneously, and it contains a stop button that stops the execution of subVI B. MainVI also minimizes when it the play button is pressed, which is necessary for this program but prevents access to its panel.
SubVI A contains a stop button that stops execution of only itself.
I'd like the stop button on subVI A to also execute the stop button on the mainVI (since mainVI is minimized), which in-turn will stop the execution of subVi B. Aborting operation of the entire program is only optional.
The code I'm working with is a large program I inherited with too much going on to be worth posting, so I've modified Diego's example to hopefully help solve the problem. It now includes a stop button and count function on the subVI. As of now, when the Stop button on the mainVI is pressed, nothing happens. I'm not sure if that's because I set it to a switching vs latching mechanism (I'm new to LV). When the Stop button is pressed on the subVI, both loops do stop running, but the program doesn't abort like it did before.
Hope that clarifies, and it would be great if someone could point out what's wrong with the attached example.
12-20-2012 01:18 PM - edited 12-20-2012 01:33 PM
@p3psi wrote:
Bill: The mainVI controls two subVIs: subVI A & subVI B. MainVI contains a play button that begins executing both subVIs simultaneously, and it contains a stop button that stops the execution of subVI B. MainVI also minimizes when it the play button is pressed, which is necessary for this program but prevents access to its panel.
SubVI A contains a stop button that stops execution of only itself.
I'd like the stop button on subVI A to also execute the stop button on the mainVI (since mainVI is minimized), which in-turn will stop the execution of subVi B. Aborting operation of the entire program is only optional.
The code I'm working with is a large program I inherited with too much going on to be worth posting, so I've modified Diego's example to hopefully help solve the problem. It now includes a stop button and count function on the subVI. As of now, when the Stop button on the mainVI is pressed, nothing happens. I'm not sure if that's because I set it to a switching vs latching mechanism (I'm new to LV). When the Stop button is pressed on the subVI, both loops do stop running, but the program doesn't abort like it did before.
Hope that clarifies, and it would be great if someone could point out what's wrong with the attached example.
How dumb of me - I didn't notice the code was posted waaaaay up there in the beginning. I apologize. Unfortunately at this time I have access only to LV 7.1! But I can make some guesses that hopefully you haven't already. I think you were trying to trigger an event on the main from inside the sub. How about registering the stop button from the sub in the main and add it to the case that stops the main? Now you'll have two events for the same case - the main VI stop button and the stop button from the sub-vi.
note: If you have the loop exit condition wired to the control inside the case, you'd have to wire it with a "true" constant, instead.
[edited for clarity] - hopefully
12-20-2012 01:39 PM - edited 12-20-2012 01:41 PM
Maybe I am missing something here. If Sub-VI A is in a loop and never exits, how is the while loop in the main VI supposed to jump to the next iteration?