取消
显示结果 
搜索替代 
您的意思是: 

FOR loop wont update Local Variable

已解决!
转到解答

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?

0 项奖励
1 条消息(共 3 条)
4,142 次查看
What do you mean by update in code? If the value is not being updated on the block diagram it won't update the front panel (not dashboard).

You would benefit from going through the online tutorials.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 项奖励
2 条消息(共 3 条)
4,139 次查看
解答
已被主题作者 Taco.Dust 接受

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.

3 条消息(共 3 条)
4,121 次查看