I'm working on a battery-powered project with a 12V Lead-acid-battery and a DC-DC-step-down-regulator.
It is one of these cheap LM2596-step-down-modules.
The LM2560 itself draws 22 mA if the input is connected to 12V.
The regular case for shutting off is measuring the battery-voltage with a voltage-divider 1M/270 kOhm and if the battery voltage goes below 12.2V = ADC-input goes below 2,59V to switch off.
I have build some kind of a "self-hold-circuit" with a TTL-Gate-MOS-FET IRF3708.
There is a voltage-divider 1MOhm / 270 kOhm between +12V and GND. The middlepoint which has 2.55 V is connected to a "switch-on-button". If pressed the 2.55V get connected to the MOS-FET-Gate switching on the MOS-FET.
The MOS-FET powers up the DC-DC-step-down-regulator which is supplying the ESP32 with 5V on the Vin-Pin. I'm using the Vin-pin because I need 5V for a 8x8 WS2812-LED-matrix.
If the ESP32 is powered up an IO-pin is switched HIGH to continue switching on the MOS-FET.
I want to increase security against too-deep-discharging of the battery through some kind of a watch-dog that must be retriggered regularly to keep the MOS-FET-Gate-IO-Pin "HIGH"
I was thinking about adding a capacitor between ground and Gate in parallel to a discharging resistor.
The code would switch on the IO-pin for a short moment to load the capacitor through a 1kOhm-resistor and then the IO-pin switches off again. Capacitor starts discharging and if IO-pin does not switch to HIGH again the MOS-FET is switched off. Switching off everything except the 1M/270k-voltage-divider.
This approach has still the problem if the program hangs at MOSFET-Gate-IO-pin switched HIGH everything stays switched on discharging the battery too much.
So I would like to have something that switches the MOS-FET-Gate-IO-pin to low even in all cases if the program hangs at any line of code.
Does somebody know of such a possability?
The other approach is to not use the microcontroller for this but to use an external circuit that works on his own. If battery-voltage drops below 12.2V switch off. Does somebody know a simple circuit (= less than 10 parts) that can do this?
The approach with the MOS-FET reduces the current to 10 µA in the switched-off-state, because only the 1M/270k-voltage-divider stays connected to the battery.
everything else is switched off.
I confess to not reading all your post but your schematic has a huge, glaring error: Just after the ESP32 IO pin goes low to turn off the MOSFET, what voltage do you think will be on the IO pin and why?
PS, love the 'lazy' MOSFET symbol, not much different to the one I use when I hand draw them because I am too lazy to draw the proper ones.
As the capacitor is loaded to 3.3V if the IO-pin is switched to LOW = 0V
The capacitor will discharge through the 1k-resistor which is limiting the current to 3.3V / 1000 Ohm = 3.3 mA which should not damage the IO-pin.
Can you explain in detail where you see a problem in this?
best regards Stefan
Do you think that the output of the DC-DC-converter jumps up to 12V feeding in 12V into Vin?
Do you think if the gate-voltage lowers the MOS-FET's Ron-resistance increases and this will produce too much heat overheating the MOS-FET?
I build up the circuit except for the connection to the ESP32.
I was simulating switching the IO-pin to 0V through a wire.
And I watched the voltage on my DSO. It did just jump down to 0V
I still have no clue what the problem might be except maybe the overheating through too high R-on-resistance
best regards Stefan
You think that the IO pin is connected to ground I believe, yes?
How is it connected to ground? You don't need the inner schematic of the processor, you just need to know that the processor has a ground pin and realise that the only way the IO pin can be connected to ground is through that ground pin. How it get there through the inner workings of the processor are unimportant.
What is the ground pin of the processor connected to? Please don't say 'ground'. Look at your schematic, what is is connected to?
Well, OK, you got me there. I think it's connected to the output of the LM2596. You have it labelled as '5V' with the positive to Vin. You have not explicitly shown that the other line below the 5V is to the ground of the processor but I took that to be the case.
So, is my assumption correct? Or have I just wasted* half an hour of your time and my time because I didn't clarify that point?
Where do you think the processor's ground is connected?
*I don't really think it was wasted because something will be learnt from this whatever the outcome.
A. For what I assumed, which is that the ESP (or any processor, it's not important) was connected with +5V and 0V from the LM2956 output as on the extreme right of your schematic, then as soon as the MOSFET turns off there is no 0V (ground) to the LM2956 so there is no 0V to the ESP, so the output on the IO pin cannot be 0V because there is no circuit from the pin to 0V. Most likely the output will be the 12V from the LM2956 as that is all that goes into it, so must be what comes out the other end, to the ESP and thus to the IO pin. If the IO pin has 12V on it, or indeed any voltage significantly above 0V then it turns the MOSFET right back on again.
B. If the ESP 0V is connected to where you labelled it GND then with the MOSFET off then I would expect the output of the LM2956 to be 12V or close so you now have a lot more than the desired 5V on the ESP, so expect smoke. In any case, even without smoke, you are supplying power to ESP, so it is not turned off, which is what I think you were hoping for.