09-08-2009 01:21 PM
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
09-08-2009 01:43 PM
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.
09-08-2009 02:03 PM
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.
09-08-2009 02:12 PM
09-08-2009 03:01 PM
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
09-08-2009 03:06 PM
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
09-08-2009 03:08 PM
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. 😞
09-08-2009 05:14 PM
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).
09-08-2009 05:21 PM - edited 09-08-2009 05:23 PM
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.
09-08-2009 05:51 PM
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