Skip to content
Home » Blog » Using Local Variables in LabVIEW Real-Time (RT)

Using Local Variables in LabVIEW Real-Time (RT)

Skills: Solution Architecture · PLC Programming · Test Automation · LabVIEW

LabVIEW, renowned for its versatility in data acquisition and control systems, offers a powerful tool – the local variable (front-panel indicator) – for seamless communication and control between parallel process loops within the same VI. This article delves into the applications, features, and considerations of utilizing local variables in LabVIEW Real-Time (RT).

Applications and Use Cases:

  1. Intra-VI Communication:
    • Employ local variables for effective communication of data, control signals, and status updates between parallel process loops within the same VI (VI-scoped).
    • Facilitate the availability of the latest variable values to other process loops.
  2. Parallel Loop Termination:
    • Utilize local variables to synchronize and stop multiple parallel loops simultaneously using a single “Stop” button.
    • Features tag-based communication for conveying the latest value of a variable.

Key Features:

  1. Front-Panel Indicator Storage:
    • Local variables store values in front-panel indicators, enhancing clarity and accessibility.
    • Tag-based communication ensures the latest variable values are communicated between loops.
  2. Easy Implementation:
    • Straightforward coding procedures make local variables accessible to LabVIEW users at varying skill levels.
    • Supports multiple clock domains, accommodating both timed loops and conventional loops.

Considerations:

  1. Creation Limitation:
    • Local variables can only be created from front-panel controls and indicators.
    • Rapid changes in one process may lead to missed updates in another; implement adequate handshaking or ensure signal duration.
  2. Global Variables for External VI Communication:
    • For communication with process loops in another VI within the same RT target, consider global variables.
  3. Stop Button Configuration:
    • Adjust the mechanical action of the stop button to “Switch When Pressed” or “Switch When Released” for compatibility with local variables.
    • Post-loop execution, write a “false” value to reset the stop button to its default state.

LabVIEW Block Diagram Elements:

Locate these elements efficiently with “Quick Drop” (press Ctrl+Space and start typing the name):

  • Local Variable
  • Feedback Node

Example Code:

Follow the provided example code for a hands-on experience. Connect your Academic RIO Device to your PC and run the “RT Main” VI. The example demonstrates the synchronization of two process loops using local variables, with a detailed developer walk-through available in the provided links.

Conclusion:

Mastering the use of local variables in LabVIEW RT opens doors to enhanced communication and control capabilities within your applications. As you explore the provided example, grasp the nuances of intra-VI communication and efficient parallel loop management. Incorporate these techniques into your projects for optimized LabVIEW Real-Time programming.