# Best way to switch between multiple power rails based on whether they're present or not [duplicate]

I've come across this issue multiple times already and never really figured out the best way to do it.

I'm designing a controller PCB for a drone and I would like to have a few different ways of powering it. USB power just for the control electronics, a battery connector (2-4S, not really sure yet) for the ESCs/motors and another regular connector for development 12V supply so I don't have to rely on batteries.

Now, I'd love to have a circuit that would automagically switch between these and make sure only one of them is active at any time to protect other supplies from reverse current and what not if multiple are plugged in at the same time. For instance, I would probably have USB and the 12V supply or battery plugged in at the same time during development because USB would just be used for debugging and the 12V supply or the battery to power all of the electronics and motors. Priorities would be 12V supply > battery > USB.

I could probably figure out the rest out myself but I just don't know where to start with this.

## marked as duplicate by Elliot Alderson, Oleg Mazurov, Dmitry Grigoryev, Huisman, FinbarrSep 18 at 9:26

• It's close, but the other question requires a focus on discrete solutions, and on two power sources. This question allows for inclusion of integrated solutions, and looks at three power sources (Battery, USB, and HiV) which is a fairly common specific situation. – Brandon Hill Sep 5 at 18:02
• An Analog Diode OR solution might be “Highest Source V supplies the current” – Tony Stewart Sunnyskyguy EE75 Sep 5 at 19:23
• The inclusion of "integrated solutions" would be border line with shopping recommendations. Can you explain why the solutions given in the dupe target don't work in your case? – Dmitry Grigoryev Sep 14 at 17:18

So there is a lot here to figure out. Assuming everything on your board will run on one regulated voltage, there are several options.

Simple diodes can do a lot of what you're asking. Coupled with a linear regulator, and accounting for some loss, this could be the easiest solution. Your battery voltage could be a problem, as if it is lower than 5V, the priority wouldn't be correct. This EE stack exchange answer and this one provide some diagrams of simple 2 source solutions, but more sources can be added in the same way.

More complicated solutions are possible using resistor and diode networks to switch a series of mosfets. Another EE stack exchange answer provides some examples.

There are also IC's for this (As for most things). Look for "PowerPath" or "ORing controller" ICs. A few dollars will buy you an incredibly capable product like LTC4090-3, which will handle 12V in, USB, and battery, while controlling a buck circuit and charging your battery for you as well. It will need another regulator, and will output a max of 5V, but it produces exactly the priority switching control you require.

This overview by Analog would be good for some IC based ideas, and has several circuit topologies as well as part selection tables.