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.
The second method was to Enable Aliasing on each shared variable and bind it to the appropriate I/O channel.
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?
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.
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
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...