LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Initializing Shared Variables

Hello -

 

I have a labview program setup to control a number of slave computers through a single master over a network switch. The main program uses events and reference VI functions and is working properly but I would like to include a few shared variables where the slaves write and master reads. I have read through the Labview introduction to shared variables and played around with the "Shared Variable Client - Server" project example but am still missing something.

 

How do I ensure a connection between the shared variables on the master to the shared variables on the slave? I have made sure to include the slave computers in the shared variable engine in the Tools/Options menu. I have also attached the sub-VI that is used to read and write to the shared variables for the master and slave computers, respectively, but do not know how helpful it will be without the rest of the project (too large to add to this post).

 

I have gotten the shared variables to connect by binding them to the slave computer shared variables but would prefer not to use this as pragmatically binding the variables seems inefficient. Datasockets would probably work for me, but after looking through the example, specifically Variable API Client.vi, it seems as though I should be able to get this working without opening and closing the shared variables. Any advice is appreciated.

 

Thanks,

Jeremy

 

LabVIEW 2009 SP1 / Windows 7

 

 

0 Kudos
Message 1 of 8
(4,786 Views)

First off NSV's are not guarenteed to be lossless.  If you need to preserve every image frame then you will need some sort of image index to check or a handshaking mechanism.  Otherwise, your example should work.  You  have a SV server that is hosting all of your image NSV's.  The clients write to these variables via static NSV nodes.  The NSV URL's can be IP absolute or project relative in which case they are resolved via the .alias file that will be adjacent to your exe.    Once your NSV's are deployed on your host then they are transactional for anybody on the network.  Just check the error out of any nodes to see if there was a problem.  BTW, I find NSV binding to be very efficient.  Also, with bufffering, you can have a timeout on your NSV's that can be used to reduce your polling.  FYI, In LV 2010 imaq images are native data types in NSV's.  Also in 2010 lossless network streams are available.

0 Kudos
Message 2 of 8
(4,775 Views)

Image loss isn't a significant factor for this aspect of the program. However, I am still having a problem with connecting the slaves and master. I will run the program on the slave and master, which I know are networked properly on the same subnet since the event triggering works, and receive an OK with the error code 180121602 saying the NSV buffer is empty and the array it gives me is the last known value. I have verified that the images are being sent to the SV by reading the SV in the main VI after writing to the SV in a sub VI.

 

Is there anything else I have to do with the SVE other than adding the slave computer names into the "time server search order"?

 

Thanks again,

Jeremy

0 Kudos
Message 3 of 8
(4,762 Views)

The way I have used Shared Variables (SV) is by having the program that writes the variable deploy it. I configure the variable to be network published with aliasing unchecked. Then, I deploy the variable and go over to the program that reads the SV. I configure the variable to be network published again with aliasing checked this time. I browse to the PSP address of the deployed variable and read from it.

 

When I am having trouble, I restart the SVE by going to the command line. (accessible from "start menu -> run" and typing in "cmd")

To restart it I issue two commands:

net stop "national instruments variable engine"

net start "national instruments variable engine"

 

I hope this helps, shared variables are new to me too!

0 Kudos
Message 4 of 8
(4,751 Views)

Thanks for the input. I have gotten the variables to work by binding them (aliasing and binding to a PSP URL) but unfortunately the solution needs to be programmatic. There is a way to bind the variables programmatically but I have not had much success on this front. I have attached the basic VI for programmatic binding if anyone has any idea why it would not be working.

 

Thanks,

Jeremy

0 Kudos
Message 5 of 8
(4,734 Views)

You may need to enable binding in the SV properties dialog, also specify the binding type (absolute or project)  then put in a dummy URL which you should then be able to change

programmatically.  Keep in mind that there is no reason you need to have an alias or binding to do what you want.  I have many systems running that host NSV's on one target and can R/W on any other target on the network.  Have you tried looking at the NSV in the distributed system manager?  You should see what data it currently contains and the actual URL it is located at.

In your client, you can probe the NSV node and see its URL to make sure it matches.  Remember, if you are using a computer name instead of a IP address then you will need to make sure your .alias file contains the correct mapping.  Also, you do not need to do any of that registering the computer stuff...

0 Kudos
Message 6 of 8
(4,724 Views)

I looked into some of your suggestions and can report back the following.

 

 - After looking into the DSM I can find the SharedVariableLib.lvlib with the list of shared variables (Image1, Image2, etc.) for each computer on the network. The value doesn't update (due to size I'm guessing) but the timestamps on the SVs being accessed by the slaves does update. None of the timestamps of the SVs on the master computer update.

 

 - So I'm guessing the problem is that each computer has it's own library and there isn't a single one of the network. I would prefer not to have separate programs for the slaves and the master though, I just use a configuration button now to assign master and slave control. Would there be a way of syncing the libraries or disabling the slave libraries? I could also make the slaves write to controls and bind shared variables to the controls if that might work better?

 

 - I tried adding the computer names with IPs to the alias manager but this did not change the actual .alias file. Is this something I should do manually? If so, what is the format? Right now mine looks like this:

 

[My Computer]
My Computer = "192.168.4.5"

 

[NI-cRIO9014-0143535B]
NI-cRIO9014-0143535B = "192.168.80.108"

 

 - Also, I played around with the programmatic binding vi. The variables work fine when I bind them manually. If I programmatically bind them, the binding changes but nothing happens until I redeploy the library. However, when the library is deployed is when the shared variables stop working.

 

Thanks,

Jeremy

0 Kudos
Message 7 of 8
(4,693 Views)

I am not sure I am following you...

Generally, one computer, will host the NSV's.  The rest of the targets on your network will have access to these variables either with static NSV nodes or using the SV API.  You could also have 'mirror' libraries on each target that are bound to the host library and then your NSV nodes on each remote target will transact with there own local SVE which is handling the PSP transfers for you.  BTW, you should not need to use the alias manager.  If your .alias file contains the correct mapping then you are good to go, otherwise manually edit it with the proper IP address and restart your target.

0 Kudos
Message 8 of 8
(4,689 Views)