LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save a number and create total time

Solved!
Go to solution

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! 

 

0 Kudos
Message 1 of 6
(529 Views)
Solution
Accepted by HANAUTOMOTIVE

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...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(526 Views)

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! 

 

0 Kudos
Message 3 of 6
(374 Views)

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.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(366 Views)

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.

0 Kudos
Message 5 of 6
(344 Views)

Hi Han,

 


@HANAUTOMOTIVE wrote:

The timer itself works fine now, only some logging issues.


Well, "works fine" is a nice desciption… 😄

 

  • When you open the file you can also read it's content and use those data to initialize the shift registers with correct start values!
  • Why is the shift register holding a float value when you write only integer data to your file?

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 6
(337 Views)