2
\$\begingroup\$

I'm working on a small mobile-phone sized gadget and I'm trying to implement a tactile momentary power button that is controllable from the MCU (Press to turn on, press again to turn off). I struggle finding a simple and elegant circuit for this. This one is almost there, but it can't be used to turn off the gadget without a dual pole switch.

Simple ON/OFF PWR_ENABLE is an active high signal that turns on power to the MCU.

When power is off, PWR_ENABLE is pulled low by Q20 being enabled (R32 holds Q20's gate high, Q19's gate is low because MCU is unpowered). When button SW4 is pressed, Q20 is disabled, allowing PWR_ENABLE to be pulled high. As soon as MCU comes up, it asserts POWER_HOLD pin high, which keeps the gate of Q20 pulled to ground. To shut power off, MCU sets POWER_HOLD low, gate of Q20 goes back high, pulling PWR_ENABLE low, power turns off.

This is all good, however I would like to let the user turn off the device with a long press on SW4. The best would be a signal from SW4 so the MCU can do housekeeping before turning off. Trouble is that the gate of Q20 is at ground potential when power is on, so I can't simply get a signal back straight from SW4.

In OFF state, a press should pull PWR_ENABLE high. In ON-state, a press should NOT pull PWR_ENABLE low but trigger the MCU, which in turn pulls PWR_ENABLE low (after saving settings etc).

I've come up with the circuit below, but it seems overly complicated. Can anyone see an elegant way to simplify? The goal is to get a signal back to the MCU that the user requests a power down.

Too complex ON/OFF

\$\endgroup\$
  • \$\begingroup\$ Another thing is that when the MCU is off you still have a current through the 100k resistor and Q10-Q20, that even if small is not so elegant, don't you think? \$\endgroup\$ – clabacchio Jan 31 '12 at 10:35
  • \$\begingroup\$ @clabacchio Well, true :-) The current leak through the 100k resistor is not ideal. \$\endgroup\$ – morten Jan 31 '12 at 11:09
  • 1
    \$\begingroup\$ When you press and hold the on/off button, does it have to force the power off or just send a signal to the MCU so that it can finish whatever it is doing and turn itself off? If it just needs to send a signal then no hardware delay is needed, just program the MCU to wait x seconds checking if the signal is still active. \$\endgroup\$ – Pentium100 Jan 31 '12 at 11:39
  • \$\begingroup\$ "button that is controllable from the MCU". That is a robotics question, which I think may be off topic here. \$\endgroup\$ – Olin Lathrop Jan 31 '12 at 12:44
4
\$\begingroup\$

I think this can be done with just a couple of diodes and a resistor. enter image description here

Pressing the button with power off enables PWR_ENABLE turning on the micro (or power supply or whatever). The micro asserts POWER_HOLD to keep the power on. The micro then monitors PWR_DOWN_REQUEST to see when the user has pressed the button again. If VBATT is above the level that can be fed into an input of the micro, a voltage divider can be added.

\$\endgroup\$
  • \$\begingroup\$ WOW, that might work! \$\endgroup\$ – morten Jan 31 '12 at 12:56
  • 1
    \$\begingroup\$ @morten, as Olin mentioned, switch debounce can be a problem so you will want to set up POWER_HOLD as an output and set it high as quickly as possible after the micro powers up, preferably right in the reset code. The nice part about this circuit is by using diodes instead of an OR gate, no VCC is needed so you can even use the PWR_ENABLE lead to gate the enable pin of a regulator, and keep system power off until enabled. \$\endgroup\$ – tcrosley Jan 31 '12 at 14:44
  • 1
    \$\begingroup\$ I added a capacitor across the pull-down resistor which will mitigate the debounce. Adjust values as needed. \$\endgroup\$ – tcrosley Jan 31 '12 at 15:12
1
\$\begingroup\$

I haven't tried this or simulated it but it seems about right.
This provides short push on, long push off.
Another glance after I had posted it suggests that mayhaps a very high value resistor (say 1M - 10M range) from C1+ to V+ may help establish initial conditions but probably not needed.

It has no processor control shown but this can be easily be added by tapping in at appropriate points as required.

Q1/Q2 and R1/R2 form a classic SCR latch.
Initially Q1 and Q2 are off.
Closing PB1 momentarily turns on Q1 via R2 which trurns on Q2 via R1 which enables the Q1/Q2 latch.
Releasing PB1 leaves Q1/Q2 latched.

C1 starts assumed charge either via Q1-be R2 D1 or via R4 not shown as above.

When PB1 is closed briefly C1 starts to discharge via R3 but as long as time constant R3.C1 is long wrt PB1 on time C1 stays charged.

A long push of PB1 discharges C1 via R3 turning off Q2 via Shottky D2.
R3 needs to be much smaller than R1 so that base of Q2 is adequately grounded via D1. This is entirely doable as long as the circuit requirements are known and designed for.

