Pages: [1] 2 3   Go Down
Author Topic: Is there Brown-out detection for Arduino Uno?  (Read 6108 times)
0 Members and 2 Guests are viewing this topic.
Nijmegen, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

See page 48 of the datasheet. When enabled, the processor resets if the voltage drops below the brown-out level.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33362
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3952
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Nijmegen, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
##############################################################
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?
« Last Edit: October 15, 2012, 04:02:57 pm by jrsikken » Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3952
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@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.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Nijmegen, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3952
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Nijmegen, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3952
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Better read this:

http://arduino.cc/forum/index.php?topic=64589.0
Logged

Nijmegen, Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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."
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 158
Posts: 2887
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: November 16, 2012, 02:16:58 pm by oric_dan(333) » Logged

Pages: [1] 2 3   Go Up
Jump to: