LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop inside a while loop

Solved!
Go to solution

Just a general question, is a timed while loop inside another timed while loop a bad designing practice?

 

Any feed back on why it shouldn't be done is much appreciated.

 

mhaque

Message 1 of 9
(14,398 Views)
Solution
Accepted by mhaque

Yes, it is very bad design.

 

The outer timed loop cannot complete its iteration unless the inner timed loop completes. This means that its time target cannot be enforced unless it is guaranteed to be much longer than the entire execution time of the inner loop. Too many if's!

 

What are you actually trying to achieve with all this?

Message 2 of 9
(14,367 Views)

Hi altenbach I did as you said, I wanted to use shift registers so I just used 1 while loop to do the operations.

 

mhaque

Message 3 of 9
(14,357 Views)

What if I use 2 while loops? Is that a bad designing practice? Is there a way I should link the two loops so as to synchronize one witht the other, i.e. using an error wire?

 

mhaque

Message 4 of 9
(14,305 Views)

It depends what you mean by "synchronize".

 

 

  1. Do you want the two loops to both start at nearly the same time, but the run independently?
  2. Do you want to maintain some synchronization while they run?

 

(1) could be done with a wire if done right. Also, the "timed loops" have start synchronization functionality built-in. Check the help. Option (2) cannot be done with wires, because you would create a data dependency.

 

Message 5 of 9
(14,284 Views)

@mhaque wrote:

What if I use 2 while loops? Is that a bad designing practice? Is there a way I should link the two loops so as to synchronize one witht the other, i.e. using an error wire?

 

mhaque


Are you still talking about nesting While Loops?  Or 2 While Loops in parallel?

Message 6 of 9
(14,271 Views)

Hi altenbach since I have already accepted your solution I have posted another thread dealing with this issue.

 

http://forums.ni.com/t5/LabVIEW/Synchronizing-2-while-loops-one-with-an-event-structure/m-p/1418612

 

Message 7 of 9
(14,261 Views)

I think it is two while loops in parallel.

Message 8 of 9
(14,260 Views)

For parallel loops, there are many (a few?) ways to synchronize them.  I would start with what Altenbach suggested.

Message 9 of 9
(14,219 Views)