LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to save the operating hour of a device?

Hello,

 

I am communicating with a device over TCP/IP(UDP) protocol. The device has some registers for configuration and there is a register to activate and deactivate the device. I want to implement a shared variable to save operating hour of the device, namely a timer that counts, when I activate the device till deactivating.  My approach (not a good idea) is that I create a boolean shared variable, While activating my device I set this shared variable to true, while deactivating to false. But I have to sum all of the times when shared variable is true.  It will maybe get slower and slower after months, because it shall sum all the times from the beginning. What is the best approach for this task?

 

Thanks.

0 Kudos
Message 1 of 8
(3,728 Views)

I don't understand, do you need to store all of the times individually or keep just a running total? Are you worried about losing this data if the system accidentally reboots? Why is the boolean shared variable necessary?

0 Kudos
Message 2 of 8
(3,696 Views)

I assume you activate and deactivate the device by doing something (using LabVIEW, I presume) on your PC.  So when you Activate the device, save the "Start Time".  When you Deactivate the device, get the "Stop Time", subtract the Start Time, and you have the Time Device was On.  Save this somewhere/somehow.  If your program runs over multiple days/months and multiple Activation cycles, you can (a) save an Array of Run Times, or (b) accumulate (means "add up") the Run Times to save "Cumulative Run Time".  No need for Shared Variables,

 

Bob Schor

0 Kudos
Message 3 of 8
(3,682 Views)

Yes I am activating and deactivating it from my application, that I implemented in LabVIEW . I am saving lots of values from device in Shared Variables, therefore I want to save also the operating hour in a shared variable and I want to show the operating hour on GUI as hour:minute, it shall be shown to user but not changable by user. Later on I will backup the shared variable database to analyze it. I want to avoid to save it in a text document.

And I don't want to accumulate all of the run times during start-up the program. After a couple of years, maybe the data will be huge and it will take a long time to accumulate all of them.

0 Kudos
Message 4 of 8
(3,630 Views)
I'm confused by what you want as well. You just have to save a single value to file (i.e an ini file). What do you think you have to accumulate? The total time is simply displayed in a timestamp or numeric indicator. The value is saved when the program is stopped and loaded when you restart it. Just addition to the value after that.
0 Kudos
Message 5 of 8
(3,605 Views)
One logical problem to keep in mind is that unless the operating hours are tracked on the device itself, you don't actually know when thel device started or stopped. All you know is when you told it to start or stop. If that command/response process breaks you have no way of knowing what state the device is really in, and consequently how long it has been running.

Also, variables (shared or not) are for dynamic data. If you don't keep track of individual start/stop cycles, why should it slow down? You should be processing the same amount of data every time.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 8
(3,600 Views)

Yeah, the only thing you need to keep track of is 'accumulated runtime' - it's a single value in a file that you can read, add your runtime since last write, and write back to the file. For example, you might want to write to the file every 10 minutes and if it has been online for all that time - you'd be adding 10 minutes to the accumulated runtime in the file.

 

As Mike said - you need to be aware of what happens if you run it on another computer (a database or storing the file in a network location - use the serial number of the device to identify it) or what might happen if the device is running and your PC crashes etc. - it might not be 100% accurate.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 7 of 8
(3,594 Views)

Thanks for answers. Yes, it will not 100% accurate, it will be only a "feature" 🙂 .

I will try your suggestions. Thanks a lot.

0 Kudos
Message 8 of 8
(3,518 Views)