LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

extracting data from subvi loop

My program contains a main vi and a subvi  The subvi contains a loop which is used to grab small chunks of position data in the form of number arrays from a motor.  My main vi contains a chart which I would like to use to plot the position data.  In the subvi I have created an indicator within the loop, which is connected to a terminal.  I have the subvi array terminal in my main vi connected to the main vi chart.
 
However only the last chunk of data is displayed in the main vi after the subvi loop is finished.
 
Thanx,
 
Tom
0 Kudos
Message 1 of 5
(3,296 Views)
Tom,

This is the way LabVIEW's dataflow paradigm works. Data from anode (the subVI in your case) is only available after the execution of the node completes.

Queues, functional globals and other means can be used to get data from one loop to another.

The acquisition loop should probably be running as an independent parallel loop. Look at the Producer/Consumer design pattern under File >> New.. >> VI ...

Lynn
0 Kudos
Message 2 of 5
(3,290 Views)

Lynn,

thanx for the reply.  I looked at the producer/consumer (data) example and implemented it into my code.   In the subvi I created an indicator for the queue reference and connected it to a terminal.  In the main vi I connected the queue reference output to the second while loop.  However using a probe for the queue reference in the main vi, it tells me that the refnum is invalid.  I have attached a simplified picture of what I am doing.

Tom

0 Kudos
Message 3 of 5
(3,280 Views)

I also tried to create global variables in the subvi which connect to the refnum and error of the queue.  Then I added duplicate global variables in the main vi and connected those to the "consumer" while loop.  However the same "invalid refnum" occurs.

 

Tom

0 Kudos
Message 4 of 5
(3,267 Views)
Tom,

If I interpretted your picture correctly you have wired the output of the subVI as an input to the Main VI. In this case the main vi will not start until the subVI has completed. At that time the Release Queue function has destroyed the reference.

But the more fundamental problem is that you want the subVI to run in parallel with the loop in the main VI. Make the queue reference an input to the subVI and create the queue in the main VI. Have the subVI outside the loop in the main VI with no data dependency between the loop and the subVI.

Lynn
Message 5 of 5
(3,258 Views)