LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shared variable has no value error

When I attempt to read a shared variable that is hosted on my computer from a VI running on a PXI w/ real time I get the "Shared Variable has no value error".  If I read the shared variable in a loop, I eventually get the correct value (after a couple of seconds or so).  There is a VI on the host which I run, before running the VI on the PXI, that writes to that shared variable so it seems to me that there should be a value when the VI on the PXI runs (and there is after a couple of seconds).  Why is the value not available on the first read?
 
Thanks,
Kevin C.
0 Kudos
Message 1 of 6
(5,286 Views)

Hello Kevin,

This warning comes up if the data source your variable is bound to has not sent a value back to your RT controller yet.  Here is an excerpt from a knowledge base article:

"This warning will occur if the shared variable is bound to a source, but the variable has not received a value from the source. This is only a problem if the variable never receives an update from the source, even if you are sure the source is generating updated values. In most cases you can ignore this warning."

Since it may take a few seconds for the variable to connect, you may want to just poll the shared variable in a loop and wait for it to connect before your main program starts.

-Justin D

0 Kudos
Message 2 of 6
(5,268 Views)

Hi Justin,

Thanks for the response.  Could you post the link to this knowledgebase article.  Couple questions about terminology in your post.  When you say "the data source your variable is bound to", are you refering to the "data source" as the shared variable and the "your variable" as the instance of that shared variable on the block diagram which gives me the warning?   

Also, couple other questions:

When does this "connection" start?  Is it when the VI which reads the shared variable starts to run or is it after the first attempt to read it? I know that the variable has a value since the VI running on my host PC writes to it and this VI is run before the VI which runs on the PXI box and reads it.

Is there some default time that I should wait for this warning to go away before I declare it to be a problem?  The excerpt says that its only a problem if the variable never receives an update, but how long would I wait before I know that it will never receive an update?  I know this sounds like a silly question but it seems odd to me that the read of the shared variable would return with this warning.  If there is some processing that takes place to "connect" then it seems to me that the read shouldn't return until its connected or some timeout occurs.

Is this warning something that could occur after a successful read?  For example, if I looped until the warning went away and then began using the variable, could I ever see this warning again such that I should not ignore it?

Again, thanks for the response. 

Kevin

0 Kudos
Message 3 of 6
(5,263 Views)
Hello Kevin,
 
The knowledgebase article that I got this quote from is one that we have taken off the web temporarily while it is being updated.  I'm not sure how long this will take but once it is back online it will be at this address:
 
 
When I talked about the "data source" the variable is bound to, I was referring to whatever path is specified in the shared variable properties window under the "Bind to Source" checkbox.  "Your variable" is whatever variable you are reading on your block diagram.
 
If you have everything in one project, you won't have an explicit data source like I've explained above.  It the variable is hosted on the Windows side (that is if the library is deployed on the Windows machine), the variable reads on your PXI RT code are implicitly bound to your Windows variables.
 
The "connection" starts when you start your realtime code.  Your variables in the Windows code do not know that your RT code is going to read from the shared variables.  It is up to the shared variable engine running on your PXI target to request these values.
 
I agree that it doesn't really make sense for the shared variable read to return without a value.  That being said, since this is how the shared variable works, it's a good idea to read from the shared variable in a loop before your main program starts until the warning goes away.  I think it would be reasonable to wait for 5 seconds before timing out with an error.
After the variable on the RT target starts reading from the data source it should never throw that warning again.  If it doesn't receive a new value it will just give you the previous value that you read.
 
Regards,
Justin D
0 Kudos
Message 4 of 6
(5,248 Views)

Hi Justin,

Thanks for the response. 

So I assume that this initial loop would need to be done for all of my network published shared variables.  That is any network published shared variable that I read from that is not hosted on the machine from which I am reading will have to go through this loop??

Thanks,

Kevin C.

0 Kudos
Message 5 of 6
(5,233 Views)
Hi Kevin,
 
It all depends on what your shared variables are bound to.  If all of your shared variables are bound to data items on 1 computer or 1 PLC, I would say that looking at one of your variables in a loop would be enough.  However, if your variables are bound to a variety of sources you would most likely want to check one variable from each data source.
 
Regards,
Justin D
0 Kudos
Message 6 of 6
(5,185 Views)