Electronic – how to switch to backup battery when power fail

backupbatteriespowerswitch-mode-power-supply

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?

or

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

Best Answer

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.