From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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 Variable Alias vs Programmatic Assignment, which is better?

Hello,

 

I am programming an application for a cRIO platform using the scan engine in LV2009SP1.  I'd like to use the cRIO as a standalone controller, and only connect a computer to it occasionally to download data.  I decided to do this using shared variables.  So far I've been successful at doing this in two ways, both involved creating nearly identical sets of shared variables on the cRIO and on the PC, which I think (correct me if I'm wrong) I understand is the way it should be done.  The differences are the following:

 

The first method was to create a parallel loop on the RT VI which would assign the values passed through the shared variables to the individual I/O channels.

 

17989i32B4B9200AC43D1B

 

The second method was to Enable Aliasing on each shared variable and bind it to the appropriate I/O channel.

 

17987i781A47D29A34019C

 

After deploying the RT code to the cRIO for each case and running the UI on the PC, I noticed that both worked, however, the second method showed a short lag between command and feedback (~200ms or so).  The test I ran was to wire an analog output to an analog input, command the AO, and read back the value on the AI.  I can deal with the delay on the UI since it's only for reference - what I'm really interested in is the data that's logged on the cRIO controller.  My question is:  Is one of the two methods better or more appropriate than the other?  Is there something even better?

 

Thanks,

 

-NS

 

 

0 Kudos
Message 1 of 3
(3,251 Views)

 


@No Substitute wrote:
I decided to do this using shared variables.  So far I've been successful at doing this in two ways, both involved creating nearly identical sets of shared variables on the cRIO and on the PC, which I think (correct me if I'm wrong) I understand is the way it should be done.

 

Hi NS,

 

No correction necessary.  These are both valid ways of sharing data between your Real-Time controller and your PC.  Here's a forum that discusses some similar options to accomplish the same task (
Shared variable architecture for distributed crio system)

 

Regarding the latency issue with method 2, take a look at KnowledgeBase: Why Is Accessing IO Variables Through The Shared Variable Interface So Slow?

 

I hope this helps!

 

- Greg J

Why Is Accessing IO Variables Through The Shared Variable Interface So Slow?

0 Kudos
Message 2 of 3
(3,230 Views)

Thanks for your repsonse, Greg.  The article about the lag of the Shared Variable Interface is interesting.  I will look more into their recommended way of opening and closing connections to IO variables. 

 

There's something else I will try also: reducing the period at which the system updates network-published variables.  I'm not sure what effect this might have, or what the value is currently set to, but I can check next week...

0 Kudos
Message 3 of 3
(3,195 Views)