How to remember the number of power switch

How to remember the number of power switch,
Note:the power is main power,if the power off time is too long,MCU was stop working. sod ,off time less then 400ms,and MCU have a big cap to save power.
question:
if on/off power switch 1 times MCU output 500Hz on/off power switch 2 times MCU output 1000Hz ....................................
anyone have a method?
thx you .

Parents
  • It's a bit tricky to work with the external power, unless you also make sure you have a suitable reset circuit that will reset the chip correctly if the voltage (after your cap) drops to unsafe levels where the processor may go wild, but do not reset the chip as long as supply voltage is stable enough.

    Then you just need to add a diode on power and feed a processor pin the power before the diode, and feed the cap after the diode. Then the processor can get an interrupt when external power goes away while the cap still keeps the processor running.

    If you select a good processor, you can even change the processor to a lower power mode to conserve power in the capacitor while you count time waiting for power to come back (or reset to stop the program if power was off too long).

    As long as the cap can feed the processor, you don't need anything special. Just run your program and store state information in normal variables.

    A good processor can be powered and count time and still consume much, much, much lower than 1mA. Quite a number of processors can do it while drawing 50uA or less. Some chips can go way lower than that. Remember that processors with power-save can stop program execution with timers still ticking. So they count time while the processor core is stopped. It's just crystal oscillator + timer that needs to run.

Reply
  • It's a bit tricky to work with the external power, unless you also make sure you have a suitable reset circuit that will reset the chip correctly if the voltage (after your cap) drops to unsafe levels where the processor may go wild, but do not reset the chip as long as supply voltage is stable enough.

    Then you just need to add a diode on power and feed a processor pin the power before the diode, and feed the cap after the diode. Then the processor can get an interrupt when external power goes away while the cap still keeps the processor running.

    If you select a good processor, you can even change the processor to a lower power mode to conserve power in the capacitor while you count time waiting for power to come back (or reset to stop the program if power was off too long).

    As long as the cap can feed the processor, you don't need anything special. Just run your program and store state information in normal variables.

    A good processor can be powered and count time and still consume much, much, much lower than 1mA. Quite a number of processors can do it while drawing 50uA or less. Some chips can go way lower than that. Remember that processors with power-save can stop program execution with timers still ticking. So they count time while the processor core is stopped. It's just crystal oscillator + timer that needs to run.

Children
More questions in this forum