From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shared Variables in LabVIEW 2010

Hi!

 

Its been awhile since I've messed with Shared Variables, and their inflexibility back in 2008ish lead me to just use the DataSocket server approach instead.

 

Revisiting them now for an application using LabVIEW 2010, and trying to see what has changed.

 

I'm interested in using shared variables to communicate between labview applications that run on seperate machines.  Neither machine will have the full LabVIEW development system.  They will have runtimes installed.

 

From what I recall before, I had to create two seperate shared variable libraries that mirrored each other.  One was for my "publisher" computer, and the other "subscriber" library contained variables that linked to the "publisher's" shared library.  The path had to be entered in the shared variable dialog box (which made it difficult to test on my development machine...I didn't like having to use a static computer name or IP address in the setup of these variables).

 

I also recall that I had to check if my application was an EXE and then deploy the variable libraries progmatically.  Is that still the case?  I see that there is a check box in the application build for deploying shared variables but the path names bother me.

 

Does anyone have a clean LabVIEW 2010 example for this?  The shipped Shared Variable example won't open because it says I'm missing some addin (which addin would be nice to know, but that information was not in the dialog box....).  Example I find on website is for LabVIEW v8, and I know there have been changes to Shared Variables since then.

 

Thanks for your input!

0 Kudos
Message 1 of 9
(2,934 Views)

I did some testing.  It appears that there no longer needs to be any special programming to detect if the VI is part of an application build and if it is ensure that the library containing the shared variables is deployed.  There also doesn't seem to be a need to "Always Include" the library that contains the shared variables and ensure that it is installed in a known location.  The checkbox in the Application build specifications to "Deploy the shared variables" works as expected.

 

What still seems to be needed is in the "consumer" applications running on other machines, another library with shared variables needs to be setup and configured to alias the shared variables on the "producer" application and machine.  This will work fine for the application I'm building now, but I still dislike this hard-coded network path in a dialog box.  Easy to use, but lacks flexibility.

0 Kudos
Message 2 of 9
(2,915 Views)

Hi Nickerbocker,

 

I'm glad that you've found Shared Variables in LV 2010 to be easier to use.  It sounds like you've gotten to the point of understanding it.  Here's a document that will go into more details, for your reference:

http://zone.ni.com/devzone/cda/tut/p/id/4679

 

 

Regards,

Che T.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 9
(2,890 Views)

That was a good reference article.  Thank you.

 

I have a couple of implementation questions.  This is vanilla LabVIEW 2010 development suite, mind you.

 

  • I've currently setup 2 separate shared variable libraries.  One library is for the SVE, and the other library has links to the variables on the SVE.  When my applications on the server/publisher SVE is launched, the shared variables are deployed.  When my application on a client machine is launched, does it deploy its shared variable library to a locally running SVE that links to the server/publisher SVE, or does the LabVIEW application itself do the communicating with the server/publisher SVE?
    • From the documentation, it sounds like only one SVE is requires to be running.  I'm just wondering if the way I'm setting up my application will make it use 2 or just the 1 SVE.
    • When I make installers for my server and client applications, do they both need to have the Shared Variable Engine included?
  • I'm working on an application right now that uses kind of dated hardware for the data acquisition and control test machine, and I will be monitoring/controlling remotely on my laptop.  The test machine is a Pentium D, and my laptop is a newer i7.  The Pentium D has a PCI card that I need to use as part of the setup, and I think the machine is sufficient to handle the task.  The literature you linked me to suggests I should consider the faster computer for my SVE.  However, since all the data is coming into the test computer and my laptop will just be for remote viewing and control I don't need to have every single piece of data sent to my laptop.  I just care about what are the values right now, historical trends will be streaming right to disk in parallel with the network.  In this configuration, which machine makes the most sense to be my SVE?

 

Thanks!

0 Kudos
Message 4 of 9
(2,878 Views)

So, I think I answered my first question.  The way I was linking the varibles in my code and deploying a library of shared variables in each of my applications to local machine SVEs was more overhead than I needed (and it looked like it was slower than it is now).

 

I can use the variables in a single library in both application VIs and builds.  This works if I modifity the .alias file that is created and set [My Computer] = "SVEHostComputer" on the client machines.  It makes me uncomfortable pointing an alias titled "My Computer" to another computer.  Is there a better way to do this?  Are there any cosequences?

 

The only other way I've found that works is if I right-click the shared variable and select "Replace with Programmatic Access", and then change the "My Computer" to "SVEHostComputer".  I prefer just changing the .alias file.

 

Thanks for the input.

0 Kudos
Message 5 of 9
(2,872 Views)

Another question: is there anyway to setup an interrupt driven thread for reading shared variables?  Or is polling the only option?

0 Kudos
Message 6 of 9
(2,837 Views)

Hi Nickerbocker,

 

You can do an interrupt driven.  However, it does require that you're using the DSC module.  Please see the following forum post regarding this:

http://forums.ni.com/t5/LabVIEW/Shared-Variable-event-handling-spurious-events/m-p/1526712?requireLo...

 

Also, an example can be found here:

https://decibel.ni.com/content/docs/DOC-4375

 

If you're interested in this approach, then please let me know.  I can get an account representative to contact you if you're interested in getting the DSC module.

 

 

Regards,

Che T.
Applications Engineer
National Instruments
0 Kudos
Message 7 of 9
(2,823 Views)

Thanks for your reply. The DLC module looks too expensive and I would only like to have this 1 feature from it.  I think I'll go with a polling setup for this project.

 

What about the .alias file?  Are there any unforseen sideeffects of setting the [My Computer] entry to point to another network location?  It is awfully convienant to do it this way for testing on my development machine and deploying w/ a pre-configured .alias file that points to the SVE.

0 Kudos
Message 8 of 9
(2,815 Views)

The .alias file is there to resolve logical target names in NSV URL's.  The only potential problem would be if you also want to have locally hosted NSV's in which case you would need to

modify the default target name to something unique since it will also be named [My Computer]. 

It is too bad that NI requires you to purchase the expensive DSC if you only want NSV events since actually that capability is built into the SVE but LabVIEW does not exposed that functionality.

In CVI you can access those events right out of the box.  I imagine that someone who knows CVI could create some sort of wrapper that could setup and trap NSV events and then trigger a LV occurance or even better a LV user event.

0 Kudos
Message 9 of 9
(2,774 Views)