This is similar to other questions, but I feel it is different because of the reuse of the "power" button.
I want a "latching" Momentary Power button.
Behavior:
User Pushes momentary button, holds down as long as necessary and the device powers up.
Between Power On and Off the same button will be re-used for other functions
When it is held down for 5 +/- seconds the MicroController will turn itself off.
Design Constraints:
Battery provides between 3.7V to 2.9V during it's usable life
The Voltage regulator requires Vin +/- 0.3V on the Enable Pin, 3.1V output.
MicroController operates at 3.1V
MicroController Output Pin High state is 2.7V Max
Debouncing: In this case I'm not concerned about debouncing the switch, if the user doesn't hold it down long enough for the MicroController to set it's Digital Output pin High the device doesn't power on.
I've worked up the following schematic, which kind of works.
Falstad Circuit Simulator of my schematic
It assumes 3.7V from the battery. Uses an Analog Input for the Power button, which then uses the variation in voltage to determine if the button has been pressed. In the current design the difference is 0.12 V (from 3.4 to 3.52), but the MicroController has a 12 bit ADC so that shouldn't be a problem, in addition I can adjust the sensitivity range of the ADC.
Questions:
What is the difference between reality and the simulator?
Is there a better way?
How can I get a greater voltage difference on the button input? I've tried many different combinations but they increase the voltage range above the 3.6V Input High Maximum specified in the datasheet.
I'm not excited about the "Leakage current" when the uC Controlled Power Pin is Low, any suggestions?
Thank you for any ideas/suggestions/answers.