LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

single core

If read through the posts about future changes... you will find where the global has trouble. As soon as someone says "Now I want that knob cranked automatically and if it goes over ... but still be able to control it manually..." you will have to find all instance of that global and replace it with an AE.

 

But if you started with an AE, no-brainer peice of cake...

 

I believe my opinion on globals is in that thread "say no more, say no more..."

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 21 of 26
(826 Views)

I generally go with the rule that no global variables is the way to go. I would use an AE or you can even look into using LVOOP. I can't remember the last time I used a global variable. It was back in the '90s sometime when I first started using LabVIEW. I never embraced them and believe that there is a better alternative in virtually every case you can thinnk of using them.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 22 of 26
(813 Views)

"If a LV2 global only has read-write functionality, it's not any better than a global."

I am only trying to write values into global variables and them read them in other VIs. According to the quote above, It wouldn't make a difference in this case whether I used global variables or LV2 globals?

"In my opinion, the only good use for Globals is as a Constant (read only)."

Assuming that is true, then global variables cannot be relied on as actual "variables"?  So it shouldn't be used as a "variable", but only for holding constant values. That sounds like global variables are completely useless except for maybe some sort of readability or labeling?

So if I am using global variables to read and write, then I should go ahead and replace them. But if LV2 globals that only read and write are not better then global variables, then what should I replace them with?

Feel free to correct me if my assumptions are wrong.

thanks

0 Kudos
Message 23 of 26
(804 Views)

I would argue that LV2 globals are better than normal globals even for reading and writing because you can offer some data protection in them because they are implemented with in a function.  However, it depends completely on the developer to implement that.  The other major reason to use them is performance.  The LabVIEW compiler is significantly better at optimizing code when it sees how the data flows.  This can help with LV2 globals some, but it's more of an encouragement to use variables only when necessary.

Jared S.
Applications Engineering
National Instruments
0 Kudos
Message 24 of 26
(774 Views)

OK, it sounds like they are worth a try. I have seen some images of functional globals and have read about them, but is there a place where I can actually download some example VIs that use LV2 globals for reference? From the very basic to the more complex? For LabVIEW 2009?

Any links or suggestions would be greatly appreciated.

0 Kudos
Message 25 of 26
(748 Views)

Here are a few examples that I've been able to find:

 

 

  1. Basic Functional Global Variable Example
  2. Using a Functional Global Variable to Communicate with a SubVI
  3. Multi-Functional Global Variable

 

 

Jared S.
Applications Engineering
National Instruments
0 Kudos
Message 26 of 26
(719 Views)