Example Code

FGV Timer SubVI

Code and Documents

Attachment

Download All

FGV Timer 2012 NIVerified

 

Overview

This Timing VI can be called within a main application to start, get value, pause, and resume.

 

Description

The values are stored in a functional global variable (FGV) within a loop that is called only once. Each time you call the subVI, you can input a enum state in order to start the timer, get the elapsed time, pause or resume the timer. The timer also outputs the Elapsed time, a Boolean indicator comparing the elapsed time to the target time, and a pause flag to notify the user if the timer is paused.

Requirements

  • LabVIEW 2012 or compatible

 

Steps to Implement or Execute Code

  1. You can run the subVI on it's own by selecting the enum input for timer state and pressing run. It is designed to run the loop only once since it is designed to run as a subVI. For testing purposes, you can run the VI continuously to keep the values on the front panel updated.
  2. Use this VI as a subVI. Within a state machine, you can start the timer in one state and get the time in another state.

Additional Information or References

front panel 

FGVTimer.PNG

 

5.png

 

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

 

 

 

Applications Engineer
National Instruments

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

Comments
Greg_Reynolds
Member
Member
on

Thanks for this fgv timer example.  I enjoyed reviewing it's functionality as I study for the CLD.  I made a few changes and posted here.

Greg R.
Ahmed_Osman
Member
Member
on

Thank you for sharing.

 

I've made a minor modification:

  1. add start time option "so that you start counting from known value when needed not 0"
  2. removed the type definition

 timer v2.png

 

https://drive.google.com/file/d/1gd1zVOoXcbD0l9mIWds_NqNOJ2vLVWRn/view?usp=sharing