Should I use brown out detection?

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good day!

I've a small device based on ATmega8A which is powered with 3 AAA batteries. Most of the time the MCU is in sleep mode. My program writes and reads from EEPROM (I've seen messages about EEPROM value corruptions due brown out, so I note this).

I've a couple of questions:

- Should I enable BOD fuses to prevent EEPROM corruption when batteries get low? Which value?

- Is there any simple way to detect that batteries became low? Will BOD help to stop MCU in such situation?

Thanks in advance!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Enable BOD. 2.7V should give more battery life.

Measure battery voltage with ADC. To do this use internal 2.56V reference for ADC. Then attenuate the voltage by two using a resistive divider. It might be possible to use an output pin and set it high to drive the divider. While it will not go to full Vcc, it will not consume power when not high. A bypass capacitor at the measure point may enable the use of a high impedance divider to minimize losses. Might need to correlate measured values to some minimum operating range.

Bypass capacitors at the battery may also help some when the batteries are low.

It all starts with a mental vision.

Last Edited: Sat. Jan 1, 2011 - 11:16 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

artvolk wrote:

- Should I enable BOD fuses to prevent EEPROM corruption when batteries get low? Which value?

Of course you should turn on BOD. What values are available and what do you think you should choose, when you are using three AAA batteries? What battery voltage are you expecting to see when they are full or empty? What clock frequency you are planning to use for the AVR? What supply voltages are needed for reliable operation at that speed?

artvolk wrote:

- Is there any simple way to detect that batteries became low? Will BOD help to stop MCU in such situation?

Thanks in advance!

BOD keeps the AVR in reset when supply voltage goes low enough. When and if it comes out of reset, you can read the reason it was reset from the MCUCSR.

If you need to know in advance the batteries are low for example to indicate that to user, you can use ADC to measure battery voltage against internal reference. Or actually the other way around, measure the internal reference against battery voltage.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
when batteries get low? Which value?

- Is there any simple way to detect that batteries became low?


Battery voltage monitoring may give a signal quite precisely.
You should provide battery specifications or look for corresponding discharge characteristics for batteries of Your choice.
Have BOD up is a good idea; fixed BOD level can be mismatched with specific battery cut out voltage, nevertheless. Second to Jepael.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Enable BOD. 2.7V should give more battery life.

Quote:

Of course you should turn on BOD.

Quote:

Second to Jepael.

You kids are pretty sure about that, it seems. So, on the old dinosaur Mega8, how many uA does the BOD consume? Does that make the difference between the batteries lasting virtually "forever"--the shelf life of the batteries; say 5-10 years--and a replacement set every few months?

Does the 8A have the picoPower "sleeping BOD"?

-- Niggardly power usage could be the one reason I might recommend no BOD.
-- Then you have to devise other means to ensure that regular operation is discontinued when supply V is too low.
-- Why not use an 88P or 88Pa or equivalent, end get the sleeping BOD and pass muster with the other recommendations and still conserve power?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

KitCarlson wrote:

Enable BOD. 2.7V should give more battery life.

Why enabling BOD will give more battery life? Will MCU use less power with BOD enabled?

KitCarlson wrote:

Measure battery voltage with ADC. To do this use internal 2.56V reference for ADC. Then attenuate the voltage by two using a resistive divider. It might be possible to use an output pin and set it high to drive the divider.

Thanks for the tip, it seems to be an elegant solution!

KitCarlson wrote:

Bypass capacitors at the battery may also help some when the batteries are low.

Yes, I have one 0.1uF on power lines.

Jepael wrote:

What values are available and what do you think you should choose, when you are using three AAA batteries? What battery voltage are you expecting to see when they are full or empty? What clock frequency you are planning to use for the AVR? What supply voltages are needed for reliable operation at that speed?

That's average AAA batteries (not accums), so I have no specs. Brand new they give 4.8V. About speed grades, that's from ATmega8A datasheet:

theusch wrote:

So, on the old dinosaur Mega8, how many uA does the BOD consume?

