From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Global Variables to Update Boolean controls on the Main VI

Solved!
Go to solution

Hello,

 

I am trying to use a global variable to act as both a control and an indicator of a few boolean operations in my VI. I currently have a subVI which changes my boolean value to TRUE. My problem is that although these values are being updated in my Global variable VI, I am finding it impossible to get it to update on my main VI (unless of course I change it to an indicator).

 

Any help would be much appreciated.


ThanksCapture.PNG

0 Kudos
Message 1 of 2
(2,422 Views)
Solution
Accepted by topic author yezdi777

Hi Rahul. 

it looks like you have misunderstood how global variables work in LabVIEW. I’ll quickly talk you through what is happening in your vi. 


youve wired the boo leans to the global sun your main vi. This writes the value of those booleans you the globals. 


you then overwrite those values with false values. 

 

your subvi is then called which then writes a true to both globals. 

at no point is the value of those globals written back to the control. The only way of doing that is make a local variable of the controls and set them to write. 

 

the use of global variables isn’t the best way to achieve this though as it goes against the data flow paradigm of LabVIEW. A better way would be to create indicators in your sub vi and wire them to the terminal block. 

I suggest tou read the links below to get a better understanding. 


https://zone.ni.com/reference/en-XX/help/371361R-01/lvconcepts/using_local_and_global/

 

http://www.ni.com/academic/students/learn-labview/

0 Kudos
Message 2 of 2
(2,400 Views)