Automatic 12V power source switching to battery backup - Page 1
Forum section: electronics / beginners

author: newtekuser
author_rank: Frequent Contributor
timestamp: December 25, 2024, 03:13:54 am
content: I am working on a simple 12V power source switching circuit using a P-channel mosfet and LTC4412 IC. The idea is to automatically switch to 12V battery backup if the primary power is out. I'm prioritizing the primary by adding a schottky diode to create a small voltage drop on the backup. Can someone please chime in if I messed something up in the wiring? Schematic attached.Thanks in advance!

author: Terry Bites
author_rank: Super Contributor
timestamp: December 25, 2024, 02:59:47 pm
content: Just before I have my lovely lunch.....Your schematic shows the MOSFET is shorted out?It should look like this:

author: newtekuser
author_rank: Frequent Contributor
timestamp: December 25, 2024, 05:58:59 pm
content: Quote from: Terry Bites on December 25, 2024, 02:59:47 pmOops, I very much misunderstood the operation of the IC. Corrected.So, the VIN of the IC is connected to the backup source and not the primary source, or is that depending on whether I want to monitor when the backup goes offline instead of the main power?Also, for "prioritization" of main power over battery (to prevent battery from being used when main is active), is the use of a schottky diode to create a voltage drop the right approach?

author: xvr
author_rank: Frequent Contributor
timestamp: December 26, 2024, 11:37:01 am
content: Wrong again. D1 polarity is wrong, and cathode of D8 should be connected to D of MOSFET

author: newtekuser
author_rank: Frequent Contributor
timestamp: December 26, 2024, 12:57:45 pm
content: Quote from: xvr on December 26, 2024, 11:37:01 amThank you! It's 5am but 3rd time's a charm

author: xvr
author_rank: Frequent Contributor
timestamp: December 26, 2024, 01:25:00 pm
content: Now it looks correct

author: newtekuser
author_rank: Frequent Contributor
timestamp: February 02, 2025, 11:29:37 pm
content: So now that I've built the circuit I'm seeing an issue: when the main 12 DC power is live, the 12V auxiliary circuit is also live (reading 12V) and once I connect a battery source to the 12V aux power both fuses die, taking down the device. Did I mess something up in my schematic? (attached)

author: Peabody
author_rank: Super Contributor
timestamp: February 03, 2025, 04:12:10 am
content: I don't see the second fuse. But I'm confused by the circuit. Current flows through D8, then through the body diode of the mosfet, then to the input of U6. Is that what you want? Also, the net labels seem to have 12V on both sides of D8.If you have the mosfet, maybe you don't need the ideal diode. See the circuit below. Note that the source terminal of the mosfet is toward the load so the body diode is oriented correctly. If the main supply is present, current will not flow through the body diode unless the battery voltage less 0.7V is greater than the 12V supply less 0.3V. Or maybe both diode drops are greater if the current is high, but the principal is the same. Of course the circuit won't work if the battery voltage is materially higher than the 12V main supply.

author: newtekuser
author_rank: Frequent Contributor
timestamp: February 03, 2025, 05:59:47 am
content: Quote from: Peabody on February 03, 2025, 04:12:10 amI wanted an ideal diode instead of just a mosfet for max efficiency as the backup source is a battery and the current draw can be up to 1.5A.The circuit (minus the reverse polarity portion) is taken from the LTC4412 datasheet. Terry Bites also posted a picture from the DS in the second post.Now, the reason for the same net name on both sides of D8 is just me being sloppy and not naming things properly, but I think this may also be the contributing factor to the source (shorts) of my problems.The board takes two power sources, a main 12V DC from the wall wart and 12V DC from battery which should only kick in when main fails. Both circuits (main and backup) power a buck converter (which powers up other parts of the board), and a stepper motor driver. Both need to work independent from each other.I've attached the layout for more context.

