LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

local variable

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

0 Kudos
Message 1 of 5
(2,548 Views)

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

0 Kudos
Message 2 of 5
(2,538 Views)

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.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 3 of 5
(2,526 Views)

the caveat....

Example_VI.png

 

@LVPro, "A better way to pass values out of a loop is with a queue." ...  +1  Smiley Wink

0 Kudos
Message 4 of 5
(2,515 Views)

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.

0 Kudos
Message 5 of 5
(2,485 Views)