LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How come my local variable is not updating it's value with respect to what's happening in the while loop?

Solved!
Go to solution

Hello,

 

I am trying to extract data out of a while loop as my declarations update with respect to the iteration number. I have attempted to use both local variables and shift registers, but with no luck.

 

I have also done the following example: http://www.ni.com/white-paper/7585/en and it works like a charm.

 

I attached the PNG file with local variable declaration circled in red. Will attach a VI in the next respnose.

 

Thanks

0 Kudos
Message 1 of 10
(5,017 Views)

That's not a local variable, but a value property. It gets read exactly once at the beginning of each iteration of the outer loop, each time before the code in the inner loop ever writes to it.

Sorry, posting by phone. I'll look at the code later.

0 Kudos
Message 3 of 10
(5,000 Views)

OK, looking at the code...

 

Can you explain what it is supposed to do? What's the purpose of the value property node read which only seems to update an indicator.

 

The inner while loop should proably be a FOR loop, because the number of iterations is known before the loop starts.

Your use of formula nodes seems overly complicated.

0 Kudos
Message 4 of 10
(4,982 Views)

TacomV wrote:

I have also done the following example: http://www.ni.com/white-paper/7585/en and it works like a charm.


The examples in this application note do not resemble anything in your code. Where is the connection?

0 Kudos
Message 5 of 10
(4,975 Views)

Basically, I want to get the iteration value out of a while loop. The counter will keep incrementing, but the indicator will only update once the loop is finished, not during the loop. 

0 Kudos
Message 6 of 10
(4,954 Views)

Then you need to read it in a second loop that runs in parallel.

 

(run your code in highlight execution mode while watching the diagram to get a better understanding what your code is doing)

0 Kudos
Message 7 of 10
(4,952 Views)

To my nowledge it is being run in a parallel while loop. One while loop inside the false case statement, and the local variable being written in the while loop running the whole program.

0 Kudos
Message 8 of 10
(4,946 Views)
Solution
Accepted by topic author TacomV

No, the two while loops are stacked and not parallel, meaning the outer loop cannot go to the next iteration until all code in it, including the inner while loop has completed.

Message 9 of 10
(4,938 Views)

Ah that makes sense. Thank you very much.

0 Kudos
Message 10 of 10
(4,935 Views)