ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transfer Boolean Data/Signal from Sub Vi to Main VI

Hi,

 

I'm pretty new to LabVIEW and encountering this problem. I am hoping to get some help with the problem I've been having.

 

Objective: Transfer data (Boolean and numerical) from a sub vi to the main vi.

 

Problem: The sub vi has a for loop and the main vi has a while loop, and for some unknown reason the data off the sub vi is not transferring to the main VI. There are inputs for the sub VI, which are controlled from the main VI, and during runtime those inputs does get updated real-time in the sub VI too. During runtime I've noticed the sub VI works fine and outputs the corresponding signals, but I need those signals into the main VI. I've found some similar problem for some users and i went through the solutions too, but still doesn't seem to work in my case.

 

I am attaching the VI code and snips (Main/Sub) of the code. The Vi works for rest of the functions except for this instance. The VI is still a work under progress, so please point out any other suggestions or recommendations regarding it. 

 

Thanks

- themadgreek

0 Kudos
Message 1 of 3
(1,134 Views)

Hi greek,

 


@themadgreek wrote:

for some unknown reason the data off the sub vi is not transferring to the main VI.


There is a very known reason: THINK DATAFLOW!

 

Dataflow dictates which part of code is executed:

  • when there is no data dependency then code is executed in parallel
  • when there is data dependency then code is executed in order depending on dataflow
  • a structure is entered when all input data is available
  • a structure is finished when the code inside has finished

Problem analysis:

  • There is a subVI "below" your while loop, which imposes a data dependency. How/when is that loop executed?

 

Suggestion:

  • Learn about THINK DATAFLOW!
  • Learn about using notifiers/queues or channel wires to transfer data between parallel running loops. (Learn from example VIs found in example finder!)
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 3
(1,126 Views)

Hi Themadgreek,

 

you might consider use Functional Global Variable(FGV) to transfer data between different loops, even different VIs.

There are of course other solutions, but the FGV is the most easy way to solve your issue.

 

https://learn-cf.ni.com/teach/riodevguide/code/rt_functional-global-variable.html

 

Regards,

FrankenChino

 

0 Kudos
Message 3 of 3
(1,069 Views)