Automatic Power Selection Circuit
IFF the SECONDARY_SUPPLY battery voltage were less than MAIN, the entire circuit seems to be two diodes.







simulate this circuit &ndash; Schematic created using CircuitLab

So, the extra complexity comes from the battery voltage being higher than MAIN.

So one solution is to lower the battery voltage, or raise the mains voltage.

Alternatively, only control the battery source, and use a diode to protect MAIN.

A comparator could compare the two voltages (MAIN and BATTERY), and when main drops too low, switch on a P-MOSFET, connecting BATTERY to LOAD.

Remove the need for nano-second switch time by using a large capacitor. 100,000µF+ should supply current (5A) long enough to raise the switch time to milliseconds.