Self latching circuit

eetech00

Joined Jun 8, 2013
4,705
Also suggest changing R7 to 2.4K.
At 3.3K the voltage at GPIO1 is just under 6 volts when the switch is pressed.
Changing it to 2.7k

How does the switch turn the power back ON?
When PB is pressed, a pulse from the differentiator kicks Q2, which powers up the MCU via M1, that then generates the Hold signal at startup..
 
Last edited:

panic mode

Joined Oct 10, 2011
4,984
2k2 will do...

zener is added to protect gate of the mosfet by clamping Vgs to safe limits. for most mosfets this is some +/-20V but there are variants that tolerate up to 30 and others that only can handle 10-12V. so zener is there to ensure voltage never exceeds the transistor limits. but zener too has own limits - such as power (current rating). with 2k2 and 10V differential max zener power is in the neighbourhood of 75mW.
 

skstrobel

Joined Nov 29, 2023
28
But the switch is also grounding the PMOS gate, keeping it on....
In a similar design, when the button (combination, in my case) was pressed to turn the power off, I blanked the display right away and turned off the equivalent of the "out" pin shown in the OP's schematic. The PMOS stayed on and the MCU continued to run as long as the button was held, but that wasn't obvious to the user. When they released the button, the power actually turned off. It worked fine, and I don't think anyone noticed the delay in actually powering down. Something similar might work here.
 

Thread Starter

jan.sedlar

Joined Apr 14, 2021
31
Suggestion #1:
When power is first applied Q1 and M1 turn ON as C1 charges.
Followed by the 5V regulator and the MCU.
MCU "OUT" provides the latch and Sw1 provides the manual ON-OFF at the MCU "IN".
The key to the operation of Sw1 is in the programming of the MCU.
When the MCU powers up, the first line of code is to make the OUT pin High followed by a 1 second pause.
The code for turning OFF the MCU is written to make the OUT pin Low only after Sw1 is released along with a short pause to eliminate any switch bounce.
Turning the MCU back ON requires a brief push of Sw1.
When power is removed D1 and R1 provide a fast discharge path for C1.
Verified on bench test with programed MCU as described.
View attachment 363682
@sghioto I am a little bit confused here since in case Q1 is off after MCU switched it off, there is 24V on Q1 collector and when you push the button, you get 24V on ZD. Where is the low level pulse of the MCU input signal?
 

sghioto

Joined Dec 31, 2017
8,634
@sghioto I am a little bit confused here since in case Q1 is off after MCU switched it off, there is 24V on Q1 collector and when you push the button, you get 24V on ZD. Where is the low level pulse of the MCU input signal?
When the button is pressed ZD1 limits the voltage to 5 volts (through resistors R4 and R5) which is low enough to activate M1 turning the MCU back ON.
Once Q1 is latched ON the left side of the push button is effectively at ground potential allowing the switch to pull the IN pin LOW turning OFF the MCU.
 

Thread Starter

jan.sedlar

Joined Apr 14, 2021
31
When the button is pressed ZD1 limits the voltage to 5 volts (through resistors R4 and R5) which is low enough to activate M1 turning the MCU back ON.
Once Q1 is latched ON the left side of the push button is effectively at ground potential allowing the switch to pull the IN pin LOW turning OFF the MCU.
Thanks, got it. What if the internal pullup voltage of the input pin is only 3V3?
 

Thread Starter

jan.sedlar

Joined Apr 14, 2021
31
I have measured it and there is still 16V on MOSFET gate in OFF state (after the first switch push) which means that PMOS is still ON and I can not switch off the power source. Do you know what is the root cause of this? Thanks.
 

sghioto

Joined Dec 31, 2017
8,634
I have measured it and there is still 16V on MOSFET gate in OFF state (after the first switch push) which means that PMOS is still ON and I can not switch off the power source. Do you know what is the root cause of this? Thanks.
Either the circuit is not wired correctly and/or the mcu is not programmed as mentioned in post #13.
 
Last edited:

eetech00

Joined Jun 8, 2013
4,705
Because ON/OFF signal is active low on MCU.
The GPIO would be floating at boot-up, so the internal pull-up will be disabled at startup anyway. Its pulled down by R7.
Make the GPIO active high in software, and disable the internal pullup.

Do that in the MCU Setup() code.
 
Last edited:

Thread Starter

jan.sedlar

Joined Apr 14, 2021
31
Either the circuit is not wired correctly and/or the mcu is not programmed as mentioned in post #13.
I have double checked it and it is wired correctly. Could there be any leakage through PMOS? Since when I put an oscilloscope probe to Enable signal it works as expected. Without it I can not switch PMOS off. I guess the autostart does not work and a device is switched on because of the leakage as well? Any idea, please?
 
Top