02-17-2024 06:25 AM
HI all,
I am trying to build an hour counter for engines. When the engine runs it must log the running time, and save this to a text or excel file. We do know by end of the year how much time the engine runs, or when it does need service etc.
Now I have created a case structure with condition ON if the engine is running >50rpm the counter starts and shut off when <50rpm.
However it saves nou every second that the timer runs, which makes the save file very large. What is the best way to only save the total sum of that running time, including date.
For example, the engine has runned for 60 min, I want to save 60 minutes. and not 3600 sec. and thus 3600 cells (every sec. is a cell now).
Also, a total time from previous running times would be great, but that is something for later on.
Thanks in advance guys!
Solved! Go to Solution.
02-17-2024 06:30 AM
Hi han,
@HANAUTOMOTIVE wrote:For example, the engine has runned for 60 min, I want to save 60 minutes. and not 3600 sec. and thus 3600 cells (every sec. is a cell now).
Don't append to end of file, but overwrite the file entry...
In general: read the file on start of your program, keep the current OperatingHours in a shift register, and save the result upon exit of your program...
03-14-2024 05:50 AM
HI All,
I have built a time counter to be able to log the engine running time.
However, now it logs it total end time when the vi stops, that is good. But it deletes the time in the log file and restarts when the VI starts again.
I actually want that the time, from every run, is added to the total time in the txt log file. How can i do this? See attached the code. I have tried several things but that didn't seem to work out. Thanks in advance!
03-14-2024 06:00 AM
Hi Han,
@HANAUTOMOTIVE wrote:
I actually want that the time, from every run, is added to the total time in the txt log file. How can i do this?
I already told you to load the file at start of your program, then add up the counters in your program and save the new (total) counter values upon end of the program.
Seems fairly easy...
@HANAUTOMOTIVE wrote:
See attached the code.
Please attach a downconverted version of the VI: File->Save for previous.
(Anything for LV2021 or older might be ok, I prefer LV2019.)
03-14-2024 08:23 AM
Hi Gerwd,
Thank you for your help and suggestions so far. The timer itself works fine now, only some logging issues. See attached downgraded VI version 2019.
03-14-2024 09:06 AM
Hi Han,
@HANAUTOMOTIVE wrote:
The timer itself works fine now, only some logging issues.
Well, "works fine" is a nice desciption… 😄
Suggestion:
I made a similar OperatingHours counter some time ago. I loaded the persistent data on startup, updated the values in memory based on conditions for each counter, saved the current data on a regular schedule to the file (to prevent data loss due to power outages or software crashes), and saved the data when exiting the software routine…