Reading Shared Variables with the Same Name Deployed to Multiple Targets

Updated May 23, 2018

Reported In

Software

  • LabVIEW Real-Time Module

Issue Details

I have deployed a single LabVIEW real-time project to multiple real-time targets. Because the same project was deployed, I have also deployed shared variable libraries with the same variable names to each target. When I use a host interface to read the shared variables published on my network it is apparent that the the value of any given shared variable is switching back and forth between the various targets randomly. How do I ensure I am reading a variable from the target I expect?

Solution

You can read and write shared variables programmatically with the Publish-Subscribe Protocol (NI-PSP) shared variable functions. Using the Search Variable Container Function , specify the IP address of the real-time target you are trying to a read a shared variable from as part of the container refnum in input, which will ensure you are reading the shared variable from the target you expect.

Format the container refnum in input as follows:
 
ni.var.psp:/'/XXX.XXX.XXX.XXX'/'Library Name'/'Variable Name' 
 
Where XXX.XXX.XXX.XXX is the IP address of your real-time target on the network, 'Library Name' is the name of the shared variable library as it appears in your LabVIEW project, and 'Variable Name' is the name of your shared variable.

Additional Information

Reading and Writing Shared Variables Programmatically in the LabVIEW 2017 Help Manual outlines an example of this code architecture. 

WAS THIS ARTICLE HELPFUL?

Not Helpful