Go Down

Topic: Is there Brown-out detection for Arduino Uno? (Read 7349 times) previous topic - next topic

jrsikken

I have implemented a watchdog timer to restart my Arduino Uno when the code hangs. But I also want to avoid to run code when the voltage drops too much. Is there Brown-out Detection (BOD) for Arduino Uno? :smiley-eek:
I read http://arduino.cc/forum/index.php/topic,49044.0.html
And also found this fuse calculator http://www.engbedded.com/fusecalc.
But still I'm not sure how to set the BOD in a sketch.

Nick Gammon

See page 48 of the datasheet. When enabled, the processor resets if the voltage drops below the brown-out level.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Grumpy_Mike

Quote
I have implemented a watchdog timer to restart my Arduino Uno when the code hangs.

It is much better to write proper code in the first place.

But yes a brownout detector is available. However you can only run this on an arduino powered by 5V as 3V3 is below the brownout threshold.

Jack Christensen

The brown-out detector can be set for 1.8, 2.7 or 4.3V via the extended fuse byte. Arduino Unos are set for the 2.7V level. I'm currently working on a project where it was beneficial to change it to 4.3V.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

jrsikken

#4
Oct 15, 2012, 10:58 pm Last Edit: Oct 15, 2012, 11:02 pm by jrsikken Reason: 1
Yes I've read p48 of the datasheet and I'm using 5V through USB.
I found boards.txt in the IDE? It says:
Code: [Select]

##############################################################
uno.name=Arduino Uno
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=stand
###########################################################

According to http://www.engbedded.com/fusecalc I should change the extended fuses from 0x05 to 0xFC to get 4.3V level.
Let's try that.... but now what? Is that it? Do I need to burn a bootloader?

Jack Christensen

@jrsikken, either change the boards.txt file then burn the bootloader (which also burns the fuse bytes) or just change the one fuse byte with AVRDUDE.

BTW, the top five bits of the efuse sort of "aren't there", so setting the efuse to 0x04 turns out to be the same as 0xFC.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

jrsikken

@Jack, thanks for your reply! I will try tomorrow. Now it's bedtime!

Nick Gammon


According to http://www.engbedded.com/fusecalc I should change the extended fuses from 0x05 to 0xFC to get 4.3V level.
Let's try that.... but now what? Is that it? Do I need to burn a bootloader?


That's one way, although you can change the fuses on their own. You need an ICSP programmer to do either. You can use another Uno for that.

Example:

http://www.gammon.com.au/forum/?id=11638

http://www.gammon.com.au/forum/?id=11635
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon


The brown-out detector can be set for 1.8, 2.7 or 4.3V via the extended fuse byte. Arduino Unos are set for the 2.7V level. I'm currently working on a project where it was beneficial to change it to 4.3V.


Isn't 2.7V a bit low? At 16 MHz the processor requires 3.78V. So it would become unreliable before the brown-out reset kicked in.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Jack Christensen



The brown-out detector can be set for 1.8, 2.7 or 4.3V via the extended fuse byte. Arduino Unos are set for the 2.7V level. I'm currently working on a project where it was beneficial to change it to 4.3V.


Isn't 2.7V a bit low? At 16 MHz the processor requires 3.78V. So it would become unreliable before the brown-out reset kicked in.


Agree completely, but it is what it is!
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

jrsikken

Page 54 of the datasheet shows that I can read a brown-out reset flag. And also the watchdog reset flag. That's nice to monitor.

Jack Christensen


Page 54 of the datasheet shows that I can read a brown-out reset flag. And also the watchdog reset flag. That's nice to monitor.


I hope someone else can confirm, but I think the bootloader may get in the way of that.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Nick Gammon

Better read this:

http://arduino.cc/forum/index.php?topic=64589.0
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

jrsikken

Welcome back all, I tried changing the extended fuses from 0x05 to 0xFC in boards.txt to get 4.3V level, but it did not work. It showed error :  ***failed;  avrdude: verification error, first mismatch at byte 0x0000 0xfc != 0x04 avrdude: verification error; content mismatch. Then I tried to change extended fuses to 0x04, then it worked! Thanks to the comment of Jack Christensen : "BTW, the top five bits of the efuse sort of "aren't there", so setting the efuse to 0x04 turns out to be the same as 0xFC."

oric_dan

#14
Nov 16, 2012, 08:14 pm Last Edit: Nov 16, 2012, 08:16 pm by oric_dan(333) Reason: 1
I don't know about the watchdog issue, but I just went through the brownout business a couple of days
ago. This info is VERY difficult to track down, no matter what anyone says, and the bits and pieces are
scattered all over the darn place. See Post #16 on the following thread,

http://arduino.cc/forum/index.php/topic,132124.msg995031.html

I have it as 2.7V, assuming I actually did find the correct source [jeesh], but this explains why I am able
to run my Duemilanove and UNO chips at both 5V and 3.3V.

Go Up