Trossen Force Sensor  Top Banner
Results 1 to 5 of 5

Thread: Arduino Uno Brown-Out Detection Software

  1. Arduino Uno Brown-Out Detection Software

    How do I use the brown-out detection that is apparently built into the Arduino Uno? I need to save off eeprom before the power goes completely off, and do not want to write to eeprom unless/until it is necessary.

    I've seen some data on setting trigger voltages and stuff (fuses?), but I am completely unsure of how to execute code when the brown-out occurs. I'd hope this could be set up somewhat like the external interrupts. I don't want to continuously check some memory value. I'm currently using interrupt 0 to watch for a button push. Interrupt 1 is available, but I'm guessing the brown-out capability in the Arduino is going to function differently from those 2 external interrupts.

  2. #2
    Join Date
    Apr 2012
    Posts
    1,787
    Images
    25
    Rep Power
    58

    Re: Arduino Uno Brown-Out Detection Software

    I recommend reading the Atmel Atmega328p data sheet. It describes exactly how the brown-out detector works, starting on page 47 (in the copy I have -- may move based on errata)

    Unfortunately, I don't think the built-in brown-out detector will work for your needs -- it works by pulling the internal RESET signal when the voltage goes too low; this won't let you actually get any time to execute any code.
    You can build an external brown-out detector which triggers an interrupt when voltage goes low, and if you put a big capacitor across +5V and GND, you will have enough cycles left to do something before it runs out. Tuning this detector so it's not too sensitive (going off as a false positive) yet still gives you enough time to run, might be a challenge.

    A simpler option is to simply write what you need to EEPROM every five minutes or so, plus/and/or when "important" events have happened and need to be remembered. With 100,000 write cycles, and 5 minute intervals, that gives you about a year before the EEPROM wears out at its rated 100,000 cycles. You can write level sections of EEPROM by cycling through base addresses, for significantly longer time (depending on how small your data is.)

  3. Re: Arduino Uno Brown-Out Detection Software

    Thank you! Your response was excellent and quick. Are you sure about the 100,000 rewrite cycles for eeprom and that that limit is per byte?

    I have read p47, but it left me with more questions than I started. I'm not real confident in that space, but was coming up with the same conclusion as you: this won't do what I want, because it is a "reset" trigger, not set up to register an emergency-interrupt service function that would fire off on a brown-out.

    My critical cycle time is probably going to be no less than 1/2 hour, so 100,000 cycles would then last 5.7 years (my app runs 24/7/365). We're still in R&D, and the truth is that 1/2 hour is currently only a guess.

    Originally I was told 1,000 cycles was the rewrite limit on this eeprom, not 100,000 cycles, so I was also wondering then about changing my base address just like you suggested, but didn't know if the cycle limit was byte-based, or if the cycle limit was true for all eeprom writes, no matter where the data goes.

    My crucial data is only 2-4 bytes, so if I can write 100,000 cycles to those bytes and then move my base, the eeprom would be good for decades/centuries, which of course would be totally fine. It would then be a lot better and easier to use this 100,000-rewrite design (maybe with base addressing), instead of the brown-out interrupt design.

    So again, may I ask, are you sure about the 100,000 rewrites and the per-byte granularity of that eeprom limit?

  4. Trossen Desktop RoboTurret Thread Banner
  5. #4
    Join Date
    Sep 2010
    Location
    ಠ_ಠ
    Posts
    1,385
    Images
    25
    Rep Power
    54

    Re: Arduino Uno Brown-Out Detection Software

    For the most popular AVR's (ATmega48/88/168/328 - Arduino, ATmega164/324/644/1284 - arbotix, and ATmega1281/2561/1280/2560 - ArduinoMega/CM-5/CM-510/CM-700), the EEPROM is byte writable and byte readable with 100,000 Erase/Write cycles, while the FLASH memory is page/sector writable and byte/word readable with 10,000 Erase/Write cycles. There are several less popular/specialized AVR's that only get 1000~2000 Erase/Write cycles for both EEPROM and FLASH (ATmega128RFA1).
    Please pardon the pedantry... and the profanity... and the convoluted speech pattern...
    "You have failed me, Brain!"

  6. #5
    Join Date
    Apr 2012
    Posts
    1,787
    Images
    25
    Rep Power
    58

    Re: Arduino Uno Brown-Out Detection Software

    EEPROM write cycles are typically per "page" of EEPROM, although it seems the AVR EEPROM (at least the 328p) has a page size of one byte -- I can see nothing else in the data sheet.

    I would still come up with a timestamp and CRC for each piece of data. With a four-byte timestamp, four-byte data, and two-byte CRC, this means 10 bytes per item, so 102 items in EEPROM. If you cycle through them like this, you'll presumably extend lifetime by 102 times, so even a once-a-minute write will let the EEPROM last approximately 20 years.

    You should probably try to contact an Atmel development representative at some point, though -- I don't know whether 100,000 writes is "MTBF" or "guaranteed" or whatever, and whether it depends in any way on temperature and operating environment. Also note the warning about writing during brown-out. Easiest is to set the brown-out reset to 4.7V and not worry about it :-) But with a good CRC algorithm, you'll typically not have a problem with corrupt data, as it would simply be treated as "not written."

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Question(s) Arbotix and Arduino Software Serial Library
    By Jules in forum Arbotix, Microcontrollers, Arduino
    Replies: 4
    Last Post: 06-21-2012, 10:19 AM
  2. Piezo Impact Detection?
    By byi in forum Mech Warfare
    Replies: 6
    Last Post: 09-18-2011, 02:18 PM
  3. Trouble with brown outs
    By billyzelsnack in forum Power
    Replies: 11
    Last Post: 12-28-2010, 07:28 AM
  4. M. Carter Brown smallest paintball gun contest
    By Electricity in forum Off Topic
    Replies: 8
    Last Post: 07-10-2008, 01:13 PM
  5. Crack detection
    By Blinkers in forum Sensors
    Replies: 17
    Last Post: 06-27-2008, 12:05 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •