LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Total hour counter

How do i add a engine running houre meter to my vi. I need it to count when a input is high and stop when low, However it needs to continue if the input goes high again.
0 Kudos
Message 1 of 8
(3,933 Views)
Just use a shift register to hold your ON time and only increment it in the TRUE case.
 
Attached is a very simple example (LabVIEW 7.0) that counts ON seconds of a switch. Modify as needed.
0 Kudos
Message 2 of 8
(3,918 Views)

Thanks altenbach for your reply

I think i need to use system time because i have meny other thing going on in the main loop and can't rely on the mil/sec ticker. do you have any other suggestions?

0 Kudos
Message 3 of 8
(3,915 Views)
Just use "get Date/Time in seconds" and increment by the elapsed time in the TRUE case. 🙂
Message 4 of 8
(3,909 Views)
You might consider writing the data (Elapsed time) elsewhere, in case the system shuts down, locks or crashes.

You could also find that you have run a couple of hundred hours and the computer is shut down loosing the count if you don't handle the output from the shift register.

Me, I put it in the registry or into a text file every once in a while and then at the end of the loop update the entry.
0 Kudos
Message 5 of 8
(3,903 Views)
I often use a typedef control with Idle, Start/Run, Pause, Resume, and Stop buttons. My elapsed time VI is similar to Christian's OnTimer2.vi with extra states for the other buttons. It works in a larger VI with shift registers for Start Time and Elapsed Time. These are often in a cluster with other indicators and flags. Here is a simplified version (LV 7.1).

Lynn
0 Kudos
Message 6 of 8
(3,880 Views)

Thanks guys, eveything now all working very nice. One thing is that it's mentiond that i should store the count in a txt file or registry. I know how to store in a txt file but could some one give me an example of how to store in the registry? Cheers 

0 Kudos
Message 7 of 8
(3,850 Views)
You can find examples of registry access by searching the examples using the keyword REGISTRY
 
There are three examples in Rev 7.1 which are: -
Delete Windows Registry Key.VI
Read From Windows Registry.VI
Write To Windows Registry.VI
 
Just remember that the registry is not intended for large amounts of data or real time data storage, its intended for program settings and preferences, configurations and important data etc. But it can be a handy place to store stuff and on a multi user machine you can choose to write into a user profile space or to the machine in general. If it's in the user space and the machine is on the domain with network user profiles, It also gets backed up onto a server as part of the users profile, this can be very handy (the desktop counts as the same, but check with the domain administrator).
0 Kudos
Message 8 of 8
(3,833 Views)