author: Peabody
author_rank: Super Contributor
timestamp: February 03, 2025, 02:52:21 pm
content: Ok. If you connect both supplies, but with no connection from the output to the converter, do the fuses still blow? Well, aside from the diodes being installed backward, I don't have a ready explanation for what's happening.Edit: I can't really tell anything from the layout, but it seems if you get voltage at the auxilliary connector when the main supply is plugged in, then either D1 is installed backward, or there is indeed a short somewhere.Edit2: Your circuit still differs from the datasheet with regard to the orientation of U5. I know it looks backwards for a P-channel, but the drain should connect to the battery, and the source to the load. That makes the orientation of the body diode the same as the diode from the main supply. I don't know if this is the explanation because D1 should still prevent current from the main supply from flowing back to the battery, which I assume is what's blowing the fuse (essentially unlimited charging current) unless there really is a short.

author: newtekuser
author_rank: Frequent Contributor
timestamp: February 03, 2025, 09:49:01 pm
content: Quote from: Peabody on February 03, 2025, 02:52:21 pmTurns out D2 (TVS diode) on 12V main was backwards as well as D4 (zenner diode). Now the behavior is as follows (looks partially working to me... or is this how this is supposed to work?):Connect 12V main only: 12V backup not energized (tested at the F2 terminal)Connect 12V backup only: 12V main also energized (tested almost 12V at the barrel jack connector) and 12V backup draws 0.034A.Connect 12V main + 12V backup: 12V main AND 12V backup energized (current draw in minimal so no short; 12V main draws 0.026A while 12V backup only 0.004A)Disconnect 12V main with 12V backup connected: Now 12V backup draws 0.034ARe-connect 12V main with 12V backup connected: Now 12V main draws 0.026A while 12V backup draws 0.004AThe main fuse still blows sometimes in these conditions unless I remove all bulk capacitors on input, totaling 660uF. Both fuses are rated for 2.5A each, I think they're undersized for the initial draw while caps are charging.

author: Peabody
author_rank: Super Contributor
timestamp: February 03, 2025, 10:35:32 pm
content: Quote from: newtekuser on February 03, 2025, 09:49:01 pmNo. Current from the battery cannot get past D8 to register at the main input. D8 is there to prevent that. Unless the "+12V" nets on both sides of D8 really are connected, which they shouldn't be.I want to make one more comment about this circuit. In reply #8, you saidQuoteYou have not achieved max efficiency. You have the battery supply running through D1, which results in a voltage drop across that diode. You need that diode only because you have the mosfet oriented backward. If you oriented it as Terry Bites posted, you wouldn't need D1. In fact, my very simple circuit in reply #7 is more efficient than any circuit you can make with the ideal diode, because is has zero operating current from the battery. Current through the pulldown resistor comes only out of the mains supply. Well, I just wanted to make that point.

author: newtekuser
author_rank: Frequent Contributor
timestamp: February 04, 2025, 12:39:32 am
content: Quote from: Peabody on February 03, 2025, 10:35:32 pmThank you very much for the suggestion! I very much like the idea of eliminating the LTC4412 altogether in favor of just the mosfet and I can see now that with D1 gone I don't have to worry about its voltage drop when the battery is used.This is what I've got now (attached). Anything I missed?

author: Peabody
author_rank: Super Contributor
timestamp: February 04, 2025, 01:22:40 am
content: That looks fine to me, but you'll need to test it. Just make sure D8 is oriented correctly, and hasn't failed for some reason.

author: emperox
author_rank: Newbie
timestamp: June 01, 2025, 11:16:39 pm
content: Quote from: Peabody on February 03, 2025, 04:12:10 amI tried to implement the exact same circuit as newtekuser, but in my case my battery voltage is 13.3V and the main supply voltage is 12V so for that reason my circuit doesn't work right and voltage from the battery is back-fed into the main when the battery is present and power from supply is provided. The battery is draining and I can measure voltage (from negative battery terminal to D8 positive) at my D8 when main supply is active . I was expecting to see a short when the battery is back-feeding but there's noneAnyhow, how can I make this work right and prevent the back-feeding of voltage from the battery when main supply is also present?

