10-29-2013 08:13 AM
Hi
I could not find the exact answer to my problem so I am posting a very quick question.I am pretty new to labview.
I have to access a value inside a while loop to the outside. I created a local variable and put it outside the loop but it does not update the value...what am i doing wrong here??? thanks in advance.
Cheers
Adi
10-29-2013 08:27 AM
The code outside the loop is only executed once after the program starts. You have to put it into another while loop. And don't forget a wait (1 ms) in either loop to prevent the loop from hogging the CPU.
Cheers
Edgar
10-29-2013 08:32 AM - edited 10-29-2013 08:33 AM
The indicator outside the loop is being updated once, probably at the start of the program. Try eliminating the outer indicator, moving the inner one out of the loop and the local variable inside the loop, where it, the local, is written to. The way you have it, the value on the local, at some unknown time, writes to the indicator, then "their" action is complete. If you wanted them to continuously update then you might put them in a loop of their own, but then you would have timing issues between the two loops. You also want to get into the habit of putting a Wait(ms) or a Wait until next ms Multiple (found on the Timing pallete), otherwise a loop will grab most of the CPU, screaming in a loop. A better way to pass values out of a loop is with a queue. If you open "File:New:From Template: Producer/Consumer Design Pattern" it will show one method.
10-29-2013 08:37 AM - edited 10-29-2013 09:00 AM
the caveat....
@LVPro, "A better way to pass values out of a loop is with a queue." ... +1
10-29-2013 09:39 AM
Thanks for the quick reply. For me a small delay would still work. But I would include the delay time anyways. This solves the problem. Thank you.