I have a project running with MCU supplied with a 24V power supply regulated via an SMPS to 9V also, I have Li-ion battery pack 9V

how to connector these two sources to run the MCU with battery pack when the power failure occurs?


what is the best way to switch from battery to power supply and power supply to battery?

  • \$\begingroup\$ We have something similar in our project. I don't know if this is right, but it can give you an idea. We have our control unit connected to both power sources. When the cable splits, eache part has a reverse polarity protection with a diode to prevent voltage compensation when one voltage drops. Our CU then draws current from the source with the most voltage. So if the main battery is disabled, it automatically switches to the backup. \$\endgroup\$ – birdfreeyahoo Apr 3 '19 at 20:09
  • 1
    \$\begingroup\$ The solution @birdfreeyahoo describes is called ORing diode solution. (This diode conducts OR that diode conducts). With low supply currents you can use diodes or schottky diodes (without dissipating too much power). Search internet for "ORing diodes" to find other ORing solutions. \$\endgroup\$ – Huisman Apr 3 '19 at 21:39
  • \$\begingroup\$ will DIODE OR make both power source to supply power to the circuit same time? \$\endgroup\$ – komto909 Apr 4 '19 at 14:11

Diodes are a very simple option if you've got the voltage headroom.

Another good reference design is the arduino power selection circuit:

arduino power selection circuit

The P channel mosfet on the USB VIN prevents back powering of the usb line, and also doesn't introduce a diode voltage drop.

One thing you'll need to check for safety is the leakage from the 24v supply into the battery. Most semi-conductors like diodes leak a little bit in the uA range. If you're not careful the battery could be overcharged by this and potentially burst into flames!

There are old-school options you could also consider. For example, use a spdt relay with a coil connected to your power supply. Connect COM to the MCU, NO to the power supply, and NC to the battery. You'll need a large cap or something to supply power for a few ms while the relay switches.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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