The "A" version I use seems to be improved (picoPower etc.), but I haven't found any notices about sleeping BOD in datasheets. Right now when MCU is in sleep I can't measure supply current with my cheap multimeter (it seems to be too low, nA?).

theusch wrote:

-- Why not use an 88P or 88Pa or equivalent, end get the sleeping BOD and pass muster with the other recommendations and still conserve power?

Unfortunatelly 48/88/168/328 series is not available in my location right now (yep, supply shortages of Atmel, prices are high), so I grab what they have.

Thanks for the responses! What about EEPROM corruption?

Edit:

From 48/88/168/328 datasheet:

Quote:

When the Brown-out Detector (BOD) is enabled by BODLEVEL fuses - see Table 27-7 on page
298 and onwards, the BOD is actively monitoring the power supply voltage during a sleep
period. To save power, it is possible to disable the BOD by software for some of the sleep
modes, see Table 9-1 on page 39. The sleep mode power consumption will then be at the same
level as when BOD is globally disabled by fuses. If BOD is disabled in software, the BOD function
is turned off immediately after entering the sleep mode. Upon wake-up from sleep, BOD is
automatically enabled again. This ensures safe operation in case the VCC level has dropped during
the sleep period.

Note: 1. BOD disable only available in picoPower devices ATmega48PA/88PA/168PA/328P

ATmega8A doen't have this... :(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

artvolk wrote:
KitCarlson wrote:

Enable BOD. 2.7V should give more battery life.

Why enabling BOD will give more battery life? Will MCU use less power with BOD enabled?

No, that is exactly why I asked about your voltages and speeds. If you must choose between 2.7V and 4.0V BOD with three AAA batteries, 2.7V is the right one to choose, and you can use 8MHz speed for the whole range.

What I did not take into consideration but others did, is the fact that the chip consumes more current with BOD on.

artvolk wrote:

KitCarlson wrote:

Measure battery voltage with ADC. To do this use internal 2.56V reference for ADC. Then attenuate the voltage by two using a resistive divider. It might be possible to use an output pin and set it high to drive the divider.

Thanks for the tip, it seems to be an elegant solution!

Since the battery voltage is directly AVR supply voltage, you don't need any voltage divisors or other external components. Just measure the internal 2.56V voltage by setting supply voltage as ADC reference.

artvolk wrote:

KitCarlson wrote:

Bypass capacitors at the battery may also help some when the batteries are low.

Yes, I have one 0.1uF on power lines.

It depends on what else your device needs to do, but I really suggest putting something like 4.7 or 10 uF there too.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Since the battery voltage is directly AVR supply voltage, you don't need any voltage divisors or other external components. Just measure the internal 2.56V voltage by setting supply voltage as ADC reference.

Wow. I haven't think it is even possible. How I can measure internal reference 2.56 voltage having supply voltage as a reference?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

artvolk wrote:
How I can measure internal reference 2.56 voltage having supply voltage as a reference?

Actually, in the AtMega8A, the 2.56 volt reference is not available as an A/D input, but there is a 1.3v bandgap voltage. You simply change the ADMUX register to select the band gap voltage ( MUX3..0 bits ) and use AVCC as the reference ( REFS1..0 bits ). Then when you do a conversion the result will be the ratio of the battery voltage and the band gap voltage. For instance, if the battery is new ( 4.8v ) and you are reading the 10-bit ADC value, it should read 1024 * ( 1.3 / 4.8 ) = 277; when the battery has fallen to 3v it should read 1024 * ( 1.3 / 3.0 ) = 443. Note, however, that I said "should". The 2.56v reference ( which is generated from the 1.3v bandgap ) has a min/max range of 2.3v - 2.8v ( not quite 2.56v... ), that wide span is a result of the underlying bandgap. So, if you want accuracy, calibration will be required; even without, though, it gives you a reasonable idea of battery charge.

Martin Jay McKee

As with most things in engineering, the answer is an unabashed, "It depends."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you a lot for the explanation, it seems I got it now.

Here are reference for googlers:

and this: