6
\$\begingroup\$

I am designing a circuit, which can use either 5V from USB, or some higher voltage (7-12V) from a battery. If both power sources are connected at the same time, I want some kind of electrical switch, that would disconnect the battery and power the circuit just from the 5V USB. But the circuit still has to work, when only one of the sources is present. I tried to design a switch using two mosfets, but I was not able to figure out a working circuit.

Can such a circuit be build by only using two mosfets? Also, do not worry about the voltage regulation, that is taken care of.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ The easiest way is to just use a diode from each source, they will select the higher source automatically. \$\endgroup\$
    – Ian Bland
    Nov 25, 2016 at 15:50
  • 1
    \$\begingroup\$ @IanBland but that doesn't fulfill the "if possible, use the USB (which is lower)" \$\endgroup\$ Nov 25, 2016 at 16:13
  • 1
    \$\begingroup\$ Are you OK with having control ICs in your solution, or do you want something using only jellybean parts? Also, do you have any preferences regarding device packages? (i.e. no SMD, only coarse pitch, only gull wing, no through hole, or anything-goes) \$\endgroup\$ Nov 25, 2016 at 16:27
  • \$\begingroup\$ I would like to suggest an IC: TPS212x for that job, in case someone needs a recommendation. \$\endgroup\$ Oct 21 at 11:35

3 Answers 3

6
\$\begingroup\$

There are dedicated chips that you can get which will do this but doing it with discrete parts would look something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

All part numbers are the defaults rather than recommended parts.

Without the USB disconnected R1 ensures M3 is off. R5 turns M2 off and R2 turns M1 on. The end result is that the output is connected to the battery.

With USB powered M3 turns on. This pulls the gate of M2 down turning it on which in turn pulls the gate of M1 high and turns it off. Power then flows through D1 (which should be a schottky diode) and to the output.

D1 also protects the USB from over voltage while the voltage on C1 drops to USB levels. Note, if the battery is under the USB voltage then the body diode of M1 will feed power into the battery. This is outside of your stated operating range but if it is a possibility add a diode to prevent it.

C1 should be sufficiently large to prevent the output voltage dipping too far during switch over.

And now I wait for everyone else to point out the problems with this circuit (or point out how to do it with half the parts) since I'm sure I've overlooked something...

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Thank you, this is exactly what I need. By the way, what kind of chip would work for this application? \$\endgroup\$
    – Dan
    Nov 25, 2016 at 16:46
  • 1
    \$\begingroup\$ I know, this is an old thread, but I look for something like this and I see a problem here, may be someone comments on this. Is it true, that if USB power is connected and supplies the load, the paralell resistors (M2+M3 are on) drain the battery at the same time? \$\endgroup\$ Sep 10, 2017 at 0:46
  • 1
    \$\begingroup\$ If the USB power is on M3 is on which pulls the gate of M2 low and turns it off. So yes, R5 is draining the battery when on USB power but not R2. However this represents a draw of less than 1mA. If that is an issue you can use a larger value resistor. \$\endgroup\$
    – Andrew
    Sep 11, 2017 at 7:55
8
\$\begingroup\$

The simplest way that I can think of uses 3 parts. A CPC1117N, a resistor and a diode (eg. 1N5819).

schematic

simulate this circuit – Schematic created using CircuitLab

Operation should be self-evident- the presence of the +5V USB source turns off the 9V battery source and D2 prevents back-feeding the USB +5.

This circuit has no provisions against brown-out in the USB+5 input (for example, a 3V input could switch off the battery and leave only 2.5V at the output). If you need that, add a power supervisor chip to switch the SSR. An LM431 and two resistors would work too.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Great circuit, though limited supply current at 150 mA. I'd suggest that you can get lower VF diodes to replace the 1N5819 ....try SB1245 or an SMD SS1P3L. You could also put a 3v27 zener such as the DDZ3V3ASF-7 in series with R1 which would switch out at about 4.5 V on the USB. \$\endgroup\$ Nov 25, 2016 at 19:32
  • \$\begingroup\$ Newbie here, is it OK to connect batteries negative pole with USB GND? If not, then how should I close the load circuit if the GND is differs between power supplies? \$\endgroup\$
    – pbn
    Dec 13, 2018 at 21:59
  • \$\begingroup\$ @pbn Yes, the battery negative side is connected to ground, which is connected to USB ground. \$\endgroup\$ Dec 13, 2018 at 22:05
1
\$\begingroup\$

That's the job of power monitors.

You can either buy a ready-made circuit that is pretty clever about that, for example the LTC4412, which will ensure low switchover transients etc.

Or you can actually build this yourself, as you said, from MOSFETs. In principle, yes, one or two might suffice, if you got a few diodes to spare to ensure a few voltage drops and avoid current flowing into the USB port.

schematic

simulate this circuit – Schematic created using CircuitLab

Downside of this is clearly that operation from battery wastes energy by letting voltage drop over D2 – but that's necessary to ensure that M3's V_GS is always positive when V_G = V_Bat, even when there's a high voltage drop across the load.

You can build a more elegant version of this circuit essentially by employing the CMOS ideology – but you'd be, logically, building nothing different than two logic circuits: one that conducts power from the battery if (not USB voltage ), and one that conducts power from USB if (USB voltage).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.