A simple "On-Off" push-button circuit is easily implemented with a D-type flipflop. However, I need my flipflop to turn ON when the push-button is pressed and OFF when the push-button is pressed and held for several seconds.
The few simple criteria as follows. The last criterion is there to remove any ambiguity in the scenario:
- The momentary push-button is part of a rotary encoder and shares its common anode;
- The ON 'press time' should be under 0.5 seconds, but still incorporate some debounce;
- The OFF 'press time' must be at least 5 seconds;
- The current draw when idling must be as low as possible;
- The solution must be purely hardware - I cannot use a uC.
After much deliberation and shouting I came up with the following circuit. It performs to the specification, except I'd like to know if there is a way of doing it with a lower component count.
Vcc = 3.7V. U1 (MAX942) is currently a simulation stop-gap and will likely be replaced with a lower-power equivalent, if there is one. The R/C values give suitable timimgs at present.
The circuit is quite simple: Q2 charges C1 and C2 through 1k resistors. When 'SWITCH' is pressed the caps will discharge through R3 and R5, respectively. When a capacitor's voltage drops below
THR the compartor will go HIGH, providing a rising edge to
CLK. However, when the flipflop is ON, Q4 shorts the output of
CLK of said edge. If the button is held down for long enough then C1 will eventually discharge below
U1:B will provide the rising edge to
I can't think of a simpler solution; everything I've tried ends up spiralling into complexity. Any recommendations would be appreciated.