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
  • Former Member
    0 Former Member over 10 years ago

    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 against the sram value and if it is the same nothing gets written to eeprom, thus conserving eeprom write events.  Also, an if statement that will only allow eeprom write if all buttons are LOW.  These four buttons are used to change the set temperature and the allowable range.  So, while any button is pressed to change the setting, eeprom write cycles are not wasted while values are incremented or decremented and it is only updated to eeprom when the button is released.

     

    Thank you for all the help and suggestions.  Hopefully the problems are solved now and some good beer can be brewed.  I am still looking at brown out detection, as far as I understand if the voltage drops while a write event is taking place, that can also cause problems.

     

    Armand

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 10 years ago

    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 against the sram value and if it is the same nothing gets written to eeprom, thus conserving eeprom write events.  Also, an if statement that will only allow eeprom write if all buttons are LOW.  These four buttons are used to change the set temperature and the allowable range.  So, while any button is pressed to change the setting, eeprom write cycles are not wasted while values are incremented or decremented and it is only updated to eeprom when the button is released.

     

    Thank you for all the help and suggestions.  Hopefully the problems are solved now and some good beer can be brewed.  I am still looking at brown out detection, as far as I understand if the voltage drops while a write event is taking place, that can also cause problems.

     

    Armand

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • mcb1
    0 mcb1 over 10 years ago in reply to Former Member

    Sounds like sensible changes.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify 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