Example Code

Measuring the Elapsed Time Since a Boolean Was Turned On using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
Demonstrates how to use loop iteration time to roughly measure the amount of time a Boolean has been ON for

 

Description
DISCLAIMER: Since this is being run on Windows, which is not a deterministic operating system, it is prone to jitter and there is therefore no guarantee that the loop iteration time will be exactly the same on every iteration (it could exceed 5ms on any given iteration due to lag created by background processing). As a result this is not an extremely accurate means of measuring the time the signal has been on for. It would not be good for applications such as alarms or system shutdown conditions. However it is appropriate if you just want to know how long a signal has been on for and do not need accuracy on the ms scale.

This VI uses a shift register to increment a value while the Boolean is turned ON. The minimum loop iteration time of 5ms is then used to convert this value to the approximate amount of time that has elapsed since the Boolean was turned ON.

 

Requirements

  1. LabVIEW 2015 (or compatible)


Steps to Implement or Execute Code

  1. Download the VI.
  2. Run The VI
  3. Turn the Boolean On
  4. 'Elapsed Time (ms)' will show the amount of time the Boolean has been on for, the LED will light up if this time exceeds 10s
  5. Turn the Boolean Off
  6. Repeat if desired
  7. Stop the VI

 

Additional Information or References

VI Snippet

Measuring Elapsed Time Since Boolean Was Turned On.png 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Selene

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.