LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed While Loop Bug/Feature?

I believe there may be a bug in the Timed While Loop structure in LV 7.1.

I have a timed while loop inside a normal while loop (state machine). The timed loop is set to _not_ discard missed periods. On the first run of the timed loop, it behaves as expected. However, if the timed loop is stopped, then restarted after a delay (without stopping the VI itself), it appears that it is quickly running through all of the iterations it "missed" during the delay (i.e. on the first run, the iteration value ramps up at a steady rate from zero; on the second run, the iteration value ramps immediately from zero to a value equal to the delay time divided by the period, then ramps up at a steady rate from there.)

I have attached a VI which de
monstrates this issue. Run the VI, flip the "Start" switch to TRUE, observe the iteration value ramping, flip the switch back to FALSE, wait several seconds, then flip the switch back to true again. You'll see the iteration value displayed in the chart rapidly ramp up, then slow down.
0 Kudos
Message 1 of 3
(3,084 Views)
Hi!

Actually, this is expected behavior from the timed loop. The following is copied from the Context Help on the Loop Configuration:

"Discard missed periods�Remove the checkmark from the checkbox to run Timed Loop iterations for each missed period. Otherwise the Timed Loop executes on the next scheduled iteration the Offset and Period values establish."

Basically, if Discard Missed Periods is not checked, then the loop is going to run as fast as it can through the iterations that it missed to "catch up." If Discard Missed Periods is checked, then it will just discard those iterations and go back to the established timing.

Hope this helps!

Travis H.
National Instruments
Travis H.
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 3
(3,084 Views)
Is this really by design? I understand the functionality of the "Discard Missed Periods" setting, but I assumed it was only functional while the loop was actually running. The loop is actually processing periods it "missed" even when it isn't running (i.e. after its conditional terminal has been set to False and the loop has stopped). It would seem to me somewhat misleading to have the loop still logging missed periods when VI execution isn't even in the loop.

Just for information, I have found 2 workarounds for this problem. You can create a custom timing source, use it for the timed loop, and then clear it when the loop stops, or you can set the mode to discard missed periods for just the first iteration.
0 Kudos
Message 3 of 3
(3,084 Views)