Iteration Duration Output From Timed Loop Inaccurate or Too Large in LabVIEW

Updated Aug 30, 2023

Reported In


  • LabVIEW

Issue Details

I'm using a Timed Loop in LabVIEW to time an action, and am reading the Iteration Duration output from the Timed Loop to get the duration of the loop's previous iteration.
Iteration Duration Timed Loop output terminal.
Occasionally during the code's operation, the Iteration Duration output will jump to 4x10^9 ms, which is significantly larger than any iteration of my code should take - this is causing my code to stop prematurely or experience other issues. What can cause this behavior, and how can I fix it?


This behavior usually occurs when a Timed Loop operates for longer than its specified period but isn't constructed to throw an error or otherwise stop iterating. Timed Loop periods are supposed to be the absolute maximum duration that the Timed Loop's code could run for without necessitating an error, so having a situation where a Timed Loop could run without error for longer than its period could generate strange, erroneous behavior on the Timed Loop's backend. One way this can manifest is as integer overflow for the loop's Iteration Duration, which can produce inaccurate, often high numerical values near the 32-bit unsigned integer limit of 4.29x10^9.

There are two ways to address this behavior:
  1. If you are able to, raise the period of your Timed Loop to ensure it matches up with the longest iteration you can feasibly expect from your code's operation. This will minimize the chance of issues with the Iteration Duration output value.
  2. If you're unable to increase your Timed Loop's period, or your code typically takes a small amount of time to operate but occasionally takes a long time, you should look into substituting a While Loop for the Timed Loop in your code. While Loops allow for greater flexibility in code operation duration, and can still enforce a minimum period by using the Wait (ms) or Wait Until Next ms Multiple LabVIEW functions .
Example While Loop architecture allowing for similar period enforcement to Timed Loop.