LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel Loop Operation in Subvi

Hi all,

 

I need your help.  I have a few parallel loops in my main VI.  The first loop would read off my DAQ buffer every so often and put the data (feedback signal of a motor) in a queue.  The second loop contains a subvi that would take the reference of the queue, dequeue the data, and check to see is the feedback in a particular range (if not in range, the motor keeps going; if in range, the motor stop, and the program leaves the subvi). 

 

If I explained myself clearly, you can see that the subvi would dequeue repeatedly in a loop, assuming that the queue is being updated by the first loop in the main VI (which is not).  Any suggestion?  I am trying to say away from global, but I would like to hear all methods.  Thanks!

 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 6
(3,394 Views)
What you want to do sounds reasonable.  Are you having a particular problem?  If so, what?  Please post your code so we can see how you are trying to achieve your goal.
0 Kudos
Message 2 of 6
(3,386 Views)

Let me rephrase my question a bit.  If I have two parallel loops, and the first loop has a subvi with another loop that dequeues repeatedly, and the second loop enqueues repeatedly to supply the dequeuing for the loop inside the subvi.  When the program is inside the subvi, would the enqueuing of the second loop continues to run, or would the program get trapped inside the subvi, and the enqueuing on the second loop would stop until the program exit the subvi?  I guess I got confused because I was in debug mode, and it seems to me that the program would be trapped inside the subvi during debug.

 

Loop 1

- subvi loop (dequeue repeatedly)  << would the program get trapped here? 

 

Loop 2

- enqueue repeatedly to supply data for the subvi loop dequeuing

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 3 of 6
(3,383 Views)

So you don't have two parallel loops.  A loop inside a loop is not parallel.  Two side by side loops are paralle.

 

You have an outer loop.  Inside that is a subVI, inside that is another loop?

 

If so, yes the operation gets stuck inside the subVI.  It is a part of dataflow.  An iteration of the outer loop won't finish until all code inside of it has completed.  That means the subVI.  The subVI won't finish until the code inside of it is completed.  That means its loop needs to end.

 

You need to move the subVI out of the outer loop.  In general, subVI's shouldn't have continuously running loops.  If it does, it should be standing alone outside of the first loop with just the queue reference initiating it.  If it did not have a loop inside, just a code routine, it should be in its own loop outside of the first loop.

 

Look at the producer/consumer architecture examples.

Message 4 of 6
(3,380 Views)

I guess I am not making myself very clear, sorry.  I have two parallel loops.  Let's call them loop 1 and loop 2.  Inside loop 1, there is a subvi that contains another loop, and let's call this loop 3.  My question is when the program is inside loop 3 (inside the subvi), would the program execute loop 2 concurrently? 

 

Loop 3 dequeues repeatedly, and loop 2 enqueues repeatedly, so it is critical for them to execute concurrently, but I have a concern that my program maybe trapped inside loop 3.  Is my concern legitimate? 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 5 of 6
(3,364 Views)

Probably.

 

But instead of constantly revising your description, please post some VI's that show your setup.  Then things will be clear.

 

What is going on in loop 3 that must run continuously?  How do you plan to stop loop 3?  If loop 3 continues to run, loop 1 will never get to its next iteration.  If loop 1 is the enqueuer, it will only enqueue data 1 time (depending on how the code is ordered inside it).  Loop 2 (the dequeueing consumer loop) will only run once, when it gets its data from loop 1.

0 Kudos
Message 6 of 6
(3,362 Views)