I'm currently designing device which will be powered from external PSU but also will have backup power system from battery. I'm trying to solve my problem. When external power source is down (5V - USB), I'm switching to battery source. Battery powers my 3,3V power line through LDO regulator. At the same time boost converter turns on and powers my 5V bus. I have problem that external 5V source (USB) is connected directly to my main 5V bus, same as my boost converter. Where is problem? Charging circuit is also powered from 5V bus (USB), that means battery will charge itself, it'll drain quickly. enter image description here

I want to note that only one source will work at the same time, there are additional switching circuits which will take care of it. There is no possibility that boost converter will be working when external source is connected.

enter image description here

I came with such idea like on picture above. However I'm bit suspicious, will it work? N-channel mosfet is "inverted" and I'm unsure how it will behave in real life scenario. I tried it with simple simulation and it somehow work, but it's just simulation... Any advices are welcome. I'd like to keep it simple as possible. If 5V bus wouldn't be critical, I'd probably just use diode, but I need to keep it as close 5V as possible at this stage of design.

Falstad:* (n-channel) (p-channel) *when top source is 5V, right source is 0 and vice versa

Also piece of main schematic I'm working on enter image description here

I was also thinking about doing same thing with NPN transistor, but I'm unsure because of power losses and current ratings (this part of bus consumes up to 200-250mA),

In tl;dr I want to avoid powering a piece of power bus, isolate it.

  • \$\begingroup\$ The way you have that mosfet, it's either always on, always off, or conducting backward, but you haven't achieved useful control. one option is cut off power to the boost converter if power is present on the 5V line in, and use a diode to stop the boost converter from energising that line. A mosfet set up as an ideal diode instead of a real one if the load on the 5V bus out is significant. \$\endgroup\$
    – K H
    Feb 4, 2021 at 10:35
  • \$\begingroup\$ Current design makes converter state dependent form +5 V USB voltage, that's also why I need separation. As I mentioned, I was thinking about using diode (simplest solution) but such voltage drop is unacceptable for me with current stage of design. Mosfet as ideal diode sounds interesting, never heard of it. Will do some research on it. \$\endgroup\$
    – LMatt
    Feb 4, 2021 at 10:42

1 Answer 1


Edit: After some thought, I have decided that I do not like the solution below for the following reason.

Under the assumption that the circuit acts ideally as a diode, and under the assumption that the battery boost circuit outputs exactly 5V, there still seems to be a 50-50 chance that the external supply is greater than the battery boost 5V vs being below the battery boost 5V.

That means that some times, the load will draw current from battery, and some times from the external supply.

Although the load will work when the power is drawn from the battery, the battery will be drained, and if the external supply should become unavailable, the drained battery will be of no use.

What I personally would like from a circuit that may use either a battery or external supply for power is

  1. if the external supply is available, it is used to power the load, even if it provides a lower voltage than the boosted battery voltage.

  2. if the external supply is available, and has excess capacity after powering the load, it will additionally charge the battery with this excess capacity.

  3. if the external supply is available, but it does not have the capacity to supply both the load and charge the battery at the same time, then it will supply the load rather than charge the battery.

These may not be the same objectives as you, but they seem reasonable to me.

The down side of these objectives is that I cannot think of a circuit that achieves them with the same efficiency as an "ideal diode". The best I can think of involves a loss of power between the external supply and the load, possibly in the 5-20% range (80-95% efficiency). If my load does not require the amount of current that my external supply is capable of providing, I wouldn't mind that loss. However, if my load could only barely run with a standard usb supply, I might not be happy with such a loss.

I may offer an alternative that assumes that a 20% power loss from external supply to load is acceptable.

Original: Try this (partial) circuit to isolate the power going into the charger, battery, and boost converter from the +5V rail.

(The switch is there to simulate that the external power supply might be disconnected. It is not needed in your circuit).


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ Is it necessary to have matched pair of PNP's in such scenario? I did some research and noticed that most solutions base on matched pairs. Is it mostly about current mirror and uneven currents? \$\endgroup\$
    – LMatt
    Feb 4, 2021 at 22:00
  • \$\begingroup\$ you can get a set of matched pairs of 2N3906's in a single package. However, in this case, the voltage on the drain side of M1 will either be 5V or Vout-Vds, and I think (could be wrong) that Vds will increase in the latter case, even if the transistors are not perfectly matched. \$\endgroup\$ Feb 4, 2021 at 22:46
  • \$\begingroup\$ Also, I guess I should ask if this is for a one-off project or for a production run. If the latter, the latter, there is a possibility that two random 2N3906s will be unsuitable, and you would need to test each circuit prior to sale to avoid returns and unhappy customers. If just a one off project, I think the chances of the circuit working with off the shelf components is good, but you may have bad luck. I haven't played around with it, but there is room for improving the circuit by a) changing the resistance values, and b) adding precision resistors at the emitters. \$\endgroup\$ Feb 4, 2021 at 23:00
  • \$\begingroup\$ Thanks a lot. For my luck it's only one unit. I'm not in rush so will probably do some tests before running final version to avoid unwanted problems. I can see that there are dedicated ideal diode mosfet driver IC's, will also consider them in my design. \$\endgroup\$
    – LMatt
    Feb 5, 2021 at 6:46
  • \$\begingroup\$ @LMatt I have added a comment explaining that I am not happy with this solution. May offer another solution. \$\endgroup\$ Feb 7, 2021 at 15:04

Your Answer

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

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