Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I retrieve data from a while loop inside a subVI to main (calling) VI?

I have a main (calling) VI which calls three subVI's, each subVI has a main while loop inside, each while loop contains some data, the question is, how can I get the data from these subVI and display to the main VI?
0 Kudos
Message 1 of 5
(3,330 Views)
Lok,

at first, I'd suggest re-thinking your design. There might be some reason to do so, but except some asynchronous actions, this is in most cases bad style and prone to race conditions.
Having said this, here are some means:
1. Use a/some Global(s) to write to in your SubVI. Read its value in Main.
2. Create a/some named queue(s) to transfer your data.

In any case, you need some parallel running processes to read and process these data while main is still _calling_ the SubVIs.
LabVIEW uses data dependency to schedule the different nodes on a block diagram. In any case, each node/structure/compound is operated not before all its data are avilabel. So the only way to call your SubVIs _and_ to process their 'internal' data is to have a parallel running loop. Needs some synchronisation and precaution and so on.
Again, I'd suggest re-evaluating your program design.

Greetings from Germany!
--
Uwe
0 Kudos
Message 2 of 5
(3,319 Views)
I assume you mean that you mean that you want to display the data while the subVIs are running and not how to return a value from a subVI. What you need to do is in each subVI, write to a reference of the indicator on the main. I've attached a simple example. There are other shipping examples on references. To create a reference, right click on the indicator on the main's front panel and select Create>Reference. Then, find the reference on the block diagram and select>Create Control. Cut the control from the main's front panel and paste it on the front panel of your subVI. Wire this reference to the subVI's connector pane. On the subVI diagram, right click the reference and select Create>Property>Value. Wire the reference to the property's reference input and wire the value you want to pass to the main to the property's value input. On the block diagram of main, wire the reference of the front panel control to the subVI.

Now that I've said that, I'd also like to second Uwe's recomendations. While the procedure above makes it possible, it's usually not necessary. I find it simpler to just show the front panel of a subVI while it's running. It most cases, the main VI can't do anything with the data until the subVI finishes anyway.

Message Edited by Dennis Knutson on 06-22-2005 09:08 AM

0 Kudos
Message 3 of 5
(3,317 Views)
Uwe,

Thanks for the quick response. The three subVI's are the data acquisition process with different data rate. The first design was to aquire these three types of data using the same VI. It didn't work because of the asychronous actions, as you said. Right now this design has the best result, the time sequence follows what I expected. The only concern is that I can't display the data to the front panel in the main VI. If you can help, that will be great. Thanks again.

Lok
0 Kudos
Message 4 of 5
(3,314 Views)
It works! Thanks so much Dennis!

Lok
0 Kudos
Message 5 of 5
(3,305 Views)