Author Topic: What happens when the power goes out?  (Read 3710 times)

syrinxtech

  • Sr. Member
  • ****
  • Posts: 347
  • Country: us
    • Syrinx Technologies
What happens when the power goes out?
« on: February 08, 2016, 10:43:45 AM »
I have a question about a behavior that I've seen over and over that occurs when the power goes away from a running Moteino.  I think I know the answer and the cause but I wanted to get some confirmation from those with more experience than myself.

If a Moteino is running with a battery and it drops below the minimum voltage needed to run the Moteino, it obviously stops working.  However, if there is a solar panel recharging the battery the Moteino will not start running again until it is either reset or the battery is removed/replaced.  My first thought was that it should start running the sketch as soon as the battery voltage reached the minimum required.  Is it like a car, that once the gas runs out and the car stops that you have to replace the gas and restart the car? 

I could see situations where a battery-powered device in the field using a solar panel for charging could drain enough to cause the Moteino to shut down and then when the sun came back and the battery recharged that it would hopefully start working without intervention.

Does BOD play a part in this equation?


WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: What happens when the power goes out?
« Reply #1 on: February 08, 2016, 12:27:15 PM »
If BOD is enabled, it will force a reboot if voltage drops below threshold (fuse selectable to 4.3V, 2.7V or 1.8V).  That's why you sometimes encounter "boot loops" when voltage is too low.

If BOD is disabled and voltage dips below 1.8V, I'm not sure if there are any guarantees as to what will happen.  I suspect you run the risk of it getting stuck in some weird state, not to mention corrupting it.  The BOD exists to prevent that kind of bad stuff from happening.  Which raises an interesting point: maybe it's best not to disconnect power to a Moteino that's sleeping with BOD disabled?

Note that if you're using the bolt-on flash memory, it's not rated for use below 2.3v.  The atmega (at a lower frequency) and the SX1231H are both rated down to 1.8v, and the RFM69's datasheet claims the RFM69 is rated to operate as low as 1.8v as well.

If someone else can add more detail, feel free to jump in.
« Last Edit: February 08, 2016, 01:25:29 PM by WhiteHare »

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: What happens when the power goes out?
« Reply #2 on: February 08, 2016, 06:31:21 PM »
My guess is that your Moteino draws more current while rebooting than the solar cell can deliver. One likely culprit: the radio. The radio draws a couple of mA while booting up, the 328p does too and together that might just be enough.

Happens with coin cells all the time, too. Best thing you can try is to start up with 1Mhz (set by fuse), sleep the radio immediately after boot (preferably in the bootloader) and wait for VCC to recover. But even that might not be enough.

In technical terms the 328p triggers power on reset at I believe 1.3V, so even if the BOD is off (as it is during low power sleep for example) a clean reset should always happen if there's enough power to do so. See https://lowpowerlab.com/forum/index.php/topic,1579.0.html.

Joe

SanG

  • NewMember
  • *
  • Posts: 43
Re: What happens when the power goes out?
« Reply #3 on: June 17, 2019, 12:01:24 PM »
I know it's been a while since the last post on this thread but just giving a shot..
 - By default, is BOD enabled or disabled in moteinos?

I am also running similar issue with moteino not turning on itself even when the input voltage reaches and crosses the 3.6V after turning off for a while. I am powering the moteino with the supercapacitors (scaps) with solar panel. Every now and then the voltage of the scaps go below the min voltage of moteino but in the morning the panel should charge the scaps easily within an hour to reach 4.0V or higher. But still the moteio does not turn on. I have to go in person and plug in/plug out either the scaps or the moteino itself. I researched little bit and found out that it could be because of the BOD fuse settings. But I don't know much about it. My question is: is BOD enabled by default or disabled in the moteino?

If the BOD is not enabled by default, should I enable it? If yes what is the BODLEVEL fuse: 4.3, 2.7, 1.8 or any other if (possible)?

Sorry for replying in such an old post.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: What happens when the power goes out?
« Reply #4 on: June 17, 2019, 12:35:15 PM »
BOD enabled by default. 2.7V for all AVR Moteinos, 1.8V for the 8Mhz AVR Moteinos.
BOD Can be disabled in firmware.

