12-11-2012 01:46 PM
@jdeters79 wrote:
Lynn,
Disregard my last message. Should've actually put some effort into figuring it out before posting. I figured out how to make it work using a local variable.
Again, thanks for your help with the parallel loop issue!
Jordan
This is a great opportunity to learn about queues.
12-11-2012 03:16 PM
Jordan,
Bill is right. A queue is a better choice than a local variable.
Lynn
12-12-2012 01:37 PM
From what I've read, it seems that the queue is a more reliable way to pass a variable when rates are high. In my case, the data I'm sampling is 5Hz/6Hz, thus is it really necessary? Are your recommendations strictly "best practices"?
One thing that is somewhat confusing, I was looking at the 'Queue Basics.vi' example and see that they pass the elements from the queue in one loop to another loop using a local variable? Where or what is the benefit to the queue? I've obviously demonstrated my LabView experience level in the previous posts, but the example does not really explain the benefit of the queue.
Thanks,
Jordan
12-12-2012 02:15 PM
Jordan,
You are right. That example does a poor job of explaining what it is doing. The side by side top loops demonstrate how the queues work. Notice that when the Dqueue Speed is slower than the Enqueue Speed, the Elements in Queue indicator will fill up and then the Inserted and Removed charts no longer show the same data.
Stopping the upper loops on error is easy but may result in loss of data. If you run the VI at the higher speed and look closely after stopping you will see that the last element Inserted often does not show up on the Removed chart.
The bottom loop is a "monitor" to show what is going on in the queue loops. One of the major problems with local variables is the possibility of race conditions. It is possible that the local variables in the bottom loop are read the first time before any data has been written to the indicators in the upper loops.
So, yes, in a way this is a best practices issue. But it is important to remember that the data is not held in the controls and indicators; it is in the wires. The (poorly named) local variable is a copy of the data in the indicator and not a pointer to the data in the wire.
About the only recommended use for local variables is setting controls programmatically, at startup for example.
Lynn