author: emperox
author_rank: Newbie
timestamp: June 02, 2025, 01:00:04 am
content: Quote from: emperox on June 01, 2025, 11:16:39 pmNevermind, my circuit is working fine. Despite the voltage, there is minimal (leakeage?) current only 0.002A from the battery when the main supply is also connected.

author: calzap
author_rank: Frequent Contributor
timestamp: June 02, 2025, 01:27:08 am
content: Although using solid state for this purpose can be useful and educational, is there some reason the OP can’t use a relay for the intended purpose? There can be circumstances where a relay would not be appropriate like frequent switching, need for very short delay, need to switch over at a particular voltage on the PSU input, etc. However, hard to beat a relay for robustness, isolation and simplicity.Mike

author: Peabody
author_rank: Super Contributor
timestamp: June 02, 2025, 02:06:43 am
content: Quote from: emperox on June 02, 2025, 01:00:04 amSo are you saying when both are connected the main supply is providing all the load current, and the battery is supplying none? I assume that's what you want to happen.I'm not sure what circuit you are using, but if there is a diode in the main supply line, I don't see how there could be any back-feeding. The problem with having the battery voltage higher than the main supply is that if it's high enough, the battery will supply the load current even when the main supply is present - through the mosfet body diode.

author: emperox
author_rank: Newbie
timestamp: June 02, 2025, 02:59:15 am
content: Quote from: Peabody on June 02, 2025, 02:06:43 amThat's correct, when both are connected, the main supply is providing all the load and from the battery side I only see a 0.002A draw which I'm thinking must be leakage from the mosfet, maybe?What threw me off was that when I was testing with my bench power supply, both channels (for battery and "main") were set to 12V, so I was reading 12V at the diode (0.002A load though) not knowing if it was coming from the battery or main. But now with a real battery connected and charged to 13V, I am reading 12V at the diode when the main supply is connected. Hope I'm making sense.

author: Peabody
author_rank: Super Contributor
timestamp: June 02, 2025, 03:04:01 am
content: Maybe. Can you set up your meter to measure whether that current is actually flowing through the mosfet, and not back into the charger or protection circuit?

author: newtekuser
author_rank: Frequent Contributor
timestamp: June 12, 2025, 02:34:46 am
content: Quote from: calzap on June 02, 2025, 01:27:08 amThe circuit is powering an MCU which needs to be functional without any downtime not to miss events if power is switching between main and backup. With the slow reaction time of the relay compared to MOSFET this will be a problem.

author: mariush
author_rank: Super Contributor
timestamp: June 12, 2025, 03:49:44 am
content: There's power switches you can use, like TPS2121 :https://www.digikey.com/en/products/detail/texas-instruments/TPS2121RUXR/9859001Each input is good up to 22v, and you can select inputs using a signal on a pin.Quote from: newtekuser on June 12, 2025, 02:34:46 amYou're gonna have a dc-dc converter to reduce 12v to 3.3v/5v or whatever the micro neeeds so you'll have input and output capacitors, they'll hold enough charge to sustain your micro for a few millisecondsTPS2121 chip switches in 5us (0.05ms) , and tps2020 (lower current, max 3A) is max 100us (0.1ms)

author: calzap
author_rank: Frequent Contributor
timestamp: June 12, 2025, 04:53:14 am
content: Properly designed solid state can be a lot faster than mechanical relays. Solid state relays can switch very quickly. As mariush states, capacitors can be used to provide power to the electronics during the switchover time.Mike

author: tooki
author_rank: Super Contributor
timestamp: June 12, 2025, 09:07:53 am
content: Quote from: newtekuser on February 04, 2025, 12:39:32 amDid you delete all the diagrams from your replies? It’s annoying to everyone reading the thread later on.

author: radiolistener
author_rank: Super Contributor
timestamp: June 15, 2025, 08:28:30 pm
content: you can use this approach for automatic switch between battery and PSU for backup purposes. The main idea is to use voltage detector (on picture U1 for 5V) to generate switch signal which controls FET switches which also block reverse currents