SanG

  • NewMember
  • *
  • Posts: 43
Re: What happens when the power goes out?
« Reply #5 on: June 17, 2019, 01:00:11 PM »
Thanks for the quick reply Felix.

BOD fuse preset (by default) at 2.7V: Does this mean if the supply voltage of moteino goes below 2.7V, it should turn it back on automatically as the voltage reaches higher than 2.7V. Please note that I am using supercapacitors (can charge up to ~4.8V and discharge down to ~1.7V) to supply moteino. In other words, the Vin pin of moteino can get as high as ~4.8V or as low as ~1.7V. I am using a solar panel to recharge the scaps.
The reason I am asking this question is that I have had many times that the moteino did not turn back on automatically even after the supply voltage reaches higher than 4.0V.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: What happens when the power goes out?
« Reply #6 on: June 17, 2019, 01:10:34 PM »
BOD means it will keep the chip in POR while voltage is below the BOD voltage.

Your solar cell is there not to supply direct power to the Moteino, but to keep the supercap charged, which would in turn supply the bulk of current to the load (Moteino). That should be a nominal 4-5V. The solar cell (and sun exposure) should be sized to be able to keep the load powered up. a drop from 5V to 1.7v tells me your cell/supercap is too small, or underexposed and can't keep up with the load demand.

Electronics sometimes is more than plug and play, need a little math or basic calculations to ensure the project will survive beyond the bench.

SanG

  • NewMember
  • *
  • Posts: 43
Re: What happens when the power goes out?
« Reply #7 on: June 17, 2019, 02:09:03 PM »
Hello Felix, that was just an example trying to clarify the possible range of voltage level that my moteino is getting. My system does not have a drop from 5V to 1.7V over a night or two. I am sorry I didn't make myself clear about the choice of solar panel, scaps etc. I will explain that later (if you want).

