Loading...
Pages: [1]   Go Down
Author Topic: How often to write to EEPROM  (Read 233 times)
0 Members and 1 Guest are viewing this topic.
California
Offline Offline
Sr. Member
****
Karma: 2
Posts: 408
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I will be using the EEPROM to store distance and time for a bike speedometer, and load them at startup in case of switching off. But switching off may not have a warning. These values will change just about every second, or even more at times. Is it safe/recommended to write to the EEPROM that often? Is there a finite amount of times it can be written to before failing? Should I limit it to writing only when the rider has stopped, so maybe once every few minutes? If it makes any difference I am storing two longs split up into the first 8 bytes of the EEPROM.

A second side question: If I plan to use power down sleep mode a lot, can I trust my variables to stay in tact or should I read from the EEPROM when waking from power down? I suppose if that was a problem, I would have bigger problems to worry about so I would assume that is not necessary.

Thanks
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 60
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello !

From the atmega328 datasheet: The EEPROM has an endurance of at least 100,000 write/erase cycles.

So suppose you want to write data every second it would last for about 27 hours. Not the best way to go

EEPROM is more intended for storing data which doesn't change that much, like look-up tables.

You might consider connecting a SD-card (with SD-shield) to your arduino and log your data to the card. This makes it easier to process the data on your computer as well.

Cheers !

Jack
Logged

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 31
Posts: 1179
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Always read the data that is in the eeprom and write only the changed bytes, there are macros that write data, but there is also newer additions that update:

Code:
eeprom_write_byte(); //Writes data, regardless of the eeprom value.
eeprom_update_byte(); //Writes only the bytes that are different to the eeprom contents.

Also by dividing your eeprom into two ( or more ) banks, and use them sequentially, you effectively double the lifetime you will get out of the eeprom.
Logged


Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 242
Posts: 16485
Available for Design & Build services
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can also use a FRAM chip (mouser.com)
Has non-volatilty of EEPROM, but waaay higher unendurance,10^14 write cycles,
and access speed of SRAM.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17

Grand Blanc, MI, USA
Offline Offline
Edison Member
*
Karma: 43
Posts: 2491
"We're a proud service of the Lost Electricity Reclamation Agency"
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can also use a FRAM chip (mouser.com)
Has non-volatilty of EEPROM, but waaay higher unendurance,10^14 write cycles,
and access speed of SRAM.

I was really wanting to try FRAM for a datalogger project I'm designing, but the cost is way out there. I can get 2Mb EEPROMs for about the same price as a 16KB (128Kb) FRAM. 2Mb FRAMs cost about 5.5 times as much as an EEPROM with equivalent capacity. For some reason I thought it was quite a bit more cost-effective than that. The EEPROM I'm looking at has 4M write-cycle endurance and 200-year data retention. Not even close to that of FRAM, but neither will I ever wear it out. Given the low-bandwidth nature of the thing, I doubt that the slower access speed will be a factor, either.

Anyhoo just disappointed in the pricing. If you come across any deals though, be sure and give a holler!
Logged

Get the infamous "One Million Ohms" board at tINDIE.com: http://tinyurl.com/BuyMohms

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 242
Posts: 16485
Available for Design & Build services
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've only seen the mouser pricing.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17

United Kingdom
Online Online
Faraday Member
**
Karma: 130
Posts: 4647
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It's not difficult to design the hardware to provide power to the mcu for a fraction of a second after the power supply is removed. Then you can have the mcu detect the loss of power and write to flash at that time.

To provide the reserve power, use a diode between the battery and the 5V (or whatever) regulator input, along with a large capacitor to ground. To detect loss of power, use a voltage divider feeding an analog input.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com

Grand Blanc, MI, USA
Offline Offline
Edison Member
*
Karma: 43
Posts: 2491
"We're a proud service of the Lost Electricity Reclamation Agency"
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've only seen the mouser pricing.

Yep that's where I was shopping.
Logged

Get the infamous "One Million Ohms" board at tINDIE.com: http://tinyurl.com/BuyMohms

Pages: [1]   Go Up
Print
 
Jump to: