Switch between power sources automatically - Page 1
Forum section: electronics / projects

author: OM222O
author_rank: Frequent Contributor
timestamp: April 20, 2019, 02:12:08 pm
content: HelloI have a project that runs on a battery and a 12v jack. I can detect the voltage at 12v line and switch to it when I detect a voltage. there is also a capacitor that allows the MCU to operate and switch back to the battery when the 12v line is disconnected. my only issue is coming up with a way of actually doing that ... I initially tried using mosfets but then the 12v line back feeds the battery via the body diode of the fet which is no good ... a mechanical solution such as a relay is also no acceptable. I also can't really use diodes as the device can pull up to 5 amps and that's simply way too much of wasted energy and heat do deal with. are there any easy solutions that come to mind for switching between the two sources? thanks!

author: KC0PPH
author_rank: Unknown
timestamp: April 20, 2019, 02:49:52 pm
content: Use a Diode if current is not too much.12V Supply goes directly to your circuit12V Battery goes through a diode.If you want protection against backfeeding your 12V supply use 1 diode in series with your 12V supply and 2 in series with your battery.Quick and dirty and works like a charm.

author: SiliconWizard
author_rank: Super Contributor
timestamp: April 20, 2019, 03:27:33 pm
content: One way of avoiding to be bothered with the body diode is to put two MOSFETS back-to-back.

author: OM222O
author_rank: Frequent Contributor
timestamp: April 20, 2019, 03:47:03 pm
content: I'm sorry if this sounds stupid but I'm not sure how back to back fets would work. Can you please provide a schematic?

author: madires
author_rank: Super Contributor
timestamp: April 20, 2019, 03:53:33 pm
content: Search for "ideal diode" or "power oring". For example LTC4359 which I'm using for one of my projects.

author: SiliconWizard
author_rank: Super Contributor
timestamp: April 20, 2019, 04:11:56 pm
content: Quote from: OM222O on April 20, 2019, 03:47:03 pmYou can find the principle here:http://www.ti.com/lit/an/slva948/slva948.pdf(don't mind the eFuse devices, the first pages explain the concept.)There are also integrated OR'ing controllers so you might want to look that up as well.

author: OM222O
author_rank: Frequent Contributor
timestamp: April 20, 2019, 06:36:39 pm
content: I think the fet approach is cheaper although it might take a bit larger space on the pcb. Thanks for all the replies!

author: Zero999
author_rank: Super Contributor
timestamp: April 20, 2019, 09:49:10 pm
content: If you just connect two Pchannel MOSFETs up, back-to-back, with the sources tied to 0V, they'll act as low value resistors. Some active circuitry is required to direct which MOSFET and therefore which power supply is active. An ideal diode controller does this by monitoring the voltage across the MOSFET and turning it off, if it senses the current is reversing.If the voltage drop is acceptable, then the cheapest option is zener diodes.

author: OM222O
author_rank: Frequent Contributor
timestamp: April 20, 2019, 10:29:57 pm
content: I understand how the power oring chips works but even the cheapest one on mouser (MAX40200) costs about 0.70$ ... I can get 2 dual fets (any fet is easily rated for 5A) for almost half of that, but those chips are also a viable option. thanks!

author: KL27x
author_rank: Super Contributor
timestamp: April 21, 2019, 12:02:13 am
content: Quote??QuoteI'm now extra super confused.

author: Zero999
author_rank: Super Contributor
timestamp: April 21, 2019, 06:56:11 am
content: Perhaps I'm confused? No schematics have been posted of what the original poster meant by two MOSFETs.Quote from: OM222O on April 20, 2019, 10:29:57 pmHow would you intend to solve this, without one of those ICs?Because the MOSFETs conduct in both directions, the voltage on one input can back-feed to the other input, which isn't connected. The direction of the current needs to be sensed, in order to decide which MOSFET is activated, and is what these ideal diode controllers do. It's possible to do it with and op-amp, but is far easier to just use a dedicated IC.

author: madires
author_rank: Super Contributor
timestamp: April 21, 2019, 11:14:07 am
content: Quote from: OM222O on April 20, 2019, 10:29:57 pmIt's either an ORing controller plus MOSFET or a Schottky diode with larger power loss (less battery runtime). Choose one!

author: OM222O
author_rank: Frequent Contributor
timestamp: April 21, 2019, 02:03:50 pm
content: as per the application note by TI, if you connect two P channel fets with common source config (or N channels with common drain) there will be 2 body diodes in opposite directions, effectively blocking the back feed. their gates are also connected so they turn on / off together. dual fets with common drain / source configs are pretty cheap on mouser.

author: SeanB
author_rank: Super Contributor
timestamp: April 21, 2019, 02:27:58 pm
content: Dual 12A Schottky rectifier in a TO220 package, with power from battery on one leg and 12V on the other. 0.4V drop, and low enough leakage at room temperature to not worry, plus with 5A only a small TO220 PCB mount heatsink needed. 2W of power worst case, and the highest voltage source supplies the load, no dropout when changing. Common item, used in every PC power supply, and available from multiple vendors.

author: OM222O
author_rank: Frequent Contributor
timestamp: April 21, 2019, 02:40:47 pm
content: as I mentioned, I don't want to deal with diodes because of huge wastes of power and voltage drop (especially from battery) as I said the cheapest option seems to be the dual fet approach.

author: Zero999
author_rank: Super Contributor
timestamp: April 23, 2019, 10:43:49 am
content: Quote from: OM222O on April 21, 2019, 02:03:50 pmYes, I did read the application note. The question is how do you intend to control the gates?What determines which MOSFET is on and which one is off?Imagine the capacitor and 12V supply are connected to the 12V input via switches and the 12V supply is removed. How are you going to detect the fact that the 12V supply has been disconnected? You can't simply monitor the 12V supply, because the charge on the capacitor will back-feed into it.That's what the ideal diode IC does. It monitors the current direction through the MOSFET and turns if off if the current starts to reverse. Some ideal diode controller ICs have the benefit of an internal charge pump, so a single N-channel MOSFET per channel can be used.

author: OM222O
author_rank: Frequent Contributor
timestamp: April 23, 2019, 04:51:32 pm
content: I monitor the 12v rail itself using a resistor divider and the analog comparator provided by the MCU (D6 of arduino). the mosfet is placed after that which is the same for the battery rail. that way when the 12v supply is connected, it triggers an ISR to first turn off the fets on the battery, and then turn on the 12v rail fets (which happens in a few mS) same situation for when the 12v line is disconnected. the ISR will turn those fets off and turn the ones on the battery on. If there is enough capacitance on the 5V rail of the MCU to keep it going for lets say at least 100mS, then during the short gap between disconnecting and connecting the fets nothing bad happens, just a small Vdroop on the 5v rail as the cap discharges. This actually should work surprisingly well

author: Zero999
author_rank: Super Contributor
timestamp: April 23, 2019, 07:28:40 pm
content: Quote from: OM222O on April 23, 2019, 04:51:32 pmIt's difficult to visualise without a schematic.Are you trying to do something like this?How do you decide which MOSFETs to activate?What happens if the battery has a slightly higher voltage, than the supply voltage or can't that happen? If it can, then there's the issue of the battery back-feeding into the supply. Remember once on, the MOSFETs conduct in both directions. They don't act like diodes, but switch contacts. Even if the battery can't be a higher voltage, then the supply, there's still the issue of knowing which MOSFETs to turn on.

author: OM222O
author_rank: Frequent Contributor
timestamp: April 23, 2019, 08:27:27 pm
content: Yes, that schematic is exactly correct, except the BAT_MON section. it's not needed as we can assume battery is always connected (it also charges from the PSU with a buck converter when PSU is connected, similar to a how a laptop works). and yes, battery is always lower voltage than PSU (2S lipo, so maximum of 8.4V). As I mentioned the battery fets are on as default. as soon as the voltage on PSU_MON is detected (it still can't feed anywhere, mosfets are disconnected). the MCU switches off the BAT_CNTRL fets and a few mS later, it turns on the PSU_CNTRL fets. using this "break before make" (if you will) approach we can ensure nothing ever back feeds as the two sources are never on at the same time! as I explained, I just need enough capacitance on the whole circuit (not only in parallel with Rload as you drew it) to allow the MCU to stay on while making this switch over where there is no power from either the battery or the PSU.

author: Zero999
author_rank: Super Contributor
timestamp: April 23, 2019, 09:08:39 pm
content: Quote from: OM222O on April 23, 2019, 08:27:27 pmThat makes sense, I think.In future please post a schematic. It will save yourself and us a lot of time. Even a rough sketch is far better than a verbal description.