Hi @ShermanP. As promised, here's an update on the battery backup circuit (using P-Fets) I'm trying to make.
My LTC4412’s have arrived and I’ve tested both the “Automatic PowerPath Control” and the “Ideal Diode Control with a Microcontroller” example’s from the datasheet, which are both pictured in post #32.
LTC4412 datasheet; https://www.analog.com/media/en/technical-documentation/data-sheets/4412fb.pdf
They both work great.
Despite the fact that it’s more component hungry, I’ll probably go with the “Ideal Diode Control with a Microcontroller” example, as it allows the auxiliary voltage to be higher than the mains voltage. This gives only a very slight loss of efficiency, as RDS(on) is indeed very low. That’s also a lot more efficient than using a Schottky diode as an OR-ing circuit, by my calculations.
I’ve mostly replicated the circuit from the datasheet, but I added in an NPN transistor and an Op-amp as a voltage comparator (Op-amp is not pictured). I am also now using 4 x AA batteries, which gives a battery voltage of around 6.8V.
The first picture is the original schematic from the datasheet, and the second picture is my small addition of an NPN transistor between the STAT pin and the gate's of the Auxiliary Fets.
The way my full circuit works is that once the 5V mains PSU drops to 4.5V (which would indicate a power loss), the Op-amp comparator circuit (not pictured) sends a signal to an interrupt pin on the ESP-32, and the ESP immediately sets the CTL pin on the LTC4412 to HIGH. This causes the Auxillary battery power to take over, as the STAT output pin (open-collector) switches to LOW.
However, if mains power returns, setting the CTL pin back to LOW will not actually get the 5V mains power to take over again. This is stated in the datasheet. 5V Mains power will only come back if both the CTL pin is LOW and the battery voltage falls below mains voltage.
So to solve that problem, I’ve added in an NPN transistor (T1). When the NPN transistor is turned on, it provides a path to ground (via the STAT pin) for the Auxillary P- Channel Mosfets, so that if the STAT pin goes LOW, the Auxillary P-fets can turn on. When the NPN transistor (T1) is turned off, it disconnects the P-fets from ground, which cuts the battery voltage and reconnects the 5V mains voltage (provided CTL is LOW).
That same NPN transistor can also allow me to automatically cut power to the ESP32 when I've backed up everything to the SD card (provided mains power doesn't return in time), which is what I intend to do.
It's also worth mentioning that there's a small delay (few seconds) in Setup when the MCU first turns on, as the under-voltage signal will be triggered when the power supply is first turned on.
The 470K resistor R1 in the original example acts to pull-up the STAT pin, so I added another resistor, R2, to also pull-up this stat STAT pin up when the NPN transistor (T1) is turned off. Not sure if it's necessary, but I don’t think it will hurt. I think that 470K resistor is also used to keep that gate of the Auxiliary mosfets HIGH when they are not connected to ground.
I’ve tested this exact circuit and it works very well and consistently. It is so fast that it works without using a capacitor (capacitor is used to keep the circuit alive while the switching takes place), though I’ll add one anyway.
I know you said you're not familiar with the the LTC4412, but is there any problems you can see with my addition of the NPN transistor to the circuit, or other feedback?
Thanks!