LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to stop a SubVI from the main VI?

Solved!
Go to solution

I have a sub vi that gets called in the main vi to do a couple of things. I want to give the user the option to hit a stop button and that button in the main vi will stop the sub vi while it is running. Is there any way to do this? 

 

I know there is the option to use the vi server reference. This works in the sub vi, but i need it to be called to work from the main vi. Any suggestions?

0 Kudos
Message 1 of 13
(4,573 Views)

One simple possibility: Create a reference of the control on the caller and use it as input to the subVI. In the subVI, read the value at reasonable intervals using a value property connected to that reference.

 

Of course the rest of the architecture should be reasonable too. How are you calling the subVI, for example? It always helps to show some code for context. There are many possible solutions, and picking the most suitable really depends on many things that we currently don't know.

0 Kudos
Message 2 of 13
(4,564 Views)

Thanks for the reply. How would I check the value of the button press consistently? I suppose putting it in a while loop, but then how would I get out of that while loop? I would need a condition to be met for it to stop. Is there something that detects when a sub vi is completed?

 

0 Kudos
Message 3 of 13
(4,549 Views)

Your questions indicate that you are probably not very familiar with LabVIEW and dataflow, and are way too general to give a specific answer without seeing a simplified version of you VIs (caller and subVI).

 

If your subVI does not yet have a wile loop, what does it actually do? How is it called in the caller?

 

As mentioned, LabVIEW has a rich set of tools for communicating between different VIs running in parallel (control references, globals, action engines, notifiers, ,... and many more) and we cannot tell you what's best without more information.

0 Kudos
Message 4 of 13
(4,539 Views)

Thank you for the information. Still pretty new with LabVIEW, but do government work, so cant really explain what is going on entirely. Was hoping a broad idea would get me some help, but very understandable if it did not.

0 Kudos
Message 5 of 13
(4,535 Views)

@LearningLabVIEW wrote:

Thanks for the reply. How would I check the value of the button press consistently? I suppose putting it in a while loop, but then how would I get out of that while loop? I would need a condition to be met for it to stop. Is there something that detects when a sub vi is completed?

 


Have you did any of the LabVIEW tutorials? As altenbach indicated your questions indicate that you have a lack of understanding of how dataflow works. When a subvi completes then the ouptuts will appear at the output terminals of the subvi. If you do not already have a while loop inside your subvi then what are you trying to stop? As others have stated please do attach some code (main vi and subvi) so that we can get some context. Also, it's best to save for previous version at least 2 versions back if you're using the latest version of LabVIEW as many users on this forum are not.

 

Edited to add: You can make an example vi that shows what you're trying to do that does not contain any proprietary/classified information.

0 Kudos
Message 6 of 13
(4,531 Views)
Solution
Accepted by LearningLabVIEW

@LearningLabVIEW wrote:

How would I check the value of the button press consistently?


Read Control Value.png

Note that this isn't totally consistent. You'd be polling the value, so there is a change it's toggled back to false between reads.

 

You'd need to register a dynamic event that triggers a semaphore that is read in the process's loop. If the process is done, it can give a value signalling to stop the event structure.

 

@LearningLabVIEW wrote:

I suppose putting it in a while loop, but then how would I get out of that while loop? I would need a condition to be met for it to stop.

 


Stop Loop.png

@LearningLabVIEW wrote:

Is there something that detects when a sub vi is completed?


Yes, dataflow continues with things synchronized after it.

Message 7 of 13
(4,516 Views)

Looks like you are using a latch action boolean (thus the variant). Seems very fragile (as you already mentioned). 

0 Kudos
Message 8 of 13
(4,511 Views)

@altenbach wrote:

Looks like you are using a latch action boolean (thus the variant). Seems very fragile (as you already mentioned). 


No, I disconnected the strict type, thus the variant.

0 Kudos
Message 9 of 13
(4,508 Views)

What is that icon with the gear wheel? I am not seeing it in my functions pallet.

0 Kudos
Message 10 of 13
(4,491 Views)