04-27-2015 10:09 PM
I am newer to labview, and i cant wrap my head around why a local variable wont update in code if it updates on the dashboard. Anything im missing?
Solved! Go to Solution.
04-27-2015 10:20 PM
04-27-2015 11:40 PM
Let's assume you are talking about the "Cell state" local variable. The terminal updates every 500ms in the small upper loop, The local variable just points to that indicator and thus updates equally.
The problem is "dataflow" and you need to get familiar with the concept!
Once the while loop starts, the local variable is read and the inner FOR loop starts. Most likely the local variable is read way before it gets updated in the little FOR loop, thus most likely returns a stale value on the first iteration of the while loop. Now the small FOR loop continues to iterate twice a second for about five seconds. Only after the FOR loop (and everything else inside the while loop) has completed, the while loop will go to the next iteration, at which time the local variable gets read once again, this time with the last value from the very last FOR loop itereation of the previous iteration of the while loop.
In summary, the local variable updates just fine, it's just that the code does not get around reading the new value most of the time.
Your VI is also full of potential race conditions caused by the overuse of local variable. You need to enforce proper execution order by eliminating the local variables.
So what's the solution? Hard to tell without knowing what the VI is supposed to do. Most likely you need to eliminate the inner FOR loop and use the outer WHILE loop for everything.