element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Atmega328p, eeprom burnout and interupts
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 10 replies
  • Answers 4 answers
  • Subscribers 394 subscribers
  • Views 862 views
  • Users 0 members are here
  • EEPROM
  • atmega328
  • burnout
Related

Atmega328p, eeprom burnout and interupts

Former Member
Former Member over 10 years ago

Dear Community

 

I build myself an atmega328 based temperature controller to actuate relays in order to control beer fermentation temperature in a fridge.  I am fairy happy with what I have so far.  The control works well, 2 buttons are used to change the desired temperature and two buttons are used to change the allowable range in witch to keep the fermentation temperature.  The temperature probe is a LM35 which is sealed with epoxy and heat shrink and is housed in a stainless steel probe submerged in the fermenting wort (you beer).  It takes 10 temperature reading in 40 ms as as average (this is to avoid resonance with 50 Hz AC power, I might be a fool, comment welcome), it then adds these averaged readings into a array creating a rolling average.  I have tested the temperature readings at our local electronics department (lucky to be in a university environment) and it is pretty close to truth.

 

In void loop I don't use delay, I rather use this kind of settup:

 

void loop() {
  //use millis for timing 
  unsigned long curMillis = millis();

  if (curMillis - prevMillis >= sleep){
    prevMillis = curMillis;

bla bal bla

 

sleep is set to 250 ms.  I have found that this works well with the buttons.

 

The problem:

Due to my lack of knowledge I am writing 4 times a second to eeprom addresses in order to save setting in case of a power interruption.  Just today I read about eeprom burnout.  So if I understand it correnctly:

100 000 / 4 = 25 000 ms, thus if the eeprom address gets burned out after 100 000 write events, then that address will only last for about 25 seconds.  So what happens now is that whenever there is  power interruption the set range seems to be anything random, like 124.3 deg C, which is not ideal for making beer.  I think a solution to this problem would be to only write to the eeprom if anything changes just by comparing the eeprom value to the current value in the loop, maybe also add timing - not sure.

 

I found some code here:

EEPROM advanced usage on Arduino Uno / ATMega328 | Michael Bouvy

"

  • Read / write operations on EEPROM should never be interrupted : you should always disable/clear interrupts (cli()) before any operation and re-enable/set interrupts after (sei()).

"

So in the link above it is suggested that one disables interrupts while writing.

 

From this link:

http://playground.arduino.cc/Main/AVR

"

Note that the millis timer, and serial communication will be affected by disabling interrupts. The delayMicroseconds() function disables interrupts while it is running.

"

 

What do you guys think?  I am not sure how millis timer and serial will be affected and also do you think it is that important to disable interrupts during during read write?  I know nothing about interrupts.  What would be best practice?

 

Thanks for reading.

  • Sign in to reply
  • Cancel

Top Replies

  • Former Member
    Former Member over 10 years ago +1
    Hello I think I have figured out a solution for my eeprom burnout problem and it is working fine so far, if it fails i will post it here. I now have an if statement that checks the current eeprom value…
Parents
  • Robert Peter Oakes
    0 Robert Peter Oakes over 10 years ago

    100000/4 is 25000 seconds not milliseconds if as you said your writing 4 times per second

     

    This would give you just under 7 hours, still not a lot

     

    Why are u writing it to eeprom and not just ram??. You could reduce the write to eeprom to once a minute as the process is so long if you lost1 minute of data aggregation it would have no significant affect

     

    Sent from my iPhone

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Robert Peter Oakes
    0 Robert Peter Oakes over 10 years ago

    100000/4 is 25000 seconds not milliseconds if as you said your writing 4 times per second

     

    This would give you just under 7 hours, still not a lot

     

    Why are u writing it to eeprom and not just ram??. You could reduce the write to eeprom to once a minute as the process is so long if you lost1 minute of data aggregation it would have no significant affect

     

    Sent from my iPhone

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • mcb1
    0 mcb1 over 10 years ago in reply to Robert Peter Oakes
    So what happens now is that whenever there is  power interruption the set range seems to be anything random, like 124.3 deg C

     

    There is no reason why you can't write the set temperature to the eeprom and then read it during the start process.

    I'd be including in void setup(), and you can check to see if the range is valid, and if not either stop the process or set it to something suitable, and drive an output, etc.

     

    I do question whether your sensor will actually change at all during the 40mS period, as the thermal mass alone would suggest it won't respond that fast.

    If the power goes out, your process will stop, and depending on how long it is before it resumes, the stored temp may have no bearing on the current temperature, so how storing the temperature affects the 'set' temperature, I'm not sure.

     

     

    The 100,000 write cycles is a minimum guarantee by the chip maker.

    If you hunt in the Arduino.cc forums, there was some experiments several years ago and they found it to exceed that by a factor of 10 or more, and that wasn't even optimizing the writing across the whole eeprom.

     

    As an alternative why not write when it changes by 0.x degrees, or even every 40th read (10 seconds)

     

    It looks like an interesting project so I hope you share the compete thing when you've resolved it.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube