LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatic Access to network published shared variable - Knowlege Nugget

Wanted to Share a coding problem I have just resolved:

 

Proframatic Shared.png

 

I have been trying to debug the code above.

It worked for one device and not the other (Identical devices: DevA,DevB)

 

It has been throwing an error, unable to access variable.

I resolved the problem by changing by changing the timeout to something > zero

 

Hope this helps future travellers

 

This seems onlt yo be a problem during the first connection to the variable,

Subsequent reads don't seem to need it.

 

It is almost as though it needs time to troll through the project shared variable database to finde the reference the first time through.

 

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
Message 1 of 19
(3,071 Views)

Appreciate that you came forward to share your solution. It will be really helpfull if we get to know the reason behind this. I believe these things can be collected to a seperate board as I suggested earlier here

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 19
(3,070 Views)

I noticed this a few years ago when I was doing some real-time work.  My solution then was to perform a read of all of the shared variables as part of the initialization.  I think I only had this probelm with Network Shared Variables.


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 19
(3,040 Views)

Since I don't use shared varibales I have to ask...

 

Is there a timestamp returned that reveals the state of the variable?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 19
(3,036 Views)

Ben

 

I didn't look at the timestamp but it throws an error.

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 5 of 19
(3,015 Views)

I would also like to start a discussion about how I think programatic NPSV works.

 

When I access a variable on another device, I construct a string using the device name (in the Project) followed by the variable name.

 

The "MAX" Name is not relevent.

 

So... It follows, that any code I compile must have a lookup table for the shared variable libraries in all project devices, referencing their IP Addresses.

 

If I compile an .rtexe, does this information reside in the .exe or is there an extra file (perhaps the aliases file) where this information is stored?

 

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 6 of 19
(3,006 Views)

Answering my own question:

 

Contents of an aliases file:

----------

[GWB]
GWB="192.168.1.36"

[GWB-Munted]
GWB-Munted="192.168.1.41"

[GWB2]
GWB2="192.168.1.38"

[MasterController]
MasterController="localhost"

[MESy-BC1-192-168-1-39]
MESy-BC1-192-168-1-39="192.168.1.39"

[My Computer]
My Computer="192.168.1.99"

[Remote Controller]
Remote Controller="10.30.203.37"

[Simulator]
Simulator="192.168.1.48"

[TWB]
TWB="192.168.1.35"

[TWB-Munted]
TWB-Munted="192.168.1.36"

[TWB2]
TWB2="192.168.1.37"

 

-------

 

This is how it does the lookup!

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 7 of 19
(3,001 Views)

@Ben wrote:

Since I don't use shared varibales I have to ask...

 

Is there a timestamp returned that reveals the state of the variable?

 

Ben


The timestamp is only available on the reads.  It returns the timestamp of when the variable was written to.

 

One more thing to watch out for (we recently got bit by this).  The NPSV is actually written to a buffer (8kB?).  The variable is published either when the buffer is filled or 10ms has passed.  There is a command to flush the buffer to avoid this 10ms delay.

 


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 8 of 19
(2,980 Views)

Ben,

 

Thanks for the 10 msec Nugget,

 

I was already aware of this but great to include it in this nugget, I can afford 10 mSec Latency for my application.

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 9 of 19
(2,965 Views)

Timmar,

 

I've been using action engines (AE)  to handle programatic access to NPSV's.  I use the Open and Verify Connection when the program first starts to get things rolling and then store the refnum.  This allows me to get all the overhead done first.  After that I use normal read/write.  Sometimes I have an AE per variable, sometimes I use the same AE to access many NPSV's and store an array of refnums.

Message 10 of 19
(2,951 Views)