Nijmegen, Netherlands
Offline
Newbie
Karma: 0
Posts: 19
|
 |
« on: October 15, 2012, 03:13:18 pm » |
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? I read http://arduino.cc/forum/index.php/topic,49044.0.htmlAnd 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
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13896
Lua rocks!
|
 |
« Reply #1 on: October 15, 2012, 03:31:04 pm » |
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
Brattain Member
Karma: 277
Posts: 25556
Solder is electric glue
|
 |
« Reply #2 on: October 15, 2012, 03:39:27 pm » |
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
Faraday Member
Karma: 43
Posts: 2518
"We're a proud service of the Lost Electricity Reclamation Agency"
|
 |
« Reply #3 on: October 15, 2012, 03:47:56 pm » |
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
|
|
|
|
|
Nijmegen, Netherlands
Offline
Newbie
Karma: 0
Posts: 19
|
 |
« Reply #4 on: October 15, 2012, 03:58:31 pm » |
Yes I've read p48 of the datasheet and I'm using 5V through USB. I found boards.txt in the IDE? It says: ############################################################## 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
Faraday Member
Karma: 43
Posts: 2518
"We're a proud service of the Lost Electricity Reclamation Agency"
|
 |
« Reply #5 on: October 15, 2012, 04:09:28 pm » |
@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
|
|
|
|
|
Nijmegen, Netherlands
Offline
Newbie
Karma: 0
Posts: 19
|
 |
« Reply #6 on: October 15, 2012, 04:12:13 pm » |
@Jack, thanks for your reply! I will try tomorrow. Now it's bedtime!
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13896
Lua rocks!
|
 |
« Reply #7 on: October 15, 2012, 04:32:59 pm » |
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=11638http://www.gammon.com.au/forum/?id=11635
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13896
Lua rocks!
|
 |
« Reply #8 on: October 15, 2012, 04:50:04 pm » |
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
Faraday Member
Karma: 43
Posts: 2518
"We're a proud service of the Lost Electricity Reclamation Agency"
|
 |
« Reply #9 on: October 15, 2012, 05:02:57 pm » |
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
|
|
|
|
|
Nijmegen, Netherlands
Offline
Newbie
Karma: 0
Posts: 19
|
 |
« Reply #10 on: October 16, 2012, 02:17:58 am » |
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
Faraday Member
Karma: 43
Posts: 2518
"We're a proud service of the Lost Electricity Reclamation Agency"
|
 |
« Reply #11 on: October 16, 2012, 07:28:25 am » |
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
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13896
Lua rocks!
|
 |
« Reply #12 on: October 16, 2012, 02:40:30 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
Nijmegen, Netherlands
Offline
Newbie
Karma: 0
Posts: 19
|
 |
« Reply #13 on: November 16, 2012, 02:02:46 pm » |
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
Edison Member
Karma: 81
Posts: 2137
|
 |
« Reply #14 on: November 16, 2012, 02:14:54 pm » |
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.htmlI 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
|
|
|
|
|
|