I'm working on a mini UPS for my router (12V, 1A) and modem (5V, 2.5A). I've been checking out lots of DIY UPS tutorials and stumbled upon this one. It seems to do everything I need: it's got a battery with a charging and discharging setup, provides two different voltages, and switches between AC and DC when the power goes out and back on. In the circuit diagram they've shared, there are four diodes in the middle, and I'm not sure why they're connected that way. I'm also thinking about swapping out the p-MOS for a relay. It would stay on most of the time when the power's on and turn off during an outage. Will this make the switching faster or slower? I want to make sure the router and modem don't flicker off when the power switches, so speed is important to me.

enter image description here

  • 1
    \$\begingroup\$ Just a comment, please don't build that. There is no proper lithium battery charging circuit, at most that looks like a CC/CV module sold to hobbyists on shady e-commerce sites. It will not stop charging the batteries when they are full, keeping them at float charge, which will degrade and damage them. The BMS can't protect from that. \$\endgroup\$
    – Justme
    Commented Mar 19 at 10:22
  • 1
    \$\begingroup\$ And "damage them" actually means "could cause a fire". There's been a spate of fires caused by incorrect or badly designed e-bike chargers so don't add to the statistics. You'll also invalidate any household insurance by making this yourself. \$\endgroup\$
    – Finbarr
    Commented Mar 19 at 11:01
  • \$\begingroup\$ @Justme, the BMS is meant to halt battery charging once they're fully charged. Is there a different BMS module or alternative that focuses solely on protecting the batteries to prevent fire hazards, like Finbarr mentioned? I'm not looking to splurge on an expensive UPS; I just need a basic and straightforward one for my router and modem. \$\endgroup\$
    – M-125
    Commented Mar 19 at 14:41
  • 1
    \$\begingroup\$ @M-125 And that is the problem. BMS is a last line of safety when charger has failed to do it's job properly, and that's not a proper charger to begin with. That's like not having brakes in your car because you are relying on airbag, or not bothering to take the main parachute because you are relying on the emergency parachute. What you need as a proper solution, is a proper lithium battery charger instead of CV/CC regulator. Anything with lithium batteries is not basic and straightforward, they may explode and start a fire when not used properly. \$\endgroup\$
    – Justme
    Commented Mar 19 at 15:32
  • \$\begingroup\$ I understand your concern, and I'm aware of the risks associated with lithium batteries. However, this circuit has been tested by the designer and others who have built it, so it likely works with some level of safety. What we're looking for is to improve the safety of this design. Is that something we can do, or will it be challenging to achieve? \$\endgroup\$
    – M-125
    Commented Mar 19 at 16:47

1 Answer 1


Let's first give designators to the diodes:

enter image description here

Short answer: Diodes are there to block current to the input in case of a power outage, also they work as "POWER OR" to ensure correct current flow path from/to the battery and the converter modules.

When the main input is present the MODULE-1 (DC-DC converter module to the top-left) will be on and its output will be applied to the BMS through D2. So the battery pack will be charged from the output of the MODULE-1. Also, the main input will be applied to the Buck Converter and Buck-Boost converter modules through D1. The diodes D3 and D4 as well as the Q2 MOSFET's body diode (assuming SW1 is closed) block the current to the BMS from the main input so that it gets supplied from the MODULE-1 only (NOTE: The pink connection from the main input to Q2's gate ensures the off-state of Q2, apparently).

When the main input is not present the batteries will start to discharge so the pack voltage will appear across the nodes to the right of the fuse, namely A and B (encircled section). If the switch SW1 is closed the PMOS Q2 will see negative gate-source voltage so it'll turn on and the battery voltage will be applied to the buck and buck-boost modules through D3 and D4, respectively.

D2 prevents the current flow from the battery to the output of the MODULE-1. Likewise, D1 prevents the current flow from the battery to the main input.

I'm also thinking about swapping out the p-MOS for a relay. It would stay on most of the time when the power's on and turn off during an outage. Will this make the switching faster or slower?

Probably not. The commutation time for ordinary relays are generally in the range of a few to a few tens of milliseconds. If you think (or believe) that the capacitors in the system will store sufficient energy to supply the rest of the system during that time then go for it. Let's have a look:

Initial assumptions:

  • You'll use a 12V relay with a switching time of 5 milliseconds, and a release voltage of 8V. And the coil does not draw any current.
  • You use the relay's NO (normally closed) contacts in place of the MOSFET Q2, and the relay will be energised from the main input directly. Thus, when the main input is present the relay will be energised so the connection between SW1 and D4's anode will be "open".
  • The buck and buck-boost modules' avg efficiencies are 85%.
  • The loads draw the maximum currents (i.e. 2.5A from 5V and 1A from 12V). Therefore, for a presumably 85% of initial efficiency for both buck and buck-boost modules, the current drawn from the 12V input can be assumed as ~1.9 Amps (23 W).
  • The 1000u capacitor at the input is charged up to 12V (72 mJ).

In case of a power outage:

  • Within the first ~1.5 ms the capacitor will lose almost half its energy so the voltage will drop to 8V. Then the relay will start to release (Note that we assumed an avg release time of 5 milliseconds).
  • The remaining energy (32 mJ) will supply the rest of the system for about 1~1.3 millisecond then the capacitor will be almost empty.
  • The system will probably stop until the relay completes switching (2~3 milliseconds). Then it'll restart.

Note that the MODULE-1 DC-DC converter and the BMS are kept out of equation. If they are included then the holdup time will be even less.

So you'll need an input capacitor of at least 8 to 10 times to provide enough holdup time if you want to replace the Q2 with a mechanical relay.

  • \$\begingroup\$ Thank you for clarifying. Just to confirm, are you asking about the current consumption? I have the specifications for all the components. The router uses a maximum of 1A, and the modem uses a maximum of 2.5A. The total drained current from either the power supply or the batteries should not exceed 5A. \$\endgroup\$
    – M-125
    Commented Mar 19 at 9:44
  • \$\begingroup\$ @M-125 sorry, I missed the first sentence in your question. I'm updating my answer. \$\endgroup\$ Commented Mar 19 at 10:52
  • \$\begingroup\$ Got it. I could swap out C2 and C3 with a 10,000uF (10mF) capacitor. Do I also need to change C1? The main concern with the new capacitors is the inrush current. Can I just replace the old capacitors with the new ones without making any other changes, or will there be a safety issue in the circuit? \$\endgroup\$
    – M-125
    Commented Mar 19 at 14:35
  • \$\begingroup\$ @M-125 The whole circuit is a safety issue. \$\endgroup\$
    – Justme
    Commented Mar 19 at 15:59
  • \$\begingroup\$ @M-125 C2 and C3 will not make a significant contribution to holdup. They will discharge to the loads straight away. The point of holdup is to maintain constant output(s) or in other words, to keep the DC-DC modules running. C1 is the main energy source for all, so it should be increased. What I meant by "capacitors in the system" was the capacitors at the inputs (C1, and the input capacitors of each module). So, increasing C1 on its own should be sufficient. As for your question regarding safety, to be honest I didn't check the design for safety-critical issues or concerns. There are some ... \$\endgroup\$ Commented Mar 19 at 19:44

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.