LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping parallel loops instantly

I have 2 VIs that I want to run in parallel. A is a DAQ subVI and the B is an independent subVI that processes a parameter (temperature). I'd like to stop A if temperature exceeds a certain range. I know I can use Queues or VI servers to do the same.

 

But it takes some time for A to stop and step to the next step. Is there a way I can stop A immedietly based on my temperature reading, and step to the next step ? Please let me know. I've attached a simple picture. Top VI is B, and bottom is A.


Kudos are the best way to say thanks 🙂
0 Kudos
Message 1 of 4
(2,428 Views)

The image you posted is not very helpful. Stopping immediately is not always possible or practical. There are some tasks such as a VISA read or write that cannot be interrupted and you must wait for them to complete. However I would recommend that you consider using a state machine. The state machine could take the reading and check the temperature. Based on the value of the temperature the next state would be selected. For example, it the temperature was in range go back and take another reading. If it were out of range then it could notify the parallel task to stop and then proceed to whatever task/state is next. The state machine is a flexible construct that is suited to what you want to do.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 4
(2,413 Views)

Hi Spartan00,

 

In addition to what Mark said, you can stop parallel loops using local variables (in the same program) or global variables (subVI's).

 

Check out this article: Stopping Parallel While Loops in LabVIEW With One Stop Button

 

Have a great day,

 

Chris V

Applications Engineer
National Instruments
0 Kudos
Message 3 of 4
(2,376 Views)

@Chris V wrote:

In addition to what Mark said, you can stop parallel loops using local variables


The problem with these solutions is that they are not instantaneous. It can take randomly from "zero to all the way to the actual wait time" for the other loop to stop.This could be a problem if the waits are long (more than a few seconds).

 

You can stop timed loops using the "Stop Timed Structure VI". You can also time the loops with the timeout of an event structure, so firing a stop event would bypass the delay. (Older options for interruptable waits are e.g. "wait on occurence with a finite timeout, etc.)

 

I would also recommend to combine the code of the two subVIs into one VI. We really need to see more of your code for a better analysis.

0 Kudos
Message 4 of 4
(2,350 Views)