Im working on a project that requires counting cycles on the order of millions and saving the value in case there is a power failure or in case the machine is turned off at the end of the day and restarted in the morning, to continue counting from where it left.
The set up consist on an absolute encoder coupled to a shaft of the machine. That gives the angular position of the shaft, needed to take certain decisions. (that part is up and running no problem) Th same encoder is used to count the cycles, every time it crosses zero degrees, adds one to the counter. (no problem with that part it is up and running) I need the value of the counter saved to the EEPRMO (or other device) and read it back at power up so that the counter can continue where it left. (no problem with that, it is up and running)
The problem that Im not sure how to dela with, is the number of write cycles of the EEPROM (100,000).
The machine Im working on, runs aprox. 60,000 cycles per day, so 100,000 will be reached aprox. in one and a half days.
I researched on EEPROM ware leveling, but it is hard for me to understand how it works and how to write de code. (not a lot of experience programming)
I have though on using an external EEPROM which can be changed when worn. (not very elegant solution)
I have though on using an external storage devices that can handle way over 100,000 cycles (not sure which)
Im sure there are better ways to handle this, but my knowledge is very limited.
I will very much appreciate if someone can point me in the right direction.
Thanks so much in advance,
Regards
Felipe
Are you talking about 1 cycle per second? (60.000 -- 86.400 seconds/day)
Here´s an idea, maybe it´s useful:
You could use 2 bytes of EEPROM per day, saving unsigned integers (up to around 65.5K) every 2 bytes of EEPROM.
The next day, shift the saving to the next 2 bytes... and so on.
You could use the first bytes of EEPROM as a) pointer to where in EEPROM are you storing data for the current day, plus b) a long integer with total of the cycles stored (you only increment it once a day, with the current day total, before shifting to the next pair oy bytes in EEPROM).
With 1024 bytes of EEPROM you could save about 500 days of data. Then, you just replace the Arduino!
This post really opened my eyes. Can I instal a very small Lipo battery as a back up to have a chance to save to the EEPROM whenever the power goes off, either for a power failure or for machine turned off.
In that way, I will only write to the EEPROM 1 or maybe 2 times per day.
Right now I write to the EPPROM every cycle, about every second.