5

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.

Dan
  • 63
  • 1
  • 1
  • 6
  • 1
    The easiest way is to just use a diode from each source, they will select the higher source automatically. – Ian Bland Nov 25 '16 at 15:50
  • 1
    @IanBland but that doesn't fulfill the "if possible, use the USB (which is lower)" – Marcus Müller Nov 25 '16 at 16:13
  • 1
    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) – ThreePhaseEel Nov 25 '16 at 16:27

3 Answers3

7

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.

Spehro Pefhany
  • 376,485
  • 21
  • 320
  • 842
  • 1
    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. – Jack Creasey Nov 25 '16 at 19:32
  • 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? – pbn Dec 13 '18 at 21:59
  • @pbn Yes, the battery negative side is connected to ground, which is connected to USB ground. – Spehro Pefhany Dec 13 '18 at 22:05
5

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...

Andrew
  • 6,872
  • 19
  • 25
  • Thank you, this is exactly what I need. By the way, what kind of chip would work for this application? – Dan Nov 25 '16 at 16:46
  • 1
    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? – Artur Cichosz Sep 10 '17 at 00:46
  • 1
    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. – Andrew Sep 11 '17 at 07:55
1

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).

Marcus Müller
  • 88,280
  • 5
  • 131
  • 237