How to Stop a VI in a While Loop in 60 Seconds in LabVIEW

Updated Nov 7, 2023

Environment

Software

  • LabVIEW

I'm driving a rotary stage motor between -6 and +6 degrees relative and I'm attempting to accurately measure the number of cycles per minute.The problem is that the Elapsed Time Express VI doesn't stop directly at 60 seconds so my cycle count has varied.

To stop a VI that is in a While Loop in 60 seconds you can:
  1. Measure elapsed time in a VI that is running
  2. Make a comparison between the elapsed time and the time that you want this VI to stop
  3. Wire this result to the stop button of the VI.
A way to do this comparison is to use the Tick Count (ms) block in conjunction with a Sequence Structure inside a While Loop. This method is illustrated in the figure below to time length of the Wait (ms) function in the center.



Note: This code is not optimized for production and this is one of the possible ways to perform this task.

Additional Information

The Tick Count (ms) VI returns a 32-bit number (0 to 4 billion), which means, when using the above method to measure elapsed time, the Tick Count (ms) VI can run continuously for roughly 2 months before it rolls over. The tick count is reset back to zero when you restart your computer, so restarting the computer occasionally can prevent the Tick Count (ms) VI from rolling over.