Example Code

Read Shared Variable programmatically creating the URL in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

 1. Overview:
This VI programmatically creates URL based on customer target selection and reads shared variable using Read Variable.vi and the URL created. 

 

 2. Description: 

In LabVIEW 2009 we introduced the Shared Variable Palette to give you a little more control of your shared variables.

In this code the URL to the shared variable is built by concatenating strings together.  The URL starts with "ni.var.psp://".  Then we add on the IP address of the computer or real-time target that has the shared variable library "xxx.xxx.xxx.xxx".  Then we give the name of the library followed by the name of the variable.  So in the end we have "ni.var.psp://xxx.xxx.xxx.xxx/Name of Library/Name of Variable".

This code assumes that you have three different targets on your network with the IP addresses of 10.110.1.41 and 10.0.110.41, and your localhost.  All of those targets have a shared variable library named "Untitled Library 1" that contains a variable named "Test".

 

 3. Requirements

  • LabVIEW 2012 (or compatible)

 

4. Steps to Implement or Execute Code

  1. This code assumes that you have two different targets on your network with the IP addresses of 10.110.1.41 and 10.110.1.42 and your localhost. All of those targets have a shared variable library named "Untitled Library 1" that contains a variable named "Test"
  2. Run the VI
  3. Select the target
  4. If the variable selected is being updated, the value in data out should be updated with the same value.

 

5. Additional Information or References

If data out is not updated properly, check the value of the variables using the Distributed System Manager.

 

 

 VI Block Diagram

 Block Diagram.png

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Justin Parker
National Instruments
Product Support Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.