Power switch with momentary push button

Hi everybody,
I’m here to ask for your advice on a project I’m working on.
In my project I use an Atmega328p running at 8 MHz, an MIC5205-3.3 as an LDO and a toggle switch to power the circuit from a Li-Po battery.
I want to upgrade my design by getting rid of the toggle switch and use instead a momentary push button and using the enable pin on the MIC5205.
Attached there is my new powering circuit and I would like to ask if it will work or not and maybe some tips to make it work better.

How I think it works:
Powering ON:
Push button pressed for more than 1 sec → MIC5205 powered and so the ATmega328p → as soon as the Atmega328 has booted it puts PB0 high (so the enable pin on the MIC5205 stays high) → push button released and circuit is still on because the enable is high.

Powering OFF:
The second contact of the push button is connected to an Interrupt pin of the Atmega, if the INT pin is active for more than 3 sec, the Atmega puts PB0 low. When the button is released, enable on the MIC5205 goes low and everything goes off.

Attached there is a very essential schematic of the circuit.

Waiting for anything usefull from you guys and thanks in advance!!

Davide

as soon as the Atmega328 has booted it puts PB0 high

Thus connecting an Arduino pin to an unregulated supply higher than the supply on it's own Vcc pin and bang!

Lots of other things wrong with that circuit as well.
PD2 will not trigger off a simple connection to a +ve without a pull down resistor, and still the same problem with over voltage.

if the INT pin is active for more than 3 sec

And how are you going to do that when the millisecond timer is disabled once an interrupt is triggered. I know there are ways round this but you haven't considered this.

The enable pin is floating with nothing connected to it, it is not at a logic zero. Again pull down needed.

Nice idea but I see some problems:

Both inputs of the Arduino can now see the battery voltage and that is probably to high!

You need a double pole push button…

The inputs are floating when the switch is in rest => you need pull downs

What will keep E low when the Arduino loses power?

If you short press the button and the Arduino did nu pull the pin high in time it will switch off.

Also, you don’t want to use the interrupt for this :wink:

My (untested) idea would be to use something like this.

R2 need to be high so Vbat / R2 < 1mA
R1 need to be high so that the pin can be driven high R1 > 3V / ((Vbat - 3V) / R2)
R4 same as R2
R3 order higher then R4

Or there about i think…

I the battery is 12V then I think
R1 100k
R2 50k
R3 100k
R4 50K

Should do the trick…

Grumpy_Mike:
Thus connecting an Arduino pin to an unregulated supply higher than the supply on it’s own Vcc pin and bang!

Lots of other things wrong with that circuit as well.
PD2 will not trigger off a simple connection to a +ve without a pull down resistor, and still the same problem with over voltage.
And how are you going to do that when the millisecond timer is disabled once an interrupt is triggered. I know there are ways round this but you haven’t considered this.

The enable pin is floating with nothing connected to it, it is not at a logic zero. Again pull down needed.

I didn’t include the resistors but I knew I needed them…I was just lazy!!

About the interrupt, I know that the milliseconds stops with IR, but I’m polling other input with a timer so I can poll this input too and check if it’s high for 3 sec. But this is not the important thing…

septillion:
Nice idea but I see some problems:

Both inputs of the Arduino can now see the battery voltage and that is probably to high!

You need a double pole push button…

The inputs are floating when the switch is in rest => you need pull downs

What will keep E low when the Arduino loses power?

If you short press the button and the Arduino did nu pull the pin high in time it will switch off.

Also, you don’t want to use the interrupt for this :wink:

My (untested) idea would be to use something like this.

R2 need to be high so Vbat / R2 < 1mA
R1 need to be high so that the pin can be driven high R1 > 3V / ((Vbat - 3V) / R2)
R4 same as R2
R3 order higher then R4

Or there about i think…

I the battery is 12V then I think
R1 100k
R2 50k
R3 100k
R4 50K

Should do the trick…

I use a Li-Po battery, so VBat is 3,7 V nominal (4.2 at full charge).

I’ve made some corrections following advices from both of you and updated my schematic here

Let me know!

Thank

Better.
There are no capacitors around the regulator and I would put a diode in series with the PB0 pin to protect it.