Sometimes they are needed, but I have seen one really egregious LV app in particular where the author had about 7 while loops checking local and global flag variables to see if they should run the code they contained. The program automated a highly sequential process, and would have been much better off with a state machine exerting strict control over the flow. As it was, it was like a car full of kids yelling "are we there yet?" every few milliseconds. This generated lots of useless cpu activity running loops that had nothing to do. A state machine only executes the code that needs to be running.

Flow control was abandoned to the task manager, and it took me two days to find one bug that wouldn't show when execution highlighting was on, but would appear as soon as it was turned off. I think some famous comic said "Timing is everything".

In addition, that program construction rendered the LV debugging really hard to use. When using execution highlighting, or single stepping,the point of action shifted at random around this large diagram, turning it into a software version of Whack-a-Mole. With a state machine, you know where to look.

I generally avoid them, but then, since I came here I've mostly been automating fairly slow test sequences, not pushing the envelope of high sample rates etc. The only reason I've used an independent loop is to poll an Abort button to update lots of local variables used to shut down a long process with lots of nested loops.

-BG

Bill Gilbert, EM Tech
UMN School of Physics and Astronomy
Tel 612 624 4870
Fax 612 624 4578        


Paul F. Sullivan wrote:
Michael,

You wrote:

...I enjoy discussions on methodology and implementation techniques... The issue lately is: single loop good, multiple loops bad.


Without multiple loops you lose the parallelism that is the hallmark of LabVIEW. Why would multiple loops be bad? If it's the block diagram real estate taken up by the loop structure, you could hide the loops in subVIs.



--






Reply via email to