Electronics > Projects, Designs, and Technical Stuff
Switch between power sources automatically
<< < (4/4)
Zero999:

--- Quote from: OM222O on April 21, 2019, 02:03:50 pm ---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.

--- End quote ---
Yes, 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.
OM222O:
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
Zero999:

--- Quote from: OM222O on April 23, 2019, 04:51:32 pm ---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

--- End quote ---
It'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.
OM222O:
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.
Zero999:

--- Quote from: OM222O on April 23, 2019, 08:27:27 pm ---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.

--- End quote ---
That 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.
Navigation
Message Index
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod