From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shared Variables Bound to Indicators

I am having some issues with front panel indicators that are bound to shared variables.

 

Writing to shared variable node seems to write to the SVE every time it is executed, where writing to a bound indicator seems to only write when the value changes. Is this by design ?

 Writing when data changes is more desirable from a network overhead point of view, espeically when you have data that doesn't change very  fast.

 

The writing seems to work ok, but if I try to read the local variable who's indicator is bound to a shared variable, The local variable doesn't seem to get populated with the latest value of that Shared variable. But strangely the indicator on the front panel updates correctly.   

 

Is this to be expected on a real time device?

It seems to populate correctly on a Windows PC.

 

 

I may not be going about this the best way.  I need to use shared variables to pass data from a real time device to a Windows PC. I really only need the Data to the Computer when it changes,  which will be a lot less frequent then the scan rate of the real time device.

 

Any suggestions?

 

Chris

 

 

 

 

0 Kudos
Message 1 of 6
(2,629 Views)

@CDP_FPS wrote:

I am having some issues with front panel indicators that are bound to shared variables.

 

The writing seems to work ok, but if I try to read the local variable who's indicator is bound to a shared variable, The local variable doesn't seem to get populated with the latest value of that Shared variable. But strangely the indicator on the front panel updates correctly.   

  


It sounds like you've written yourself a race condition where the local variable is reading the terminal before the shared variable is written.  A pretty clasic bug to find when you break dataflow.  But we can't be certain without some code to look into.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 6
(2,619 Views)

Attached is some simplified code outlining my issue.

 

IF the shared variables are changed via system manager, the local variables are not updated with the new variable. However, if the control is changed in the vi, then both the Shared Variable and the local variable get updated properly.

 

 

Thanks.

 

 

0 Kudos
Message 3 of 6
(2,613 Views)

There is one thing that bothers me about this.  why would you create a local variable for an indicator bound to a shared variable ?(much saner to use the shared variable directly I think) 

 

Doing so implies a binding from the locals of an object to the shared variable and that would really mke debugging hard.  In other words, This might just be desireable behavior!  The real question is why did the compiler allow you to do that to yourself?


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 6
(2,603 Views)

Well when you drag and drop a shared variable to the front panel (creating an Indicator that is bound to a shared variable), the local variable is created at the same time. Maybe using this local variable was not the intended operation.

 

I normally would have used the shared variable node directly, but I was experimenting.

I have used the shared variable nodes directly in previous projects, but we have noticed that if we write to a shared variable in the code every scan,  ( lets say the shared variable represents the status of a switch from a digital input) then the data is written to the SVE every Scan.  We have found if we write to a local indicator that is bound to the shared variable, the data is only written to the SVE when the data changes.

 

There is probably a cleaner way to accomplish this. I suppose, I could use some logic and only write to the shared variable when it changes, and remove these local indicators that are bound to the shared variables. 

 

I was attempting to reduce unnecessary the overhead on the network/SVE, but this may not be nessarry on small to mid size projects. 

 

Any other suggestions ?

 

Thanks

 

 

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

Well when you drag and drop a shared variable to the front panel (creating an Indicator that is bound to a shared variable), the local variable is created at the same time


Well that tells you how often I use databinding in automated test systems so I'm learning as we go too....

 


           We have found if we write to a local indicator that is bound to the shared variable, the data is only written to the SVE when the data changes


Just as the help file prophets state.....and a darned good reason for using databinding.

 

I'll track the thread and try not to run you down the wrong alley.   I'm pretty much out of suggestions.

 

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 6
(2,592 Views)