LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass pass data between the VIs in real time?

I am struggling with the implementatin of this feature using LabView.  I have a WHILE loop in the main program. Inside WHILE, there is a CASE structure controlled by a boolean switch on the front panel of the main program. If the boolean value is TURE, then a sub-VI (inside the TRUE case) will be opened. The front panel of the sub-VI contains a bunch of Controllers for user to adjust (the values).  When I adjust the controllers, the values do change (confirmed by the corresponding indicators).  However, the new values will not be passed back to the main porgram until the sub-VI is closed. I want the new values to be passed back to the main program while I am adjusting them (in real-time).  Could any one advise me how to do that?  Thank you so much. 
0 Kudos
Message 1 of 4
(4,997 Views)
You will have to call that subVI in a separate parallel while loop.  You will also have to either pass it references to controls in the main VI, or set up a communication scheme to pass data such as using a queue or a functional global variable.  You can also use a global variable, but that is not a preferred method.
0 Kudos
Message 2 of 4
(4,993 Views)
Thank you, Ravens Fan, for your prompt response.  I forgot to mention that the case was indeed in a parallel WHILE.  However, I didn't use any global variables.  Would you kindly educate me what the difference between a functional global variable and a global variable is? Also, why is it not preffered to use the global variable.  I used to be a C programmer and just switched to LabView a few months ago.  I am not up to the speed yet.  Thanks again.
0 Kudos
Message 3 of 4
(4,971 Views)

Global variables can cause race conditions if used improperly.  That is where you can't control when the variable is being written from or read to.  With Functional Globabl Variables, you can prevent something writing to the "variable" at the same time something else is reading it.

 

Functional Global variables are also known as action engines.  Search the forum for both phrases to learn more about them.  Especially read Ben's Action Engine Nugget.

Message 4 of 4
(4,969 Views)