This is general enough to be of use to several folks.
Anybody got a simple momentary keypad-switchable ON-OFF circuit for a
8051 (or similar)?
Figure about 100 mA MAX, and will be battery operated (9-Volt).
Program will run for a minute or so, then the device should shutdown
(under uPC control) until the next time it's needed. Probably do
this about 20 times a day. Battery lifetime is important.
MINIMUM cost, and minimum parts count would be nice too!
The only thing I can think of is a FET controlling the input to a
switch mode power supply / regulator. (But admittedly, I don't do
much battery-only stuff, and my solar design are higher current and
not easily adaptable for low cost.)
The circuit shown below is about as foolproof as it gets. The CD4093 is
a quad NAND w/Schmitt trigger inputs and can run off nearly any voltage.
This stays connected to the battery at all times, it draws no current
when the circuit is powered done, other than leakage. The circuit is
such that the switch can turn the power on and off at any time,
regardless of the processor input. It can override an OFF by being held
down, and it can turn the circuit off at any time. G1 and G2 in
combination with the switch form a toggle FF that self-latches off. The
microprocessor OFF input is not enabled while the latch is off. When the
momentary is pressed, the FF transitions to turn the PFET on and
enables the OFF input through the 1M and 0.1u delay to G3 input. This
does not occur until approximately 100ms after the switch is released.
So the user has the option of holding the switch down until the
processor gives some indication that it is on or otherwise. The
processor need only trigger OFF for a few hundred nanoseconds. G4 then
asserts a '1' to G3 input. If the the capacitor has charged to '1' by
that time, which is usually the case, G3 asserts a '0' on G2 input which
forces G2 to '1', turning the PFET off and causing G1 to latch with G2,
disabling the OFF input and locking the circuit into that state until
the next switch press.
View in a fixed-width font such as Courier.
..
..
..
.. CD4093
.. QUAD NAND SCHMITT
.. BATT
.. |
.. |
.. |< PMOS SW
.. .------------[10k]------------------+-----||
.. | | |----> TO LOAD
.. | |
.. | __ G1 |
.. | .--| \ __ G2|
.. +--| | o----+------+-------| \ |
.. | '--|__/ | | | o-'
.. | | | .-|__/
.. | | [100k] | __
.. | [1M] | | / |------.
.. | | | '-o | |
.. | | | | \__|-. |
.. | --- | | G3 | |
.. '---o o------+--------------------' |
.. | | |
.. NO SW === | __ G4 |
.. |0.1U | .--| \ |
.. -+- +-----| | o-----'
.. /// | '--|__/
.. |
.. |/
.. OFF>--[10K]---+----|PN3904
.. | |>
.. [10K] |
.. | |
.. '------+
.. |
.. ---
.. ///
..
..
..