LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Recieving data from a sub vi question

I have a sub vi that performs a function inside a for loop for simplicity think of it a s num = num + 1.
 
When I call the sub vi is there any way to get the results of each iteration in real-time in the top vi or do I have to wait until the sub vi is complete and all the data is passed out of the sub vi?
 
Right now I am using controls and indicators to connect into and out of the sub vi.  If I was to use a refereence would that recieve the data in real time inside the top vi?
 
Thanks
Tim C.
1:30 Seconds ARRRGHHH!!!! I want my popcorn NOW! Isn't there anything faster than a microwave!
0 Kudos
Message 1 of 4
(2,575 Views)
Realtime is a dangerous word, but yes, this will work as expected.
 
However, be aware that updating front panel objects via value references is extremely expensive. You shold definitely not do this in an inner fast loop. It also makes the code incomprehensible if you do this excessively. What if several subVIs update the same indicator?
 
You'll get all the associated problems of (1) bypassing dataflow, (2) race conditions, (3) extra data copies in memory and (4) extra thread switching, (5..inf) etc..
 
For example, in the attached image, you could select the while loop and turn it into a subVI and things will continue to work as expected.
 
Now, when running the toplevel VI, the counter will be updated in "realtime" and you'll be able to stop the subVI with the stop button on the toplevel VI.
 
Does this answer your question?



Message Edited by altenbach on 01-19-2008 01:16 PM
Message 2 of 4
(2,572 Views)
Well, yes it does answer my question.  But it sounds more like I should avoid this.  Pehaps having a VI pop up that say "Processing Data"  then close the popup vi and display the data when the sub vi completes would be a better solution.
 
Thoughts.....
 
 
Thanks
Tim C.
1:30 Seconds ARRRGHHH!!!! I want my popcorn NOW! Isn't there anything faster than a microwave!
0 Kudos
Message 3 of 4
(2,560 Views)
It is not clear exactly what you are trying to do. If the subVI runs as an independent, parallel loop, then you can pass data to the main VI via a queue or an Action Engine VI. Both of these avoid the problems altenbach pointed out.

Lynn
0 Kudos
Message 4 of 4
(2,530 Views)