LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Store counter on how long program has been running

Hi All,

 

I want to add a counter to my program to indicate how many hrs it's been running.  The value must be persisted so that it's reloaded each time the program starts.  How do I achieve this?

 

Thanks,

Sean

0 Kudos
Message 1 of 11
(4,611 Views)

You can use the elapsed time function. Just make sure the reset after time target is false and set the display mode of the numeric to relative time.

 

Elapsed Time.png

0 Kudos
Message 2 of 11
(4,601 Views)

Dennis' example will display the current session's running time. In order to accumulate total time for all runs,  you will need to persist the data somewhere. I would suggest using a text file or INI file. Read the file before the loop, show the data and write the total time outside the loop.

 

 

0 Kudos
Message 3 of 11
(4,593 Views)
Thanks, I missed the point that it should accumulate total time.
0 Kudos
Message 4 of 11
(4,586 Views)

I know this is probably NOT the way you would want to do it, but could you somehow incorparate an uninitialized shift register to contain the value from the last time the VI executed?

 

I'm just trying to see if my understanding of shift registers is correct.

 

Thanks!

 

Bill

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 11
(4,568 Views)

Bill,

 

That only works as long as the VI remains in memory.  It is the basis of the functional global VI (also called the LV2 style global) and Action Engines.  It will not work if the VI is closed, LV or the computer restarted, ...

 

Lynn 

0 Kudos
Message 6 of 11
(4,566 Views)

johnsold wrote:

Bill,

 

That only works as long as the VI remains in memory.  It is the basis of the functional global VI (also called the LV2 style global) and Action Engines.  It will not work if the VI is closed, LV or the computer restarted, ...

 

Lynn 


Thanks.  Sorry that I hijacked the thread.  I don't normally do this.  😞

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 11
(4,563 Views)

Guys,

 

I was able to implement what I needed (a total runtime in hours for the program).  Thanks for the advice.

Below is how I implemented it, any way it could be improved? (it feels a bit kludgy to me).

 

pump runtime.JPG

0 Kudos
Message 8 of 11
(4,544 Views)

What is "Initial Pump Hours", and why are you adding hours to seconds?

 

Oh, yeah, almost forgot: You have a race condition. The control will be read before it gets written. 

Message Edited by smercurio_fc on 09-08-2009 05:23 PM
0 Kudos
Message 9 of 11
(4,540 Views)

RE adding seconds to hours, good catch, just saw that myself.

The "Initial Pump Hours" is the total time so far the program has been running (the program is to control pumps, and that's what I need to keep track of, how many hrs they've been running).

 

How can I solve the race condition.

 

Thanks for the response too Smiley Happy

0 Kudos
Message 10 of 11
(4,531 Views)