I'd like someone other than me to take a look at this. It's a switch to disconnect the solar panel from the battery during periods of little or no sun so that the battery won't discharge back through the solar panel. The processor monitors the solar panel voltage and controls the switch.
When the solar panel is lower than the battery voltage Q18 and Q17 are off. I can see a path of battery discharge through C-B of Q17, R21, R19 and R20 but that is negligible (a few uA). When the panel is above the battery, Q18 and Q17 are on allowing the battery to charge.
It's a rather simple circuit like this, but with conditions you don't see every day that can sneak up and bite me on the butt.
* During the day the processor sleeps for 1 minute intervals, waking to measure the panel and battery voltage. If the battery is >4.2v then Q17/18 are turned off and prevented from turning on again until the next day. If the panel is < battery voltage, Q17/18 are turned off until another measurement is made in 1 minute, otherwise Q17/18 are on.
* At night (panel voltage very low, TBT) the processor is active and doing it's thing. Q17/18 are off.
Now here's another unknown: Will I be able to measure battery voltage when Q18 is on, and measure panel voltage when Q18 is off, under both conditions of solar panel voltage higher or lower than battery voltage? (at the "To A/D" point.) I'm going to have to bench test this but if someone sees that it flat out won't work I can skip that and try something else.
Thanks for your brain power.