Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Nov 27, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

Improving Determinism with Functional Globals, LabVIEW 2-Style Globals, in LabVIEW Real-Time

7 ratings | 3.00 out of 5
Print
Using global variables in time-critical priority VIs in LabVIEW Real-Time can compromise determinism. A global variable is a shared resource. If one piece of code accesses a global variable, no other piece of code can access the global variable until the first piece releases the global variable. When you block the access of a time-critical VI to a global variable, forcing the time-critical VI to wait, you introduce jitter to the application and compromise the determinism of the application. You can avoid this behavior by using a Functional Global, setting it to subroutine priority, and selecting the Skip Subroutine Call if Busy option for it. With a Functional Global, the time-critical VI does not have to access the global if another section of code is already using the global. You avoid the delays caused by accessing standard global variables.

A Functional Global, also called a LabVIEW 2-Style Global, is a VI that uses a loop with uninitialized shift registers to hold global data. Figure 1 shows an example of a Functional Global.

Figure 1: Functional Global Variable

A Functional Global usually has an input parameter that specifies the VI function, such as writing or reading. Refer to LabVIEW Help: Suggestions for Using Execution Systems and Priorities (linked below) for more information on functional global variables.

You can set Global.VI to subroutine priority by right clicking on the icon on the top right hand corner. See the link below for more information on priority settings in LabVIEW RT. You can then select the Skip Subroutine Call if Busy option for the SubVI in the time-critical loop, as shows in Figure 2.


Figure 2: Calling the Functional Global from the time critical loop

Remember that when LabVIEW skips a subVI, the default outputs are the default indicator values.

Related Links:
Functional Global (LabVIEW 2-Style Global) for Increased Determinism.
Understanding priorities in LabVIEW Real-Time applications
LabVIEW Help: Suggestions for Using Execution Systems and Priorities

7 ratings | 3.00 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).