LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I read/write data b/w two executables in the same project using shared variable?

Hello, 

 

I wish to read & write data between two different VIs in the same project (e.g. b/w My Computer for data reading & myRIO or Industrial Controller for data writing)

 

What have I done until now is, 

 

1. Create "lvlib" and shared variable under that library.

2. In  the Shared Variable Properties window;

    2.1. Network -> Check "Use Buffering" & "Single Writer"

    2.2. RT FIFO -> Check "Enable RT FIFO" and Select FIFO Type "Use network buffer configuratio(available ~ )"

3. In RIO's executable, I create that shared variable and select its access mode as read so that it can read the data I want to share with the other executable

4. In My Computer's executable, I create the shared variable and select its access mode as write

 

/** I selected both share variable in each executables as the one in the RIO's and I run both executables in RT loop with 1kHz sampling frequency **/

 

However, when I run both executables, I can not read(e.g. plotting) the data (from RIO's executable) in the My Computer's executable.

 

I found some links to solve this problem, but I'm not sure exactly what should I do step-by-step.

 

According to following URLs, Communicate Between Multiple LabVIEW Executables Using Shared Variables

 

I guess I need each separate "Build Specification" in My Computer and RIO (which is already done when the project was created I guess?)

 

Also, I tried to deploy the shared variable. But I'm not sure if I'm doing right.

 

After I right clicked the "Build Specification-New-Real-Time Application" and checked "My Real-Time Application Properties" window - [Source File Settings] Tab,

 

I set "Destination" as "Support Directory" and clicked "Build"

 

Then, some warning popped up saying "You did not specify any startup VIs. Select a startup VI before building the application."

 

This is what I have done until now.

 

Should I go to the [Source Files] tab and choose my executable VI as startup VIs and build first? and then back to the [Source File Settings] tab and do the same process again?

 

If I'm right, what should I do after those tasks?

 

What I want to know is exactly what should I do step-by-step in order to read & write b/w two different executables in the same project using shared variable.

 

Also, I want to know if should I select shared variable as the one in the "My Computer(read)'s variable" in the "RIO(write)'s executable" and the other one in the "RIO's variable" in the "My Computer's executable" (I mean select those variables in cross for each executables)

 

or should I select shared variable as the one in the "My Computer(read)'s variable" in the "RIO(write)'s executable" and also the other one in the "RIO's variable" in the "RIO's executable"

 

I have less knowledge, so my questions might heard ambiguously. Sorry about that.

 

I would appreciate if you understand my questions and share your experience & knowledge about it.

 

If you don't understand my question, please let me know about the point. Then I'll try to give you more details.

 

Sincerely.

0 Kudos
Message 1 of 4
(1,085 Views)

My general advice on Network Published Shared Variables: Don't use them.

 

NPSVs are slow (try writing a a NPSV and then immediately read it, you will read the old value because the write buffer didn't update the server yet), unprotected (anybody on the network can write to the variable), and I have nothing but issues with them.  Instead, use direct TCP message communication to pass data back and forth.


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 2 of 4
(1,058 Views)

Dear crossrulz,

 

Hello, thanks a lot for your reply.

 

Oh, I never noticed the possibility of those issues. I'll try your recommendation.

 

Again, I sincerely appreciate for sharing your insight

 

Best regards,

0 Kudos
Message 3 of 4
(995 Views)

> I can not read(e.g. plotting) the data (from RIO's executable) in the My Computer's executable.

Try to turn off firewall completely (or at least allow lkads.exe, lktsrv.exe and tagsrv.exe to pass through).

 

> My general advice on Network Published Shared Variables: Don't use them. Instead, use direct TCP message communication

Here I will slightly disagree and will say "use them when needed". Nothing is wrong with shared variables, if they used properly. It is pretty convenient and simple way to communicate between multiple applications, also across the networks (with crisp and clear understanding of all "pros" and "cons", of course). Suggestion about pure TCP required some amount of coding from both client and server sides. It is more or less easy if we have single or few variables, but if we have 30-40+ with different types, distributed across application, then solution with TCP will be not so simple. Yes, they are not very fast, because they are very similar to traditional OPC - you have NI Variable Engine (which is tagsrv.exe), and this engine holds the variables with cyclical update (around 10 milliseconds, I guess). Single Writer mode is here if you would like to block anybody on the network can write to the variable. Also NI-DSM is pretty convenient tool for troubleshooting. In the past I've used these variable in two projects and this saved for me huge amount of programming work. In one project I was able to transmit images and in another project was able to communicate with C++ application (using libraries from CVI).

0 Kudos
Message 4 of 4
(954 Views)