LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVIs in main VI

Solved!
Go to solution

Hi all,

 

The goal of my application is to read data from three subVIs simultaneously, each representing a different NI module, and put this data into a 1D array that is continuously being updated while the VI is running.

 

When I run my code with simulated hardware all three subVIs run at the same time and their data is being continuously updated but the main vi is not.

 

The array in the main VI is not updating.

 

erabrannan_0-1598949873885.png

 

How can I change that?

 

-Emilie.

 

 

 

0 Kudos
Message 1 of 5
(1,859 Views)
Solution
Accepted by topic author erabrannan

Hi Emilie,

 


@erabrannan wrote:

When I run my code with simulated hardware all three subVIs run at the same time and their data is being continuously updated but the main vi is not.

The array in the main VI is not updating.

How can I change that?


You can change this by using THINK DATAFLOW!

The mainVI loop can only iterate once the subVIs are finished. But your subVIs wait for user interaction because they have their own loops…

 

Simple solution: get rid of the loops in the subVIs.

Better solution: think about a suitable program architecture!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(1,835 Views)

Dear Emilie,

Could you reshare the VIs in a older version of Labview (2014 or even 2018)( Under File >Save for previous versions). I think most users here have not yet switched to 2020 and won't be able to open them.

From the snippet you provided, I have a question.  Do those subVIs have While loops inside ?

--DeX


0 Kudos
Message 3 of 5
(1,831 Views)

@DeXteR_INIT wrote:

Dear Emilie,

Could you reshare the VIs in a older version of Labview (2014 or even 2018)( Under File >Save for previous versions). I think most users here have not yet switched to 2020 and won't be able to open them.

From the snippet you provided, I have a question.  Do those subVIs have While loops inside ?

--DeX



They do.

0 Kudos
Message 4 of 5
(1,780 Views)

I would suggest perhaps reading about the Producer/Consumer architecture/design.

 

You could pass Queue references into each of your subVIs and have them enqueue their data elements, and then have a separate loop in your main VI (not a loop around the subVIs, but side-by-side with them) dequeue elements and place them into a shift register feeding a graph.

 

You should also consider passing information about the source with the data elements (e.g. an enum, number or string that identifies the subVI that sends the data) so that the Consumer (the loop in your main VI with the graph) can correctly append the data elements to the right source.

 

A simple example is attached (saved in 2019).

Maps are used to store the data to simplify finding a data set by name, which you might consider since you have 2020 (at least based on a previous comment).

Main_BD.png

 


GCentral
0 Kudos
Message 5 of 5
(1,757 Views)