Self latching circuit

Thread Starter

jan.sedlar

Joined Apr 14, 2021
31
Hey guys,

I need to build up the circuit that :
1/ when main power 5V is connected for the first time, MCU gets 5V (first time autostart).
2/ MCU starts and drive the PMOS switching on by active high signal via BJT.
3/ When you push momentary switch - it sends the pulse to MCU input signal which drive MCU to switch the power off via BJT.
4/ Another pushing momentary switch will again starts to MCU power on it drives it using BJT etc ....

So for the first time autostart, then switching off and on using output signal (active high) from MCU.

Would the below work?
Thanks.

1771189719351.png
 

Jerry-Hat-Trick

Joined Aug 31, 2022
806
Maybe I’ve not completely understood your requirement but why isn’t the switch connected between ground and an input pin of the MCU? If that input pin is pulled high with a resistor or internally, an output pin can toggle the transistor on and off. Loop check the status of the input pin and put a brief delay to prevent bounce.
 

Thread Starter

jan.sedlar

Joined Apr 14, 2021
31
As @Jerry-Hat-Trick says, the switch should connect only to the MCU input pin.
In the circuit shown, when the button is pressed to turn off, it will discharge the capacitor and so force the MOSFET on.
@Jerry-Hat-Trick @AlbertHall thanks, but this will not work since as mentioned in 4), I need to start MCU again by pushing the switch but MCU can not drive the switch because MCU does not have a power in that time. Any idea?
 

schmitt trigger

Joined Jul 12, 2010
2,056
I believe that I can see your point.
-The circuit has to start on its own when first powered up,
-And then using a single pushbutton switch, the microcontroller to be powered off and then on, then off…..
Is that what you’re after?

EDIT: and the supply voltage is higher than 5V?
 

Thread Starter

jan.sedlar

Joined Apr 14, 2021
31
I believe that I can see your point.
-The circuit has to start on its own when first powered up,
-And then using a single pushbutton switch, the microcontroller to be powered off and then on, then off…..
Is that what you’re after?

EDIT: and the supply voltage is higher than 5V?
@schmitt trigger the first start is correct, then using a single pushbutton to provide pulse to MCU which switch PMOS off and then using a pushbutton to switch the power on (but MCU has no power in that time since it is off) etc.
Supply voltage is 24V.
 

schmitt trigger

Joined Jul 12, 2010
2,056
At first glance, I believe that the circuit concept should work.
But 24 volts will damage your gate-source junction. You need to add a zener in parallel with your 1Meg resistor, and then a series resistor of perhaps 2.2k to limit the current.

Check the Mosfet’s data sheet and check Vgs maximum ratings. Choose a zener whose breakdown voltage is 2 or better 3 volts below that value.

EDIT: also include a pullup to 5V on your MCU’s input.
Go ahead and breadboard the circuit. As an aerospace engineer once told me: in the end after dozens of calculations, wind tunnel tests and simulations, an actual plane has to be built and some pilot has to fly it.
 

Thread Starter

jan.sedlar

Joined Apr 14, 2021
31
At first glance, I believe that the circuit concept should work.
But 24 volts will damage your gate-source junction. You need to add a zener in parallel with your 1Meg resistor, and then a series resistor of perhaps 2.2k to limit the current.

Check the Mosfet’s data sheet and check Vgs maximum ratings. Choose a zener whose breakdown voltage is 2 or better 3 volts below that value.

EDIT: also include a pullup to 5V on your MCU’s input.
Go ahead and breadboard the circuit. As an aerospace engineer once told me: in the end after dozens of calculations, wind tunnel tests and simulations, an actual plane has to be built and some pilot has to fly it.
@schmitt trigger thank you. As for 2k2 resistor, do you mean in series with zener diode?
 

sghioto

Joined Dec 31, 2017
8,634
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.
1771470083674.png
 
Last edited:

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 363624
@sghioto thanks. Will that work if MCU input pin has internal pull-up and no external voltage can be connected to that?
 

sghioto

Joined Dec 31, 2017
8,634
The reason for internal pullups and pulldowns is to make sure the pin is not "floating".
External resistors perform the same function.
A digital input is looking for either a High or Low signal voltage defined by the code to activate a function.
 

eetech00

Joined Jun 8, 2013
4,704
Here's another circuit suggestion.

1771533841712.png

1771457770565.png

Edit: Changed R7 to 2.7K. Added R1. MCU Digital components are for simulation only.
 
Last edited:
Top