01-25-2013 03:36 PM
I have a semi large vi where a significant portion of it is a while loop. For some reason the while loop is not looping and I can't find the "stuck" point. Does anything look obviously wrong to you guys?
01-25-2013 03:42 PM
Besides having a block diagram which is way too big?
Yes. The inner while loop which contains an event structure will not complete until the full stop button is pressed. Until that while loop stops, the outer loop cannot finish its first iteration.
Probably other problems but this one is enough.
Lynn
01-25-2013 03:49 PM - edited 01-25-2013 03:50 PM
The source of your problem is your event structure. Your inner loop will not exit the first iteration until you press the stop button.
With that said you really nee to think about cleaning your code up. The general rule of thumb is that a block diagram should fit on a single screen. You should also learn how to use data flow better. You can eliminate all of your sequence structures by using data flow.
01-25-2013 03:50 PM
Oh. The the inner while loop is the one that is not running. The outer while loop with the "full stop" button is supposed to function that way. Also, I was really worried about the "way too big" issue, but I'm not really sure how to make it smaller. The event structure was an attempt to make the giant thing less demanding on the computer.
01-25-2013 03:52 PM
Thanks Mark! It looks like I'm going to need some massive cleaning. Would it be okay to remove the event structure and just have the vi poll the front panel?
01-25-2013 04:00 PM
The even structure was introduced to eliminate the need for polling! The point is that data flow may require the event structure to be in a parallel loop rather than an inner loop.
Lynn
01-25-2013 04:03 PM
@DrinkitUp wrote:
Thanks Mark! It looks like I'm going to need some massive cleaning. Would it be okay to remove the event structure and just have the vi poll the front panel?
I generally avoid polling loops especially for UI related things. Take a look at the producer/consumer examples that ship with LabVIEW. Better methods for stopping parallel tasks are to use queues, notifiers or user events. Which one you use depends on your particular situation. You may also want to consider having separate parallel loops for your data collection activities. Not sure if you would need a separate loop for each device or if some can share the same loop but as written your execution will be gated by the slowest device. This is because for a loop iteration to complete all the code inside of it must execute to completion. So if your data collection can or should run at different frequencies you will not be able to do that with everything in a single loop.