LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error with parallel while loops

Solved!
Go to solution

Hi,

 

I have to connect 6 different instruments with gpib. I'm using parallel loops but the problem is when I try to open 2 or 3 subvi at the same time (the intstrument's drivers), I just can open one because of the while loop to execute the subvi. The program should be able to open all the subvi independently.

 

Can you give some ideas?

 

Thanks

A. Castillo

0 Kudos
Message 1 of 8
(3,303 Views)

Hi Ahc,

 

Open up the SubVI and Select File » VI Properties.

In the Execution tab, select 'Reentrant Execution' and use the thumbnail to select 'Preallocate clone for each instance'.

 

This will allow multiple instances of the same SubVI to be stored in memory, meaning your top level VI doesn't have to wait for a single SubVI to finish its execution when a part of your VI it and it is already in use somewhere else in your program. Without re-entrancy, which I'm assuming may not have been enabled for the SubVI you have created, only a single instance of the SubVI is instantiated in memory. Any calls to it become queued; forcing undesirable sequentiality between your VIs.

 

Hope this helps.


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

0 Kudos
Message 2 of 8
(3,288 Views)

Thanks for the help, i've tried but i still have a little problem, when I call the SubVI with the "invoke node" I want to hold it opened until I close it by myself. The problem is that despite of the SubVI configuration (as I read before) I can't do that because the data stops on the invoke node "Run VI"

0 Kudos
Message 3 of 8
(3,264 Views)

Try putting a small time delay in each while loop (Wait (ms) function).  A while loop with no delay is called a Greedy Loop because it tends to consume all available CPU cycles until it completes.  With the delay LabVIEW's internal scheduler will run another node (loop) while waiting for the delay to finish.  Since the loops are looking for human interaction, waits as long as 100 ms will still be quite responsive to the operators.

 

Rather than using the while loops, you could put all the stopp buttons in an event structure in one parallel loop and use notifiers to implement wiat for stop function.  The Wait on Notification has the same effect as your while loops but without the CPU grabbing issue.

 

If all your GPIB devices are on the same bus, it is often better to use a single VI to do all the bus communications and to pass messages via queues between the GPIB instruments and the program which uses or generates the data.

 

Lynn

0 Kudos
Message 4 of 8
(3,253 Views)

Your calling the VIs 2X, first without showing the FP then by showing the FP. Thus when you hit run, the without FP run and you don't see the show FP till the instance of without FP is finished....

 

ShowFPonCall.PNG

0 Kudos
Message 5 of 8
(3,232 Views)

Hey Thaks to both of you!

Johnsold I'm relativ new with Labview, if I may ask, how can I implement the Wait on Notification instead of the while loops?

 

Kind regards

AHC

0 Kudos
Message 6 of 8
(3,206 Views)
Solution
Accepted by topic author Ahc

Look at the detailed help for the Notifier functions.  Then follow the links to the examples included with LV.

 

Another problem you have, whether using your greedy loops or notifiers or some other technique, is how to stop your main while loop.  All of the subVIs must be called before the loop will stop.  This is the fundamental paradigm of LV.

 

You probably need to rethink your primary architecture to something which will actually do what you want.  Do some planning and design before your start coding.  Write down the requirements for the program and determine which parts are dependent on othrer parts, then select a program architecture which can meet the requirements.

 

Lynn

Message 7 of 8
(3,194 Views)

You had all the reason, I've re-thinked and now I have a solution, thanks a lot to all for the help!

0 Kudos
Message 8 of 8
(3,170 Views)