1
\$\begingroup\$

I basically want to determine if power has been totally disconnected in a low power device I am making that uses an Atmega328 chip.

The theory is that when power gets first applied the ATmega will power up, calibrate and take some readings then power down again. The rest of the circuit will still be powered until the chip wakes up again and takes more readings. What I need to be able to determine is if the battery was disconnected or not. If it was, I need to do a calibration again; if it wasn't, then I just take a reading as normal.

Is there any way of doing this which takes as little power as possible?

\$\endgroup\$
  • 2
    \$\begingroup\$ Duplicate of How to make 1 bit permanent memory circuit? \$\endgroup\$ – Transistor Sep 24 '17 at 19:02
  • 1
    \$\begingroup\$ Will the ATmega also be losing power? If so you can probably just calibrate on reset. If not, it seems like you want to be monitoring the power of the rest of the circuit. Done right, this should draw extremely little current. \$\endgroup\$ – Chris Stratton Sep 24 '17 at 19:10
  • 1
    \$\begingroup\$ If the ATMega power is independant of the main supply, you can use some of the hints given there: electronics.stackexchange.com/questions/244335/… \$\endgroup\$ – dim Sep 24 '17 at 19:58
  • \$\begingroup\$ Are you using Atmega with native tools, or with Arduino tools? That may be important for your strategy, because some aspects of low power operation are software-enabled. \$\endgroup\$ – Nick Alexeev Sep 24 '17 at 21:34
  • \$\begingroup\$ Yes the ATmega will also lose power. The other articles mentioned are very interesting and I will take some time to go through them thanks. \$\endgroup\$ – SpeedOfSpin Sep 25 '17 at 7:34
3
\$\begingroup\$

System power is disconnected and then reapplied, the ATmega will start from the reset vector, as usual (due to the power-on reset).

So you can perform your inizialization routines in the very first part of your main() function.

When you finished doing your periodic measurements, do not remove power to the ATmega. Instead, put it in power-down or power-save mode through the sleep instruction.

enter image description here

This will draw less than \$1 \mu A\$ @25°C. When the wakeup interrupt occurs (e.g. timer expiration, external pin etc.), the interrupt will be executed and the program will restart from the instruction that follows sleep. In this way you can avoid any external hardware.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Thank you for this. I won't be able to use this method unfortunately as power is completely removed from most of the circuit to save power. I could rework some of the hardware so that I can use this method which is something I am going to consider as it seems like the simplest idea. \$\endgroup\$ – SpeedOfSpin Sep 25 '17 at 7:32
  • 1
    \$\begingroup\$ @SpeedOfSpin: a AA battery as a self-discharge rate 40 times higher than the sleep current of an Atmega in sleep. An AA battery also lasts 5 years on the shelf. Are you SURE you need to save the 1 microamp? \$\endgroup\$ – Bryan Boettcher Sep 26 '17 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.