LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass a global variable between computers

Hi,
    I have two VI's that run on different computers.  They both use the same global variable vi.  They both change and read from the file as well.  The two computers are networked together, but putting the global vi on the network and having the two VI's read from it does not work, they do not update.  I assume because they are using the global stored in memory rather than the updated one.  I am still new to Labview and just as new to networking in general.  So anything is great.  If it is not possible to pass the information this way, I am open to other suggestions as well.  Thanks.
0 Kudos
Message 1 of 6
(3,666 Views)
In terms of different machines, global variables are of no use. As you mentioned they are stored in each machine's memory. different copies.
 
Let we see. there are two VIs on different machines. so you have already used networking features and what you need is just one copy of global variable data accessible by both VIs.
 
if I ignore race conditions (You must not. See LV user manual for details about race conditions on Globals and see if you will face it. It is very very important and may impact yout whole solution) the easiest way is Data Socket Server (DSS). Run DSS server on both machines and keep only one copy of your globals on one of machines. use that global on the host machine as you used it before, and in the other machine use DSS read/write commands to access the global on the other machine.
 
I guess you even don't need any globals when you find that making variables global, will not help in connecting two computers.
Message 2 of 6
(3,654 Views)
Thanks for the response.  I am not familiar with DSS at all.  After some playing around I understand what you mean by running the servers on each machine.  But when I try to read/write nothing happens.  Is there any kind of example I can look at?
0 Kudos
Message 3 of 6
(3,638 Views)

you can see examples under help>>find examples and then in the search type in datasocket.  This will show you the examples that can help you.  When running these examples you must still run the DSS (datasocket server)  this should be under start button>>program files>>national instruments>>data socket>> data socket server.  There is also a help file for the server.  Check it out  Hope this helps.

BJD1613

Lead Test Tools Development Engineer

Philips Respironics

Certified LV Architect / Instructor
Message 4 of 6
(3,620 Views)

look at these.

BJD1613

Lead Test Tools Development Engineer

Philips Respironics

Certified LV Architect / Instructor
Message 5 of 6
(3,618 Views)
Let us select the best solution first. See "Networking in LabVIEW" chapter of LabVIEW user manual (a pdf file in manuals folder, lvuser.pdf or you can call it from LV bookshelf). Choose between DSS and VIserver. This is not so difficult that it may seem at first. you will find adequate explanations there for choosing between them.
 
See DSS and VI server examples as BJD said, but I strongly encourage you to see the manual too, because trying to write your code by modifying examples will lead you to use a certain method. for example you may find it more useful if you use DSS by just adjusting controls and indicators parameters of the front panel. (right click a control>> data operations>> data socket connection ) but if you start by modifying an example it may result to a lots of programming time and lack of performance for your special case.
 
 
 
 
Message 6 of 6
(3,601 Views)