LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop a running VI from parallel loop?

Hello,

Is there a way to stop a executing Sub-VI from outside?

For example if the Sub-VI is hanging because of waiting endless for a trigger or of a not clicked popup or ....

 

In the attached example on the left side there is a check of 60secs are over AND if a Variable is set to true. In this case the VI which is on the right side "SUBVI" should be stopped.

So any opened dialog-boxed or VISA things that are waiting for instrument answers should be canceled.

 

How can this be done?

 

Thanks for help

 

BR

0 Kudos
Message 1 of 4
(1,794 Views)

Well, the *first* thing to do is not code the sub-vi such that it *can* wait endlessly for a trigger, an instrument response, or whatever.  This is one of those cases where you need to *avoid* the problem rather than *solve* it.

 

Instead of coding things that wait endlessly, build in mechanisms that let you interrupt the wait.  This might mean iterating over short waits while checking each iteration for a condition that signals you to stop waiting.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 4
(1,775 Views)

There are many ways to stop multiple parallel loops.  One way (not recommended!) is to push the "Abort" button.  Another is to have a Global Stop variable wired to every While-loops "Stop" terminal, and to make sure that every "Wait for ..." condition has a suitable Time-out (with code in the "Timed-out" loop that allows you to reach in and stop the execution) -- this is also a "Blunt-force" approach that I do not recommend.

 

I recently wrote some documentation for a complex routine I'm designing with some colleagues who are building the hardware and some of the software (I'm something of a Newbie with FPGAs).  I have a section called "Exiting and Stopping Multiple Parallel Loops" (there are on the order of a dozen in the early "test" version of the code).

 

You have not shown us any of your code, but I can only guess that it wasn't designed to accommodate parallel loops.  There is no "one size fits all" solution to this question -- it needs to be considered taking into account all of the code.

 

If you want help on a small example, include all of the code so that actual working solutions can be created, tested, and evaluated (by you).  Pictures (not useful to provide when you are asking LabVIEW developers to do your work for you for free) won't cut it -- provide LabVIEW code (preferably a small Project, zipped up for easy attachment).

 

Bob Schor

0 Kudos
Message 3 of 4
(1,766 Views)

Have you ever wondered what would happen if you would replace the "=TRUE" with a wire? What is the truth table of your current logic? (See also)

 

altenbach_0-1592575960576.png

 

I think you have some serious architectural problem and should re-think this from scratch. Maybe the timeout should be handled inside the subVI because it knows how long it has been running and can stop itself.

 

 

 

0 Kudos
Message 4 of 4
(1,734 Views)