Electronic – Where to decouple battery in circuit with power switch

attinybatteriesdecoupling-capacitortimer

My design is kind of a timer, and it will be turned on and off constantly by a switch, cutting power to an Attiny85.

The Attiny is programmed with sleep mode, and draws only 4.4 uA.

In the first circuit, when I turn it off, it still draws power from the capacitor, for about 10 seconds. So, if I turn it back on while in that 10 seconds, it continues where it left. This is not wanted.

schematic

simulate this circuit – Schematic created using CircuitLab

Is this second circuit the solution? Or it's not recommended due to not be really off?

schematic

simulate this circuit

Best Answer

Decoupling on the other side of the switch is not recommended as it will put the capacitor too far from the supply pin and add series resistance and inductance defeating the purpose of the capacitor. 10uF is OK, but in any case you should parallel the 10uF with a 0.1uF cap and maybe a .01uF cap as well for high frequency decoupling.

If you MUST put the 10uF on the far end of the switch, put a 0.1uF capacitor directly on the supply pins of the ATtiny and keep the larger capacitor on the opposite side of the switch.

Like the comment says you might be better off just sensing the switch with a GPIO.