ICSwitching between solar panel and batteries

chargerdiodeslm317nimhsolar cell

I would like to charge the NiMH batteries, when there is excess power from the solar power and use the power stored in the batteries, when I need it (to drive a motor and at night). I have the following circuit:

IC1: LM317
IC2: LM7805

circuit

On the right side, there is a uC, which needs to be powered all the time (through day and night) and drives a heavy load (motor cca 2A) for a while once a day.

The problem is, that I am not sure how the circuit will behave when there is power from the solar panel (SOL+ and SOL-), but it might not be enough to drive the motor (which will be connected to the +18 line) – ideally the voltage should drop and the MOSFET Q1 should open, supplying the motor power from the batteries. But I am afraid, that the battery and solar voltages will get to some balanced state, leaving the MOSFET half open and frying it.

What is the common solution to this problem? Would simply changing the MOSFET for a diode solve it better? Also is the diode D2 needed (I put it there to stop the LM317 from trying to source current when powered from batteries).

Thanks a lot for your ansvers!

Best Answer

I have resolved this problem by replacing the Q1 MOSFET with a simple Shottky diode. All is tested and working well.