Latch Circuit

Thread Starter

Waleed Sajid

Joined Oct 17, 2023
9
Hi Guys! I am making a latch circuit where i have a push button,MAX16054 IC, enable LDO IC AP2112 and ESP32 that operates at 3v3. Ok now i want to make latch circuit functionality bery similar to that of MP3 player where ON Long press you turn OFF and ON the device.There maybe other sorts of devices that you may be familiar with that follows the same functionality. I want to configure my circuit in such a way that when i long press the button for approximately 3 sec, MAX16054 will latch enable pin of LDO that would then output 3.3V to Esp32. I am supplying 5V from the battery to VCC of MAX16054 and to Vin of LDO. This is what i want to achieve but the problem arises in the push button. I have used 555 timer next to push button but it adds delay issues when i add modes to my MCU. Thats why timer IC is not recommended here.I tried with RC circuit but still no good. I hope someone would read it and give some solution...thanks
I have added a picture that would be very helpful
 

Attachments

Thread Starter

Waleed Sajid

Joined Oct 17, 2023
9
Yes but problem is our MCU will be then in sleep mode or deep sleep mode which will continue to consume power even when device is not in our use
 

crutschow

Joined Mar 14, 2008
38,503
The design of the IN circuit on the MAX16054 does not lend itself to an easy way to delay its operation.
Would an added transistor, a few resistors, and capacitor be acceptable for that purpose?

LTspice sim of example circuit below:
It should give a delay of about 3-4 seconds at the IN input.

1698125949843.png
 

Thread Starter

Waleed Sajid

Joined Oct 17, 2023
9
Th
The design of the IN circuit on the MAX16054 does not lend itself to an easy way to delay its operation.
Would an added transistor, a few resistors, and capacitor be acceptable for that purpose?

LTspice sim of example circuit below:
It should give a delay of about 3-4 seconds at the IN input.

View attachment 305735
Thanks can you help me explain whats going in the circuit you made and yes transistors resistors and capacitors are acceptable
 

Jon Chandler

Joined Jun 12, 2008
1,595
In several of the above circuits, the micro controller holds the power on until it senses the button is pressed, at which time it turns off the power to itself. The microcontroller SECIDES when to turn itself off. If it senses the off button is pressed, it can detect how long the button is pressed.

Button press detected, and released within a second --> do thing one.

Button pressed detected and released within 2 seconds --> do thing two.

Button press detected and still pressed after 5 seconds --> power off.

If button pressed, wait 500 mS

If button not pressed do thing one

Else wait 1000 mS

If button not pressed do thing two

Else wait 3500mS

If button pressed turn off.
 

crutschow

Joined Mar 14, 2008
38,503
Thanks can you help me explain whats going in the circuit you made
When the PB is pressed and applies voltage to R2, then R1, R2, and C1 simply delay the turn on of the transistor.
When the transistor turns on, it pulls IN low which toggles the circuit.

You may have to tweak the values of C1 to get the desired delay in the actual circuit.
 

eetech00

Joined Jun 8, 2013
4,705
Hi Guys! I am making a latch circuit where i have a push button,MAX16054 IC, enable LDO IC AP2112 and ESP32 that operates at 3v3. Ok now i want to make latch circuit functionality bery similar to that of MP3 player where ON Long press you turn OFF and ON the device.There maybe other sorts of devices that you may be familiar with that follows the same functionality. I want to configure my circuit in such a way that when i long press the button for approximately 3 sec, MAX16054 will latch enable pin of LDO that would then output 3.3V to Esp32. I am supplying 5V from the battery to VCC of MAX16054 and to Vin of LDO. This is what i want to achieve but the problem arises in the push button. I have used 555 timer next to push button but it adds delay issues when i add modes to my MCU. Thats why timer IC is not recommended here.I tried with RC circuit but still no good. I hope someone would read it and give some solution...thanks
I have added a picture that would be very helpful
If you want to use the MAX16054, here's one way to do it.
The mosfet has to have a low VGS(th) spec (2v or lower).
Use P1 to adjust the delay time (~3sec is shown below).
The LED is optional but will have to be low current, 1.6mA max.

1698168641830.png
 

Thread Starter

Waleed Sajid

Joined Oct 17, 2023
9
If you want to use the MAX16054, here's one way to do it.
The mosfet has to have a low VGS(th) spec (2v or lower).
Use P1 to adjust the delay time (~3sec is shown below).
The LED is optional but will have to be low current, 1.6mA max.

View attachment 305784
Hey thanks for your generous reply i am trying to debug your circuit but i dont think if i can achieve my functionality here.....can you explain how i can ensure long press and release to Latch LDO and long press and release to unlatch my LDO here....you how things work in MP3 where there is only one button to power ON and power OFF circuit on long press
 

Thread Starter

Waleed Sajid

Joined Oct 17, 2023
9
In several of the above circuits, the micro controller holds the power on until it senses the button is pressed, at which time it turns off the power to itself. The microcontroller SECIDES when to turn itself off. If it senses the off button is pressed, it can detect how long the button is pressed.

Button press detected, and released within a second --> do thing one.

Button pressed detected and released within 2 seconds --> do thing two.

Button press detected and still pressed after 5 seconds --> power off.

If button pressed, wait 500 mS

If button not pressed do thing one

Else wait 1000 mS

If button not pressed do thing two

