LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving and Restoring Pump Operating Hours in LabVIEW

Solved!
Go to solution

Good afternoon, everyone.
I am developing a program to record the total number of hours the pump is running, in order to assist with preventive maintenance planning.

The current code can already sum the operating time whenever the pump is started. However, I need to implement an additional feature: when the program starts, it should read the previously accumulated value from a file. This way, when the pump is turned on again, the system will continue counting from that value, adding the new operating time.

When the pump is turned off, the updated value should be saved to the file, ensuring that the total running hours are preserved for the next execution.

0 Kudos
Message 1 of 33
(490 Views)
Solution
Accepted by topic author Felipe_Alves17

I don't have much time right now but here's a quick and dirty option.

 

I'd recommend using an .ini file. You don't have to worry about string handling or file locations or anything like that, you just record the last value to the file, then read it back later.

 

Now, if you want to append a new line every so often so you can track pump usage over time, that's a different question. For that case I think I'd use "Read delimited spreadsheet" and take the last row to initialize your program and just keep something like what you have now, just appending to the end each time it runs.


Message 2 of 33
(478 Views)

I don't intend to create another line; it's just a variable to mark the hour meter. Test the update you made, but there was no update in the .ini.

0 Kudos
Message 3 of 33
(456 Views)

It worked for me, but I changed the location of the ini file. Also make sure you're not clicking the red Stop sign button in the LV toolbar- click the "Stop" button in your code.

Message 4 of 33
(448 Views)


Você tem razão, muito obrigado, tinha que clicar no parar, se clicasse no vermelho lá em cima ele não salvava. mjuito obrigado meu amigo, me salvou.
You're right, thank you very much, I had to click on stop, if I clicked on the red one up there it wouldn't save. Thank you very much my friend, you saved me.

0 Kudos
Message 5 of 33
(446 Views)

A question arose, if the PC is turned off due to a power outage, it will end up losing the bomb data and the last one will be saved, is there any way to save it instantly while it is on?

0 Kudos
Message 6 of 33
(414 Views)

You can write to the ini file each loop if you'd like, but 10x a second is pretty high. I'd say if you changed to a 1000 ms wait you could put the "Write to ini file" inside the loop. You'd need to close and reopen it each time though.

 

Just decide how much time you can afford to lose and write it at least that often. Do you need to know runtime down to the millisecond? Second? Minute? 30 minutes?

0 Kudos
Message 7 of 33
(401 Views)

Hi Felipe,

 


@Felipe_Alves17 wrote:

A question arose, if the PC is turned off due to a power outage, it will end up losing the bomb data and the last one will be saved, is there any way to save it instantly while it is on?


Do you even read the answers you got?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 33
(304 Views)

Yes, it is working, but I wanted even more help, I need to do this without using WHILE, because I am using an application and when I use while it crashes because it is already using this conditional, can you help me?

0 Kudos
Message 9 of 33
(253 Views)

Hi Felipe,

 


@Felipe_Alves17 wrote:

I need to do this without using WHILE, because I am using an application and when I use while it crashes because it is already using this conditional, can you help me?


I could help - once I know and understand your requirements…

 

WHY do you want to solve the problem "without using a while" loop?

WHAT is the reason to work without while loop "because I am using an application"???

HOW do you "use it while it crashes"???

WHAT it "using this conditional"? WHICH "conditional"???

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 33
(210 Views)