Electrical – How to add battery backup power source to a circuit

power supply

I am still a beginner but I already managed to design a circuit around a PSoC 4 device with some peripherals (5V powered sensors, 5V powered mini fan, 5V step-down regulator for the main power supply and 5V step-up regulator for the sensors and fan).
The circuit will be powered with 5V DC main power supply which will be either a wall plug supply or a power bank with minimum 5V voltage but it does not matter I hope.

Now I would like to add a battery backup power in case the main power supply fails or will be removed, just to be able to put the chip in sleep mode and keep the real time clock running, which is provided by the chip.

So far the application description.

Now to ensure that my backup battery lasts a long time and really provides current for the sleep mode only, which will be some uA, I would like to cut it off the circuit in case the main power supply is available.
I woud like to use a N-MOSFET as a low side switch for this, but I am not really sure where to attach this mosfet in my existing circuit.
After some research I came up with the solution in the attached schematic image, and here are my questions:

1) Is this correct that way in general?

2) Do I need the N-mosfet switch at all? I found several statements which state, that the battery won't be used as long as it's voltage is lower than the voltage of the main power supply.

3) I heard in some tutorial about power sources, that it's in general not wise to share a common ground between grounded (my 5V wall plug power supply) and floating power sources. Is this realy a "problem" in my case?

4) Can I switch the possition of D7 and U4 or is it bad when Vout of U4 gets the battery voltage?

enter image description here

Noe: Vgate will be set high by the PSoC 4 device as soon a voltage drop is detected by a voltage comparator, to switch the mosfet on. The power for this critical time, between the main supply failure and switching on the battery backup, will be provided by a 220uF capacitor.

I will appreciate any hints on how to make a simple battery backup for a long battery life time.

Best Answer

The key to these circuits is that you have to find a way for your circuit to turn itself on provided there is no voltage applied from the external power source. Many very basic reverse battery protection circuits (that go beyond a series diode) can actually be used with litte to no modification for this purpose - I would suggest starting there. Take a look at figures 2 and 3 from his application note from TI:

http://www.ti.com/lit/an/slva139/slva139.pdf