Else wait 3500mS

If button pressed turn off.
Thanks for your generous reply bro but i dont want to use my MCU in sleep mode or in deep sleep mode all the time because it will then consume power in small quantities which will add up after long time
 

Jon Chandler

Joined Jun 12, 2008
1,595
Thanks for your generous reply bro but i dont want to use my MCU in sleep mode or in deep sleep mode all the time because it will then consume power in small quantities which will add up after long time
Like I said, watch the videos. None of the circuits I posted keep the micro in any kind of a sleep mode; they all power the micro off.
 

Thread Starter

Waleed Sajid

Joined Oct 17, 2023
9
Below is my circuit with R4 added to reduce the recovery time when the switch is released, which otherwise is very long.

View attachment 305787
Thanks but it is not giving me the right functionality you see Vin remains latched all the time even button is closed or open for long press or short press.....i want Vin = 3.3V latched when button is pressed for 3 or more seconds, this will be power ON state.....Vin = 0V when button is pressed again for 3 seconds or more and release
 

k1ng 1337

Joined Sep 11, 2020
1,038
Thanks but it is not giving me the right functionality you see Vin remains latched all the time even button is closed or open for long press or short press.....i want Vin = 3.3V latched when button is pressed for 3 or more seconds, this will be power ON state.....Vin = 0V when button is pressed again for 3 seconds or more and release
You can use a SPDT switch and a SR latch made from 2 NAND or 2 NOR gates to perform your desired function. A NAND SR latch has active low inputs while a NOR SR latch has active high inputs but it doesn't matter in this case unless you really want to use buttons. Use pull up or pull down resistors to make sure it stays latched.
 

Jon Chandler

Joined Jun 12, 2008
1,595
If you had watched the videos shown for each latch circuit (seems like I've said that a bunch), you'd know how they worked.....

You can't quite do exactly as you ask, but you can do something nearly identical. A number of the circuits depend on the micro to hold them on until the micro releases a pin and shuts them down (you know, like I described for getting multiple functions when you press the switch). Pushing the button when the micro is off will power up the micro while it's pushed, but if you program the micro not to do anything until it counts to 3 seconds or 5 or 10 or 60, it will go off again – if it hasn't asserted the pin to hold the power on (not until after the desired delay) it will go off.

So your on delay is accomplished with the micro only powered as long as the button is pressed if the desired interval isn't exceeded, AND your goal of having multiple functions depending on length of button press while the micro is on has also been accomplished.

Dude, it's not that difficult if you take a few minutes to understand the circuits I posted, and the linked videos are all pretty clear.
 

Thread Starter

Waleed Sajid

Joined Oct 17, 2023
9
If you had watched the videos shown for each latch circuit (seems like I've said that a bunch), you'd know how they worked.....

You can't quite do exactly as you ask, but you can do something nearly identical. A number of the circuits depend on the micro to hold them on until the micro releases a pin and shuts them down (you know, like I described for getting multiple functions when you press the switch). Pushing the button when the micro is off will power up the micro while it's pushed, but if you program the micro not to do anything until it counts to 3 seconds or 5 or 10 or 60, it will go off again – if it hasn't asserted the pin to hold the power on (not until after the desired delay) it will go off.

So your on delay is accomplished with the micro only powered as long as the button is pressed if the desired interval isn't exceeded, AND your goal of having multiple functions depending on length of button press while the micro is on has also been accomplished.

Dude, it's not that difficult if you take a few minutes to understand the circuits I posted, and the linked videos are all pretty clear.
Yes thank you very much for your consideration
 

eetech00

Joined Jun 8, 2013
4,705
Hey thanks for your generous reply i am trying to debug your circuit but i dont think if i can achieve my functionality here.....can you explain how i can ensure long press and release to Latch LDO and long press and release to unlatch my LDO here....you how things work in MP3 where there is only one button to power ON and power OFF circuit on long press
Review the circuit and graph in post #11 for the following comments.
1. PB is an ordinary normally open push button.
2. (R4+P1) and C1 control the length of delay.
3. D1 permits a quick discharge of C1 when the button is released.
4. The mosfet (M1) is an N type, with a low gate threshold (turn-on) voltage, equal to, or less than, 2v.
5. The MAX16054 (U3) is PB debouncer with a latched output and active low input.
The Q output connects to the LDO "enable" pin.
6. A long press is the button held pressed for at least 3 seconds. A short press is the button held, or pressed, for less than 3 seconds.

How it works:
On power-up,
Any charge that might exist on C1 is quickly discharged thru D1 and R2, so the mosfet is off.
U3-IN is high. U3-ENA is low, so the LDO is disabled. U3-Qbar output is high, so the LED is off.

When a long press occurs:
C1 is slowly charged thru R4+P1. When the charge voltage at node RC exceeds the gate threshold voltage of M1, M1 turns on and applies a low to U3-IN. This triggers U3, latches the U3-ENA output high and activates the LDO. U3-Qbar latches low and lights the LED. When PB is released, U3-ENA remains high.

When a short press occurs:
The circuit remains in the state before the short press.

When a long press occurs again:
The same operation as the previous long press except the U3 will toggle U3-ENA output low, de-activating the LDO, and turns off the LED.

P1 is provided so that the delay can be adjusted per the gate threshold voltage of M1.

Hope that helps.
 
Last edited:
Top