Latch Circuit with delayed 'OFF'

Hey all,

for my phone project i'm trying to find a solution for the power on/off management.
A 3.7V battery powers my ATmega328 as well as a SIM A7670E Module.
I want to turn it on and off with just one button. I'm thinking to use a latch circuit, which works perfect for turning it on. But for the turnoff, i can't just power my modules off. The SIM module states:


So i either have the choice to:

  1. Pull down PWRKEY and delay the battery disconnect for around 4s, so the SIM Module has time to shut down.
  2. Sent the command to shut down the module as soon as the button is pressed again, and the disconnect the battery.

Both options would need the latch circuit to delay it's turnoff. The latch circuits i came across are almost instant, unfortunately:

I thought about making a combination of an automatic Latch ON with the button, and the have it reset with a pin commanded by the uC:

But how do i realize a button read, when both sides are pulled to Vcc?
Do you have smarter ideas/solutions?

As always, thanks in advance!

-Maik

Here's a circuit that uses the MCU as the latch, with the button performing double duty to trigger power-up as well as be an input after that. Maybe something there will be useful.

1 Like

If you like to settle in with an epic thread either under the umbrella or in front of a roaring fire, see

a7

1 Like

That was fun. Learned a lot.

Thank you for your help.

OP, this was the last design in the thread

But this is the last design that I built and tested:

2 Likes

These are smart solutions!

That would mean i'd have to keep pressing the button until the ATmega's output is enabled (about 2s if the internet didn't lie), or else the gate will get immediately pulled up to V+ again, right?
Is it fine to just cut the power of the Arduino/ATmega328 or do i need to command it to shut down as well?

That's right. If it takes two seconds, that probably wouldn't be a practical solution. But if your processor is running on a battery, and not connected to USB, it should boot up much faster. It's the communication with USB that takes a lot of time. What I've done in the past is to light up an LED so you can tell it's safe to release the button.

When you're ready to shut down, either because the button has been pressed again or because you've finished doing what you need to do, you just change the GPIO powering the transistor from HIGH to LOW output. Then the transistor will shut down, which in turn shuts down the mosfet, and the power shuts down.

Mine is the same circuit shown in post #4, except that the NPN transistor can be an N-channel mosfet if you prefer.

Correct but it could be a much faster boot time depending on which bootloader, if any, that you use.

Right. For final deployment lose the boot loader.

It's reasonably straightforward to make a ICSP out of an UNO.

a7

Yes, but i meant if it is safe for the ATmega328 to shut down by just cutting the power? Other chips like the before meantioned SIM Module do no like that (possible damage to flash, according to the hardware design sheet).

Good point.
I already bought this programmer and this adapter socket in order to get an arduino bootloader onto the raw chip.
Do i understand it right that if i want to drop the bootloader, but still use the Arduino IDE as programming environment, this programmer will not be working?
And i have to use an Arduino UNO or likewise as a programmer in between?

I don't know. Maybe someone who has experience with that module can help.