Quick Bits Resources

Soft Latching Power Circuits

Written by Andrew Levido

We often want to turn on a microcontroller (MCU)-based product or project with the press of a button. This is quite simple if the microprocessor is already running in the background. Most MCU families offer a range of low-power sleep modes with the ability to wake the processor on a button press. But what if we want to consume no power at all until the button is pressed?

We can resort to a circuit like that shown in Figure 1. Here the incoming power rail is switched by a P-Channel MOSFET, Q1 before it reaches the regulator. When power is first connected Q1 will be held off R1 and C1. Q2 will be held off by R2, as the GPIO1 pin on the MCU will be floating since it is as yet unpowered. Note that C1 is necessary to eliminate the risk that the circuit will latch on when power is applied, as there will be some stray capacitance from Q1s gate to the negative rail which could cause Q1 to momentarily switch on as it charges.

FIGURE 1. Q1 is held off via R1 and C1 until the ON button is pressed when power is applied to the MCU via Q1. Q2 is switched on immediately via GPIO1 to latch Q1 and this Q2 on. To turn the circuit off, the GPIO is driven low, turning off both MOSFETs.

When the user presses the ON button, the gate of Q1 is brought negative with respect to the source and it turns on. Power is then applied to the MCU via the regulator. The software immediately configures GPIO1 as an output and sets it high. This turns the N-Channel MOSFET, Q2 on pulling Q1’s gate low latching the power on. This all happens in the few tens of milliseconds while the pushbutton is pressed so the power is latched on before the user releases the on-button.

This is great for turning the circuit on, but the only way to turn this circuit off is for the MCU to drive the GPIO1 output to zero, turning off both MOSFETs. We can make a couple of minor changes to this circuit so that we can detect if the button is pressed while the circuit is powered and initiate the turn-off that way. This is shown in Figure 2.

FIGURE 2. This enhancement allows the one button to switch the circuit on and off. It turns on in the same way as Figure 1, but now GPIO2 can detect when the button is pressed again and initiate a turn off. This GPIO is configured as an input with an internal pull-up.

GPIO2 and two Schottky diodes are added. Power-on works as described above, except that the pushbutton pulls the gate of Q1 down via D1. The second GPIO2 is configured as a digital input with an internal pull-up. When the circuit is on, D1 is reverse biased and GPIO2 effectively monitors the state of the pushbutton. When it is pressed, the GPIO pin is pulled low via D2 and this state can be detected by the MCU which can then switch the circuit off via GPIO1 as before.

The advantage of switching off via software is that the user can determine how long the button must be pressed to qualify as a valid off signal and the program can complete any necessary housekeeping before powering down. You could, for example, require the button to be held down for three seconds to initiate power-down. The downside of this circuit is the need for two GPIO pins.  Wouldn’t it be better if we could get away with just one?


Advertise Here

Figure 3 shows how this can be achieved. This circuit turns on when the button pulls the gate of Q1 low, as per the previous circuits. This time however, we configure GPIO1 as an input with internal pull-up. This pull-up is sufficient latch the power on by turning Q2 on. Neat.

FIGURE 3. This circuit has the same functionality as Figure 2 but requires only one GPIO pin. When powered up the internal pull-up is sufficient to turn Q2 on, latching the power on. When the MCU detects the button has been pressed, the software reconfigures the GPIO as an output and drives the pin low to switch off Q2 and therefore also Q1.

When we press the button while the power is on, the GPIO1 pin is pulled low via D2 and R3 which is detected by the MCU as before. The software must then switch the GPIO to an output and pull it low to turn Q2 and thus the rest of the circuit off.  The inclusion of R3 is advisable to limit the current in the unlikely event that the GPIO is driven high before the user releases the button. If you are sure this will never happen Q3 could be eliminated.

There are dozens of variations on this theme out there—just be aware that not all of them are suitable for situations where the input voltage is higher than the MCU supply. In these circuits D2 ensures the GPIO2 input never sees a voltage higher than Vdd.


By. “Ditch The Switch: A Soft Latching Circuit Roundup.” Hackaday (blog), June 24, 2019. https://hackaday.com/2019/06/24/ditch-the-switch-a-soft-latching-circuit-roundup/.

Arshad, Areeba. “Soft Latch Switch Circuit.” Circuits DIY (blog), January 28, 2020. https://circuits-diy.com/soft-latch-switch-circuit/.

Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.

Note: We’ve made the May 2020 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.


Advertise Here

+ posts

Andrew Levido (andrew.levido@gmail.com) earned a bachelor’s degree in Electrical Engineering in Sydney, Australia, in 1986. He worked for several years in R&D for power electronics and telecommunication companies before moving into management roles. Andrew has maintained a hands-on interest in electronics, particularly embedded systems, power electronics, and control theory in his free time. Over the years he has written a number of articles for various electronics publications and occasionally provides consulting services as time allows.

Sponsor this Article

Supporting Companies

Upcoming Events

Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2021 KCK Media Corp.

Soft Latching Power Circuits

by Andrew Levido time to read: 4 min