LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i save the last count if power is lost so i can start the count from where it left off?

I have 2 similar applications that i need the same help with.  The are both keeping cycle count, from CAN translated to 485.  They work great but if power is pulled i want them to resume from where they left off.  The computer thats attached will start from zero but i want LabVIEW to recognize that we left off at say 4300 cycles, so add that to the new count of 0.  This sounds really easy but im not sure how to store the count and make labview read from it everytime the application starts again. I attached the smaller VI to take a look, the subvi maynot come thru but its just a timing vi, thanks

0 Kudos
Message 1 of 12
(3,900 Views)

How is starting from 4300 supposed to change the program? Does it change the configuration of the DAQ Assistants? Does it change the way you're reading the serial port?

 

In general, you can use the File Configuration VIs to save stuff to disk. These read/write simple .ini files. You can save these, say, in the same folder as the program. Be careful about determining file paths programmatically. Why Does My Executable Not Work When Using the Current VI's Path Constant?

 

Other comments:

  • Do not initialize and close the serial port in every iteration of the loop. Initialize outside and close outside the loop.
  • Instead of creating individual VIs for your time delays, add a control to the subVI so you can wire in the delay. Or, better yet, use the Time Delay Express VI.
0 Kudos
Message 2 of 12
(3,887 Views)

If this is really mission critical I would connect the entire project to a UPS that has a digital output that tells you when power is out. Connect the digital output to your DAQ , when power goes out dump every thing to a file. The UPS should keep you up for plenty of time to save your data.

 

Alan

0 Kudos
Message 3 of 12
(3,885 Views)

The DAQ assistants are simply there to control the pneumatics, it has nothing to do with reading the 485. 

 

Alan,

 

I have a UPS on there right now to avoid the power issue but i want my program to not need it.  I am thinking i could put the counts in an array, rewrite over it everytime, then if i loose power i could call the counts from the array and add to the restart??  So if i lose power at cycle 4300, then we i restart labview it knows to read the 4300 count and start from there, is that a little more clear?

0 Kudos
Message 4 of 12
(3,874 Views)

That should not be used as a reason to not have a UPS. Besides, whether or not there's a UPS should not make a difference. What happens if LabVIEW crashes, or Windows crashes? The existence of (or lack thereof) a UPS would have no bearing. You want the program to pick up where it left off. This means you need to save the point (however you define this) to file. You cannot "save it into the array" because you cannot have an application modify itself when it is running.

0 Kudos
Message 5 of 12
(3,862 Views)

Ok, you are correct. But the OP specifically stated "if power is lost" So that's as far as I thought it out. I guess writing to a file while windows is crashing could wreak some havoc also. What you need is uninterruptible windows.

 

Alan

0 Kudos
Message 6 of 12
(3,853 Views)

Smercurio_fc,

 

I understand your point completely, but I have to have more than 20 of these testing running at the same time. It costs to much to have a UPS at every test, but if I could I would it helps with losing power as well as noise.   I like your idea of saving, say every 500 cycles then can I call on the last saved value before running the test?  Maybe a button that sets the count, then how can i make sure it is added to the incoming count.

 

Test Background:

We are using pneumatics to hit buttons and counting them.  We are using CAN translated to 485 and i read the messages.  If power is lost, or we lose a connection, the CAN resets to zero.  Right now if we lose power i look at the last count we recorded and type it in a text box on the screen, bc the current count is off by that many.  I really need to store the values every say 500 or 1000 times, that way when i start it back its adding that count itself so i dont have to keep track of the numbers myself

0 Kudos
Message 7 of 12
(3,846 Views)

 


@chris12345 wrote:

Smercurio_fc,

 

I understand your point completely, but I have to have more than 20 of these testing running at the same time. It costs to much to have a UPS at every test, but if I could I would it helps with losing power as well as noise.   I like your idea of saving, say every 500 cycles then can I call on the last saved value before running the test?  Maybe a button that sets the count, then how can i make sure it is added to the incoming count.


 

Actually, you didn't understand my point. I wasn't telling you to use a UPS at every test or test station. I was telling you that whether you have a UPS or not is completely irrelevant here.

 

 


Test Background:

We are using pneumatics to hit buttons and counting them.  We are using CAN translated to 485 and i read the messages.  If power is lost, or we lose a connection, the CAN resets to zero.  Right now if we lose power i look at the last count we recorded and type it in a text box on the screen,


What textbox?

 

0 Kudos
Message 8 of 12
(3,835 Views)

Oh yeah i misread the UPS statement.  Well could u show me how to write to a file, for saving purposes, then have the ability to call to that file to upload the counts before i begin to run the tests? Lets say the tests runs fine till 250,000 cycles then loses power.  So i turn back on the computer, load the file i saved with 200,000 counts, then my new vi starts adding the new counts to the existing 250,000?

 

 

TEXTBOX

 

I made a simple textbox on the front panel to remind me to add 210,000 to the counters cause that was the last time they reset.

0 Kudos
Message 9 of 12
(3,830 Views)

I can't because I have no idea where you're keeping track of this magic "count". Is it the number of iterations of the while loop? What if the "Read CAN" switch is off? I also don't understand where you're supposed to stick this magic count number into the program you uploaded. Can't be the "Numeric" control that you have on the front panel, since that controls the number of iterations of the for loop and that doesn't make much sense. I also don't see a textbox anywhere on the program you uploaded.

 

LabVIEW ships with examples on using the configuration file VIs. Open the Example Finder and search for "configuration". Look at the "Write Configuration Settings File" and "Read Configuration Settings File". It's pretty straightforward.

0 Kudos
Message 10 of 12
(3,827 Views)