Power latch to feed MCU on state change of switch (help fixing circuit)

Thread Starter

lpares12

Joined Sep 6, 2023
15
Hi!

Just for context, few months ago I wrote this post: https://forum.allaboutcircuits.com/...witch-changes-state-with-auto-turnoff.196069/

My idea is to make an independent power latch that will monitor state changes from a reed switch (or tbf any kind of switch) to power up an ESP-01 board. Another requirement is that the power should be ON until the ESP01 has finished its task (which is reading the state of the switch). Took forever to get the components, but finally managed to try it. I was recommended a circuit with an LDO with Shutdown capability, but since I couldn't find such component, I had to make it a bit different.

This is my (simplified) circuit:

1699688912672.png

Source is 5V. The LDO (https://datasheet.lcsc.com/lcsc/2110121030_onsemi-NCP164ASNADJT1G_C2902124.pdf) is also connected to Vin and Ground (but removed for simplicity). The transistor is a BC547 NPN transistor bought from aliexpress. The XOR is not really an XOR (since I don't have), but I made one out of two XNOR (https://datasheet.lcsc.com/lcsc/2302221900_Texas-Instruments-CD4077BE_C353982.pdf). And the capacitors are electrolytic (also from aliexpress). And I'm aware that the 100K resistor should be bigger to save battery.

In this case I'm having some issues:

1- It looks like when there's a state change, the time the ESP-01 goes on is super small, not long enough to power on and hold GPIO2 HIGH. So I'm wondering how can I make it longer. I know there's gonna be some bounce, but can't I just make the time the switch is on somehow longer (by cahnging the capacitors), so it will have enough time to account for the bounce?

2- And also, sometimes after a good 10-20 seconds after changing state, I can see the ESP-01 leds powering on and off. Which I don't really understand, since there shouldn't be any current flow towards there. I thought about the bouncing, but I don't think it bounces for 10-20 seconds...

I asked in another forum and was recommended to change the XOR for a RS Flip-Flop, to take into account the switch bouncing. This is the recommended circuit. But then again, it's hard for me to find those components without spending 40€ in shipping. And also, I'd like how to fix my circuit, not get a new one. This is the other recommended circuit for reference:

1699689024664.png

As I said my goal is to fix my circuit, not to use this new one if possible :D, just for learning purposes I want to know what is wrong and what would be the good way to fix it with common components, more than with another IC.

Thanks!
 

ci139

Joined Jul 11, 2016
1,898
it is difficult to suggest anything because we don't know
the timing details / specifics for the reed and for the MCU
when and how the power should be saved
what is the actual source supply ("+5V")
 

Thread Starter

lpares12

Joined Sep 6, 2023
15
it is difficult to suggest anything because we don't know
the timing details / specifics for the reed and for the MCU
when and how the power should be saved
what is the actual source supply ("+5V")

I see.. what kind of information is missing? The source is an MB102 set up as 5V and comes from a USB connection from a transformer. And the reed switch I bought on Aliexpress, so there's not much I can say...

As for the MCU it's an ESP-01, takes around 130ms to boot and set the GPIO2 to High to hold the LDO enable on.
 

eetech00

Joined Jun 8, 2013
4,061
I see.. what kind of information is missing? The source is an MB102 set up as 5V and comes from a USB connection from a transformer. And the reed switch I bought on Aliexpress, so there's not much I can say...

As for the MCU it's an ESP-01, takes around 130ms to boot and set the GPIO2 to High to hold the LDO enable on.
What rate will the reed relay switch so we have an idea of the pulse frequency? reed relay P/N?
So the pulse will have to be stretched to at least greater that 130ms?
When the ESP01 boots, does the GPIO pin float during boot?
Is the input signal normally low? of high? or floating?
 

Thread Starter

lpares12

Joined Sep 6, 2023
15
What rate will the reed relay switch so we have an idea of the pulse frequency? reed relay P/N?
Found some information in Aliexpress about the reed switch (which is one of those that is usually open):

Max. operate time: 0.45ms
Bounce time: 0.25ms
Max. release time: 0.35ms
Resonant frequency: 5000HZ
Max operating frequency: 400Hz
This is the link in case I'm missing something: https://www.aliexpress.com/item/400...t_main.47.6fdc194dYltySN&gatewayAdapt=glo2esp

So the pulse will have to be stretched to at least greater that 130ms?
Yes, the pulse should be at least 130ms, so I have time to set the GPIO2 HIGH.

When the ESP01 boots, does the GPIO pin float during boot?
Is the input signal normally low? of high? or floating?
Looks like the GPIO2 is pulled up (right side image since I have an ESP-01S). Not sure what you refer to as Input signal, if you mean Vin(Vcc) then I'm not really sure, I guess it's floating.
1699862922963.png

Thanks!
 

ci139

Joined Jul 11, 2016
1,898
PS! -- this circuit is an LTspice experiment -- in real, you may need to redesign it, and expect a way lower sensitivity, and somewhat higher power consumption . . . also the dependency from the supply voltage may pose some issues - so - your CD4013 / 74HC74 circuit will likely perform better

Note -- i couldn't fit the XNOR gate in , it is redundant to this design!

Short-pulse-detector - xnor.gif
 

ci139

Joined Jul 11, 2016
1,898

Attachments

Last edited:

ci139

Joined Jul 11, 2016
1,898
the 4077 variant (Falstad simulation - ! has its event sensitivity dependent on integrating time-step value)
Note: for the inverters (labelled "NOT") the lower input is connected to GND
. . . OUTPUT is the "Y" shoulder of the Flip-Flop

Short-pulse-detector - xnor2bb.png
 
Last edited:
Top