LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview sharing global variables (using tcp?)

Hello everybody,

 

 I need to produce a tool for an external machine which has to initialize an hardware then communicate with it.

 

The machine runs its own software and just calls my executables, one for initialize and one for communication. 

I cannot do all in the same EXE since the machine has to perform some operations between initialization and communication.

 

Unfortunately, the initialization VIs that I have use Global Variables to keep initialization data.

This means that everything works properly in Development Env, but when I build the executables I can't communicate since the global variables belongs (I think)  to a different context and it seems the hardware was not initialized...

 

I've read some sections of the forum and it seems I can use TCP to communicate between executions.. Could somebody explain me how?

Can I use different solution? It occurs rarely for me to build applications, so maybe I'm not very expert in this.

 

Many thanks,

Denise

0 Kudos
Message 1 of 7
(3,317 Views)

If you use network-published shared variables instead of single-process globals you will be able to read the values over the network. This is the simplest way of doing it and works fairly well if you just want to read the current value of various variables (e.g. as a tag/snapshot of the values).

 

Of course, if you want to get more complicated you can:

- Use network streams to stream LabVIEW data over TCP/IP

- Use raw TCP/IP (end-to-end connection) or UDP (can do UDP broadcasting) to transmit data over the network


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 7
(3,307 Views)

Just to be clear, the Initialize and the Communications executables are both running the entire time?  If so, then just use the Network Published Shared Variables (NPSV).  If not, then you need to save the data to a file.  I would use a configuration file.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 7
(3,297 Views)

Hello crossrulz,

I'm afraid I will need this file, since the inizialization does not run the entire time..

 

Thank you both for your answers!

0 Kudos
Message 4 of 7
(3,209 Views)

denise78 wrote:

The machine runs its own software and just calls my executables, one for initialize and one for communication. 

I cannot do all in the same EXE since the machine has to perform some operations between initialization and communication.

 


Why can't you?  There are options to both wait and to call other things using the command prompt (system exec) in LabVIEW.  Why wouldn't you build your VI, and later executable, such that it runs the initialization task, calls the other operations (or waits if that's all you're doing), and then starts the communication?  Wouldn't this be easier than the balancing act you're trying to accomplish now with multiple EXEs to perform the same task?

0 Kudos
Message 5 of 7
(3,180 Views)

You can still use Network Shared Variables even if Init.EXE and Compute.EXE run not at the same time.  The key is where the variables are hosted -- if they are hosted on your PC, then they "live" there, retain their values, and can be read and written by Init and Compute at will.

 

That having been said, it is certainly easier to use Windows to browse to "My Settings.ini" and use Notepad to read the file, examine the settings, then change them (and easier to tell a colleague how to do this) than to go looking for NI's Distributed Systems Manager to examine NSVs.

 

Bob Schor

0 Kudos
Message 6 of 7
(3,176 Views)

In fact this is the solution I adopted in the end, since nothing else worked.

Shared variables seems not to be available in LabVIEW 7.1 (I am working on an old product) and I had no idea about how to do with TCP..

 

So I built all in the same exe, it initializes, it waits and then it continues, and it seems working in the development machine.

 

I used external files to perform syncronization.. yes, it was the simplest solution.

 

Thank you,

Denise

0 Kudos
Message 7 of 7
(3,133 Views)