i would like to ask you for help with design of an circuit.
I have and atmega328p, with detection for voltage on its Vin (Vcc). I have made and voltage divider and its output i connected to Analog Pin. And i would like to, if an voltage decrease under an certain level (4.5V), to shutdown itself (atmega328p).
As i said the voltage detection is no problem (there is an voltage divider), programing it is as well no problem, but i though that i program it like this:
Detect voltage on analog pin A0, if the voltage is less than certain level (4.5V), write to memory and send to digital pin 3 an "LOW" (0) logical state.
This will turn the mosfet off and the atmega will loose its ground (GND) and its shuts down, but i have there an pull-up resistor which when the atmega shutsdown takes its lead an set Gate at MOSFET to high (transistor will turn on) and atmega turns on, then it shuts down and this will do the infinite cycling until there's no power to turn on atmega.
I want to use an Supercapacitor (2.2F 5.5V) to power it when the main input is lost and to give an atmega a time to write to memory and steadily turns off.
I am adding an schematics to better look at the problem.
I know that there is no crystal and capacitors and the other things to make it reliable and fully functional, but this is not a subject of this question.Its an first sketch, which is not completed.
I know some ICs that can detect Voltage and turn its output to some logical state (1 or 0), like an MAX809 (803 or 810) and so on and of course this is my backup plan, but i want to ask you, if you have any great idea to make this without any special ICs and more easily? I also thought about some OPamp or thyristor maybe, i don't know......
Can you help me with an idea or better with an schematics how to do it ? Thanks.