0
\$\begingroup\$

I have a processor that is powered by a mains 5V power from a wall adapter, and has a short term battery backup.

I need the processor to turn on automatically and immediately when 5V mains supply is present. 5V power, processor turns on.

But, if mains power is removed, the processor needs to stay powered from the battery, save to memory, and then it can assert a signal saying it is ready to turn off, which should then turn off the power.

Power can then not turn on again until the 5V mains supply is present again.

enter image description here

How can this be possible to do, without it entering an unstable state where the processor tries to turn off and then can't hold it off and turns back on in a loop...

\$\endgroup\$
  • 1
    \$\begingroup\$ "can't hold it off" -- what's that supposed to mean? Instead, think of the processor as "holding it on" while it's powered up. As soon as it "lets go", the power goes down and stays down. Anyway, this has been solved many times, both here and elsewhere. Did you do any research at all? \$\endgroup\$ – Dave Tweed Aug 26 '19 at 17:59
  • \$\begingroup\$ Richard, I think you should write a little more explicitly. There are various assumptions (different readers might choose different ones reading your text) possible and some are incompatible with others. Clarity is important to sweep aside such problems. For example, I think I'd assume you ALWAYS have a battery present from your text about saving things when power is removed. But is that always the case? I can't say for sure. And only you can clarify this reasonable assumption. It is super-cheap and easy for you make it explicit. So write more. Also, you haven't addressed "brown-out" issues. \$\endgroup\$ – jonk Aug 26 '19 at 18:11
  • \$\begingroup\$ "I have a processor that is powered by a mains 5V power from a wall adapter, and has a short term battery backup" - Which processor, what battery, and how does the power switch from the wall adapter to the battery? \$\endgroup\$ – Bruce Abbott Aug 27 '19 at 1:46
  • 1
    \$\begingroup\$ If you need a regulator anyway, one with an enable is an easy solution; you initially activate it with an AC coupling capacitor to Vin, then the MCU takes over holding it with a GPIO. If you don't need a regulator you can make a circuit with similar enable function - but beware it will require at least two FETs or transistors - single active device solutions will not work as you must un-invert the polarity of the control signal relative to the power rail controlled to avoid turning yourself back on through the keeper resistor and protection diode. \$\endgroup\$ – Chris Stratton Aug 27 '19 at 4:16
  • \$\begingroup\$ It makes no difference what battery or what processor is in question here. @ChrisStratton if you make your comment an answer, I’ll accept that as the most likely and simplest solution. \$\endgroup\$ – Richard Aug 27 '19 at 8:51
2
\$\begingroup\$

Even though this has a lot of steps, it's still an outline. You need to go through the circuit very carefully and make sure you're not accidentally powering a gate or the processor through an input pin -- so you need to insure that all pins are undriven, or driven to ground, when the processor is off.

  • Find a really low-power CMOS single-gate logic family that's compatible with your battery and input voltage (HCT may be more than good enough).
  • Power it from some "always on" supply (like the battery).
  • Run the +5V and a GPIO from your processor into a NOR gate. Make sure the GPIO is pulled down when the processor is off.
  • Drive your "enable power" signal from the NOR gate
  • Run +5V to some other non-inverting gate (so it'll be LOW with no +5V, even when the micro power is off)
  • On reset, set the power enable GPIO high (to enable power).
  • When you detect that +5V is off and you want to turn off, set your GPIO low.
\$\endgroup\$
1
\$\begingroup\$

There are ICs dedicated for this purpose, called voltage supervisors. Texas Instruments make a few, with different voltage and reset options. I've not checked other manufacturers, but you can just search for voltage supervisors, and a few should come up.

TI has also made a comparison between the discrete and IC based supervisors (with some obvious interest in making the ICs come up on top in their comparison), but it is a good starting point into the subject http://www.ti.com/lit/an/snva878/snva878.pdf

\$\endgroup\$

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.