What I am really trying to figure out is whether a moteino should turn back on automatically when the Vin raises and crosses (let's say) 4.0V? It is not about the solar panel only this phenomenon occurs in my LAB also. Let me explains my simple LAB set up (see circuit diagram below):
1. Two 3.0V 50F Scaps (in series) are powering moteino.
2. The +ve leg of the Scap1 is connected to Vin of the moteino.
3. The -ve leg of the Scap2 is connected to GND.
4. A 0-6V, 2.5A Agilent dc power supply is charging the scaps.
5. A 1 Ohm, 10 W power resistor is connected in between power supply and scaps.

Observations:
1. Moteino simply works fine when the voltage (Vin or Vc) is above ~3.3V.
2. I disconnect the power supply when the Vc reaches about 4.0V.
3. Then I discharged the scaps to about 2.9V using low-value high power resistor such as the one in the circuit.
4. After that, the scaps discharges rapidly itself.
5. When the Vc = 2.0V, the power supply is connected again.
6. Then the scaps start to charge again.
7. The moteino does not turn on even when the Vc reaches 2.7V, then to 3.0V, then to 3.6V and so on..

Questions:
1. Is this supposed to happen?
2. Why is this happening?
3. What should I do to turn it back on automatically?

Any suggestion, solution will be greatly appreciated.

Thank you

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: What happens when the power goes out?
« Reply #8 on: June 17, 2019, 02:53:08 PM »
The LDO on the Moteino can account for what you're seeing.
It expects 3.3v + dropout voltage which varies with load.
I would try to nsure the VIN is at least 3.5V under normal use.

SanG

  • NewMember
  • *
  • Posts: 43
Re: What happens when the power goes out?
« Reply #9 on: June 17, 2019, 03:07:30 PM »
Thanks again. So in the above example, is it normal for the moteino to not turn back on even when the input voltage (Vin of moteino) reaches 4.0V or even higher? In my simple experiment (explained above) the moteino did not turn on even when the Vin reached 4.8V. Is it normal?

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: What happens when the power goes out?
« Reply #10 on: June 17, 2019, 03:15:10 PM »
It's not normal. Not if there is enough current that it would be able to power up again.
As the scaps are charged, they should be able to provide that current.

How about if you just power the Moteino directly from the PSU. WHen does it BOD and when does it power up again from BOD?

SanG

  • NewMember
  • *
  • Posts: 43
Re: What happens when the power goes out?
« Reply #11 on: June 17, 2019, 05:31:35 PM »
Thanks for the idea Felix. I tried that (PSU powering moteino directly) too. But no luck.
- BOD starts at ~2.8V
- Does not power up again even when the voltage exceeds 4.5V.

But one thing I noticed is that when I started to increase the supply voltage from less than 1.8V (such as 1.45V), then the moteino does not power up again even when the voltage reaches 4.5V.
But when I started to increase the supply voltage from greater than 1.8V (such as 2.1V), then the moteino powers up again.

I did this expt. with the PSU multiple times and all the results are the same.
I repeated the same expt. with Scaps and again all the results are the same.

Any suggestion about this weird behavior.

Thank you.
« Last Edit: June 17, 2019, 10:18:26 PM by SanG »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: What happens when the power goes out?
« Reply #12 on: June 18, 2019, 09:17:04 AM »
Yeah, mind the fact that there are other components on the Moteino not just the atmega328p. Like ... the radio, the flash. All those also have some limits.
So if you BOD those, they might not power up again, and even if the MCU wakes up and tries to talk to them, they don't respond, and the MCU is locked up trying, and makes it look like it's in BOD.
It's known that the radio can work down to about 1.8V.

SanG

  • NewMember
  • *
  • Posts: 43
Re: What happens when the power goes out?
« Reply #13 on: June 18, 2019, 07:52:28 PM »
Attached is the BOD voltage test result for 3-different versions of moteino I have (R3, R4 and R6). The test is in accordance with the same circuit I mentioned before (also attached here). Let me explain the test briefly: Two 3.0V 50F supercapacitors (Scaps) in series are powering a moteino. A power supply unit (PSU) is being used to recharge the supercapacitors. A 1-Ohm, 10W power resistor is connected in between PSU and Scaps.

Goal of the expt.: To figure out if all the moteinos (R3, R4 & R6) will turn back on automatically once their supply voltage  (Vin = Scaps voltage) goes below 2.7V, 1.8V etc. and then it has been charged to 2.7V and above.   
 
Observation:
- Please see the attached table (green shading: turned back ON & red shading: did not turn back on)
- Only R3 moteino turned back on regardless of the voltage level we start 
- R4 & R6 moteino show weird behavior: They only turned back on when the start voltage is above 1.8V. They could not do so when the start voltage is below 1.8V.

I don't know how to conclude the test result (suggestions are welcome). I don't know if it is the version or just a coincidence. I don't have more moteinos with me in my LAB at the moment. They are out in the field. Maybe next time, I can repeat the same experiment with another moteino of any of the three versions and observe if that will exhibit the same behavior. As of now, I am out of ideas. But at least I can tell from the table that the R3 moteino (used in this test) is capable of turning back on whether we take the Vin of the running moteino down to 0.5V or 1.035V or 1.46V or 2.00V and start charging. I don't know I could be wrong. Any idea is highly appreciated.

emjay

  • Full Member
  • ***
  • Posts: 119
  • Country: nl
Re: What happens when the power goes out?
« Reply #14 on: June 22, 2019, 10:17:57 AM »
@SanG,

There are limits on the minimum rise time for Vdd to get a successful MPU initialisation  - in fact in the critical region, the supply must increase monotonically (i.e. no backtracking or glitches).  Will that happen with the way you are controlling the variable PSU?  The supercaps should damp down any glitches but you are driving them with a very low impedance, limiting the RC value of that filtering.

At some point you probably need to generate a repetitive cycle of power up/power down and hook up a scope  for Vdd and Idd to see what is really happening.

Some illuminating results here  https://jeelabs.org/2011/11/30/all-power-up-puzzles-solved/ and related posts tagged "LOWPOWER".