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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I tie a button on a subvi to execute a button on my main vi?

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!

0 Kudos
Message 1 of 10
(3,033 Views)

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.

0 Kudos
Message 2 of 10
(3,010 Views)

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.

 

0 Kudos
Message 3 of 10
(2,981 Views)

@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


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 10
(2,966 Views)

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.

0 Kudos
Message 5 of 10
(2,956 Views)

@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?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 10
(2,945 Views)

Sure, here it is

0 Kudos
Message 7 of 10
(2,940 Views)

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. 

0 Kudos
Message 8 of 10
(2,925 Views)

@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

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 10
(2,910 Views)

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?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 10
(2,897 Views)