01-17-2011 09:25 AM
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
Solved! Go to Solution.
01-17-2011 11:29 AM - edited 08-16-2012 10:49 AM
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?
01-17-2011 11:44 AM
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
01-18-2011 08:31 AM
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
01-18-2011 10:51 AM
It depends what you mean by "synchronize".
(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.
01-18-2011 11:15 AM
@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?
01-18-2011 11:57 AM
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
01-18-2011 11:58 AM
I think it is two while loops in parallel.
01-19-2011 08:03 AM
For parallel loops, there are many (a few?) ways to synchronize them. I would start with what Altenbach suggested.