Idea for hardware reset on power failure

Hello,

I'm working on an Arduino project which operates in a harsh power environment. What I mean by that is it will frequently (and suddenly) lose power for a few moments. What I need to solve is how to trigger a reset after the power failure occurs. Once power is (very momentarily) cut, it seems like my Arduino will not resume the program until the reset button is physically pressed.

My idea to solve this is: create a separate circuit which uses a 555 timer to generate a very slow ON/OFF pulse. A transistor with the base connected to a logic inverter. Which is connected to a digital output pin on the Arduino.

IE: Arduino will always set the "working" pin HIGH. But when it loses power, the "working" pin will be pulled low. Which the digital inverter will use to turn on the transistor, which will be used to power a 555 timer, which will pulse the reset pin.

This can't be the most elegant solution, but I suspect it might work. Any advice or alternative suggestions would be greatly appreciated!

Thank you for your time.

Try activate internal BOD if it is not active.

EDIT: what means " Arduino will not resume the program"? It is possible decoupling caps on Arduino board covers the power glitch and Arduino keeps working (and does nothing because it don't know it is time to start again). In this case internal BOD won't help.

That's why the Arduino (at least the standard AVR ones) have a Brown Out Detect which will keep the Arduino in reset while the voltage is low. On most Arduino's (Uno, Mega, Pro Mini, Nano) it is set to the highest voltage (aka, most sensitive).

On other option would be to simple decouple the Arduino enough so it keeps running...

A small backup battery would work.

Allan

But we don’t know where the problem is. Maybe problem is in Arduino decoupled too well: power glitch may reset some peripherals but not the Arduino itself leading to need for manual reset to reconfigure the peripherals to work again. But it is just a guess - we cannot know until OP gives more details. In fact it looks like very viable explanation if the BOD is enabled.

If the power comes back up too slowly, the internal reset circuitry may not function correctly (the data sheet parameter is SRon, the power on slope rate, which is specified as 0.01 V/ms minimum).

An external reset supervisor might help.

jremington:
If the power comes back up too slowly, the internal reset circuitry may not function correctly (the data sheet parameter is SRon, the power on slope rate, which is specified as 0.01 V/ms minimum).

An external reset supervisor might help.

Which datasheet are you referring to? I'd like to check it out. Thanks!

Smajdalf:
But we don't know where the problem is. Maybe problem is in Arduino decoupled too well: power glitch may reset some peripherals but not the Arduino itself leading to need for manual reset to reconfigure the peripherals to work again. But it is just a guess - we cannot know until OP gives more details. In fact it looks like very viable explanation if the BOD is enabled.

Thank you for all your suggestions! I apologize I should have mentioned in my original post that my Arduino is not a standard build. It is just an ATMega328p with the Arduino bootloader/etc flashed. I need to understand a bit more how BOD works and if it is a function of the ATMega chip or software driven or what. Hopefully it is something I can easily tweak as I suspect the range may not be what I want.

Which datasheet are you referring to?

The ATMega328 data sheet, where you will find a detailed discussion of the brownout detector, plus everything else of interest about the processor.

BOD is a circuit inside the ATMega that constantly monitors voltage. If the voltage is too low (level may be selected by fuses) it causes reset until voltage is high enough. Septilion says Arduino uses BOD - AFAIK Arduino IDE sets fuses when "burning bootloader" but I don't know details - I am setting them manually via avrdude. Using Arduino as ISP sketch and avrdude is quite easy, you may verify if fuses are set to highest voltage BOD. If not, you need to do so. If BOD is set problem is probably in Arduino keeps running despite glitch. In that case you need to monitor voltage outside your board (the ATMega is probably hidden behind "too good voltage regulator") and do what needs to be done if power glitch happen. You may use internal analog comparator (that is part of ATMega too).

Fuses from boards.txt

uno.bootloader.low_fuses=0xFF
uno.bootloader.high_fuses=0xDE
uno.bootloader.extended_fuses=0xFD

So I'm incorrect ::slight_smile: BOD is set to 2,7V

Thank you everyone!

I poked around in boards.txt and did see the fuse settings for BOD. I tried using different settings because my Arduino was apparently set at 3.3v instead of 2.7v. So that was good to know.

But I finally found the real underlying issue...

Smajdalf:
But we don't know where the problem is. Maybe problem is in Arduino decoupled too well: power glitch may reset some peripherals but not the Arduino itself leading to need for manual reset to reconfigure the peripherals to work again. But it is just a guess - we cannot know until OP gives more details. In fact it looks like very viable explanation if the BOD is enabled.

This is exactly what was happening. The Arduino was fine but the peripheral was not taking the spontaneous power-down very well. This is much easier to fix than an external reset circuit - thankfully!

Thanks for all the insight! I learned a lot :slight_smile: