Self-latching auto shutdown circuit - Page 1
Forum section: electronics / projects

author: teotwaki
author_rank: Newbie
timestamp: March 21, 2022, 10:22:05 am
content: Hi all,I know, this is something that has been discussed a few times. However, the typically recommended LTC2955 is a tad pricey at the moment, so I'm trying to cut down on costs a bit. I was wondering if anyone could provide some input on the attached schematic. I have watched Dave's video from a few years ago about the jelly-bean parts, however it focuses on single latching button/flip flopping. I don't think I've invented this design, but I also can't remember where I saw it.Objectives:Reduce power consumption when system is inactive. The uC will shut itself down after 20-30 minutes of inactivity.Single momentary switch input to turn and latch on the system. The uC takes a while to boot, so waiting for it to go high on one of its GPIOs is quite annoying/counter productive.Handle between 10-30V power input.Don't turn on the system when power is applied (wait for button press).Use currently available components (hence the use of the AO3401 and UMH3N.Behaviour (or at least, my understanding of the behaviour):When power is applied, the FET is off due to Vgs being 0When button is pressed, FET switches on and powers the uC due to Vgs = -VbatWhen the FET is on, Vbe on Q3B is high enough to saturate it, pulling the gate on the FET to GND and latching the circuit on.When the uC drives GPIO_SHUTDOWN high, the gate of Q3B is pulled to GND, which means Vgs falls to 0, interrupting the circuit.Questions:Would this work at all? Am I massively oversimplifying and being a complete idiot?How/what would you improve?If there's an easy way to implement "Hold (10s) button for forced shut off", I'd be happy to hear it. (this is purely optional, though)Is there any chance that if GPIO_SHUTDOWN pulses high/low during uC shutdown that it "restarts"? Should I add an C between GPIO_SHUTDOWN and GND to filter it out?Is R3 too big? I'm not sure I understand the UMH3N datasheet on how much Ib is necessary to fully saturate it.

author: Bravo
author_rank: Contributor
timestamp: March 21, 2022, 12:02:03 pm
content: I tested this on Proteus simulation. I made the base resistors 10K & the battery volts 5v & it worked fine.I did not have the same P ch FET as you have though. I was using an IRLML6401.

author: DavidAlfa
author_rank: Super Contributor
timestamp: March 21, 2022, 04:24:54 pm
content: There's a big issue in your circuit:When the voltage falls below working range, the mcu will enter reset state, setting all pins in High-Z.Now you no longer have control of your shutdown pin.Q3B will work down to 0.6V, so in the instant the mcu stops, it will enable Q2 again.Anyways, you must take in count that using this method, if the switch is accidentally kept pressed, the power will be never removed, as it permanently forces Q1 on.You really need something that forces the off-state when the mcu is not running.How many does a mcu need to boot up the most basic init, setting gpios, etc? Usually it takes few milliseconds.This circuit makes a temporal latching, about 400ms. After that, Q3 will force shutdown.Within this time, the mcu must do at least some basic GPIO initialization, pulling SHUTDOWN pin to ground to prevent Q3 from turning Q2/Q1 off.R2/C3 make a RC circuit, so you should calculate how much time it takes for C3 to get charged to 0.6V, this example is for 3.3V VDD.MCP1702 is just as example, representing your VDD rail.You can read the button at any time, and keep track of the state.Now if you detect it was pushed down for 10s, just trigger shutdown action, in the moment the button is released the power will be turned off.You must set shutdown high to power off the circuit.C3 will get charged, in the instant it reaches 0.6V, Q3 will turn off the other transistors.When the MCU resets by low voltage, R2 will keep Q3 on until it discharges completely.

author: Peabody
author_rank: Super Contributor
timestamp: March 21, 2022, 05:11:00 pm
content: I would just question why you believe the processor would take too long to boot up after you've pressed the button. I think typically you would be unable to press the button briefly enough that the processor wouldn't boot fast enough to keep itself powered up. If that isn't really an issue, you could eliminate one transistor, and an active high output on the GPIO pin would be required to keep power on, which means as the MCU goes into reset, power would not turn back on.If the circuit turns on when you first connect power, try adding a small capacitor between the source and the gate. That will make the gate come up with the source, so Vgs stays near zero as the voltage rises.

author: teotwaki
author_rank: Newbie
timestamp: March 21, 2022, 05:38:46 pm
content: Hi David,Many thanks for the very detailed response(s) you've written up and the time you're spending on this. Much appreciated! This is fantastic circuit and feedback you've given me. I hadn't considered the high Z state during shut down at all.Peabody, the reason why I was attracted to the self-latching is because this is booting up a Raspberry Pi, and I'm not exactly sure how long it would take before it is able to take control over the GPIOs. As far as I can tell from some preliminary research, this is something that can take many seconds (if we presume I will configure the pin as low from the userland)*.I was hoping to use thegpio-poweroffoverlay as the shutdown line:QuoteThe overlay, in combination with the auto-off circuit, basically allows me to treat the Raspberry Pi as having a "proper" power supply. Meaning that the power supply would be cut off after the system has finished shutting down properly.*: I know it is possible to usegpio=x=op,dlin config.txt to drive the pin low, however it appears this is only during part of the boot process, and the pins would be reset to input during initialisiation.

author: porter
author_rank: Regular Contributor
timestamp: March 21, 2022, 07:01:01 pm
content: FYI, Here is the power-up circuit from the transistor tester project.

author: DavidAlfa
author_rank: Super Contributor
timestamp: March 21, 2022, 11:26:45 pm
content: Please specify all these details from the beginningMCU and linux system are completely different things.This is a double latch:- On poweron (When the button is pressed down), it latches.- When shutdown is pulled to gnd for at least ~200uS, poweroff latch will be trigered, cancelling the first latch.

author: teotwaki
author_rank: Newbie
timestamp: March 22, 2022, 04:58:06 pm
content: Hi David,Thank you very much for your help. This indeed makes a lot of sense. I apologise for not being clearer about the entire project from the get go.

author: nikifena
author_rank: Regular Contributor
timestamp: March 22, 2022, 08:46:06 pm
content: I had the same problem in the past, so I did a research, and also I tested a few design ideasHere is what works for me. It has a few benefits.- the button acts as a power on and as a button for doing something for the device – a dual function- you don't need to press and hold the button to power the unit on. It turns on by a quick pressBoth PW ON and SW1 signals go to the processor.

author: DavidAlfa
author_rank: Super Contributor
timestamp: March 22, 2022, 09:52:04 pm
content: The power won't be latched until the rPi takes control of the pin and enables POWERON.That's the issue mentioend earlier, the system will need several seconds to boot and enable the power.

author: nikifena
author_rank: Regular Contributor
timestamp: March 22, 2022, 10:19:37 pm
content: That's the function of C18.If you want more time, just increase the value

author: teotwaki
author_rank: Newbie
timestamp: April 04, 2022, 10:32:57 pm
content: Quote from: nikifena on March 22, 2022, 08:46:06 pmThanks for sharing nikifena. It looks like a simple design indeed. I'll look at this over the coming days.Quote from: DavidAlfa on March 21, 2022, 11:26:45 pmAm I correct in understanding that as long as Q2 is latched, /BUTTON will be active?In any case, as the re-use of the button was optional, I ended up with the following, closely inspired by your design, see attached.As you can probably tell, I'm trying to protect the Vgs rating of the pFET, but not entirely sure how to do it. The simulations appear to indicate the current design would work, but if anyone has a better approach, or sees major issues, I'm happy to learn.

author: DavidAlfa
author_rank: Super Contributor
timestamp: April 04, 2022, 11:51:59 pm
content: You're right!Another diode will solve that.The zener is placement wrong, does nothing, Q2 will pull the gate to gnd in the same way.Check 2nd picture for correct way!.

author: uer166
author_rank: Super Contributor
timestamp: April 05, 2022, 12:31:21 am
content: Quote from: nikifena on March 22, 2022, 08:46:06 pmCan confirm I've done this (almost exact same circuit) with success. In my case the FW booted fast enough to not need that gate cap. It has a great advantage in that you can re-use the button as a user button, as well as a power-on button. And for shut-down the FW simply shuts down the GPIO and commits suicide.

author: Andreas
author_rank: Super Contributor
timestamp: April 05, 2022, 04:33:43 am
content: Quote from: teotwaki on March 21, 2022, 10:22:05 amHello,the poor AO3401 is only specified for -12V gate source voltage not for -30.with best regardsAndreas

author: teotwaki
author_rank: Newbie
timestamp: April 10, 2022, 12:07:45 pm
content: Quote from: Andreas on April 05, 2022, 04:33:43 amThanks Andreas, I switched to a different PFET which has a max Vgs of +/- 20, and added a 12V zener to protect it.Quote from: DavidAlfa on April 04, 2022, 11:51:59 pmI had something working in my sim, and then completely mucked it up while copying it over to KiCad prior to posting it here. This is a good lesson that I shouldn't try to do this past midnight.So, combining both your suggestions, I came up with the following (see attached), which appears to be working in sim.At startup, Vgs = 30V, Q1B is offWhen J2 is pressed, Q1B turns on, Q2 and Q4 also turn on, latching the system, GPIO_BUTTON is at 2.7V (which I presume is 3.3V - D3's Vd)With system on, when J2 is pressed, Q1B is unaffected, and GPIO_BUTTON goes down to 0VAgain, happy to be educated if I did anything wrong.

author: Peabody
author_rank: Super Contributor
timestamp: April 10, 2022, 02:03:46 pm
content: I would just go back to question #4 in your original post about a possible rebound when you shut down. As the 3.3V rail begins to fall, it's not clear how the bipolars will respond. And GPIO_SHUTDOWN will at some point become tristate. It seems it would be better for GPIO_SHUTDOWN to have to be high for power to be on. Well, it may work fine. Just need to test thoroughly.