This is a FGV timer implemented using the function ‘Get Date/Time in Seconds’, to measure elapsed time along with Pause and Resume functionality.
Here is the front panel of the vi.
Timer states is an enum which has four states.
- Set Timer Parameters – Resets the timer
- Get Elapsed Time – Returns Elapsed time
- Pause – Pause the timer
- Resume – Resumes timer
Three shift registers[SR] are used in this vi for storing target time, elapsed time and start time. We will see the value of all three shift registers in each state.
Here present/current time will be found by using ‘Get Date/Time in Seconds’ function [gives time as timestamp] which is converted to DBL.
Set Timer Parameters:
Target time = Value from Time Target(s) control.
Elapsed time = Zero
Start time = Present time.
Target time and Start time – same as shift register value.
Elapsed time = Present time – Start time.
All three values are same as shift register value. Elapsed time will be maintained with the previous elapsed time value.
Target time and Elapsed time – same as shift register value.
Start time = present time – previous elapsed time[stored in shift register]
Following is the timer graph plotted between present time and elapsed time(s).
Since it is FGV, this has to be called in some other VI. Initially Timer parameters have to be set by passing the case Set Timer Parameters. Then Get Elapsed Time case has to be called to find the time.
When Pause button is true, pass the case as Pause, when it is resume [Pause button from True to False] pass the case as Resume followed by Get Elapsed Time case.
For Resetting timer, Set Timer Parameters has to be passed.