With Q2 off, releasing PB1 recharges C1. Recharge current needs to be small enough not to retrigger Q1 via R2.

Overall it would take some care to design to meet various drive high or low requirements but should be doable. Adding one more transistor in the timing path would probably ease design effort.

enter image description here


Yee ha!!:-)

Just thought of this.
Somewhat arcane. Diagram later maybe.

Two NPN bipolars.
Both have collector resistors to V+.
Bothe have base resistors from their own base to opposite collector.
= classic cross-coupled latch.

Now the extra - probably invented 50 years ago :-).
Name one transistor Q1. Capacitor C1 -ve end to ground. Resistor R1 from Q1 collector to C1+ PB1 from C1+ to Q1 base.

Operation:
Short pushes on PB1 will toggle latch.
Operation can be made timing asymmetric with thought. Note that as described above a long press may put system into oscillation. Resistor R1 in series with PB1 may be desireable to increase discharge ime into Q1_b.

When Q1 is on its collector is low so C1 charges to low.
Q1 base is high (as it is on).
Pressing PB1 connects low to Q1 base so Q1 turns off.
Latch toggles.

When Q1 is off its collector is high.
Q1 base is low.
C1 charges to Q1 collector = high.
Pressing PB1 connects high to Q1 base turning it on.
Latch toggles

QED

PB1 press time needs to be lower than R1.C1 time constant.
Next toggle will not occur until > R1.C1 time constant.

\$\endgroup\$
  • \$\begingroup\$ you are probably in the state of editing, but I don't think that uploaded properly. It keeps telling me my zzz drive is not accessible. To Super User to ask for help! \$\endgroup\$ – Kortuk Jan 31 '12 at 11:42
1
\$\begingroup\$

You say you want a button that is "controllable from the MCU", but other parts of you question seem to be asking about toggling power on/off from a momentary button. I'll assume the former is just bad question writing and even worse proofreading and answer the latter.

Doing a on/off toggle with discrete electronics is possible but rather tricky. One of the problems is button bounce. Since a button actually goes on/off many times for a single press, the end result can be indeterminate. This means you need to add some timing, making it even more complex.

Nowadays the far easier answer is to leave the microcontroller on all the time but have it power itself down. Micros are now available with 1 µA and less sleeep current. That's "off" for most practical purposes. The advantage is that they can be woken quickly by a button press. The micro can then do the debouncing and turn itself and other circuitry on or off as appropriate. Even if you just want a pushbutton on/off controller, a tiny micro is the simplest way to do that reliably.

\$\endgroup\$
  • \$\begingroup\$ Hooking the power button up to the MCU would be a great solution. However, the quiescent current for the regulator (an LDO in this case) is min 120uA. The rest of the circuitry also consumes some power in sleep state. Maybe I could use a separate small low quiescent current LDO just for the MCU... \$\endgroup\$ – morten Jan 31 '12 at 13:58
  • \$\begingroup\$ There are LDOs that use much less quiescient current than that. For a on/off toggle, you power only the CPU all the time, then it can power up the rest of the stuff only when it's supposed to be on. \$\endgroup\$ – Olin Lathrop Jan 31 '12 at 16:55
1
\$\begingroup\$

I think you could use a CMOS set-reset bistable with active high inputs (can be half of a suitable 74HC chip). Pull-down resistors on both inputs. One input can be made high by the switch to eanble power, and is also input to the microcontroller. The other input can be made high by the microcontroller to disable power. The bistable is powered directly by the battery, but its consumption should be minimal.

Note that the inputs must be low in rest to avoid powering the microcontroller via the input protection diodes.

\$\endgroup\$
1
\$\begingroup\$

My recommendation would be to have the "power on" button drive high the same transistor that the processor does, and use the same processor pin for both "keep on" and "button sense" functions. When the processor wants the unit to stay on, it should drive the pin high 99% of the time; it may, however, occasionally float the pin very briefly to check whether the button is being pushed. If you don't mind possibly feeding a small amount of above-rail current into your CPU pin, you should be able to get by with four resistors and two MOSFETs. If you want to avoid any possibility of above-rail current, a Zener diode might be the simplest way to do that.

One thing to watch out for, btw, is to ensure that a "high" from the CPU will only be able to turn on the circuit when the CPU voltage is above its minimum operating spec. Otherwise, it's possible that the CPU might execute arbitrary code as soon as its voltage falls below its operating spec, and that arbitrary code might try to turn the circuit back on. I've had that problem bite me in the past, but it can be avoided by making sure that the resistance ratio between the pull-down resistor on the NFET gate and the series resistor coming from the CPU pin is such that the gate won't turn on unless the CPU is outputting a very good "high" voltage.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.