So I tried to build a little constant current/constant voltage supply to charge a lithium battery. Individually, the CC and CV sections work as expected. Originally I used an Arduino to read the voltage and switch to CC or CV, but I wanted to try to do the same thing with a voltage comparator.
So I'm using one comparator to switch the CC section in, and another set up as inverting to switch CV mode. For some reason the comparators both output the same voltage, and never go above 0V.
I've got diodes in there because I got negative voltage leaking from collector to base, and because sometimes the opamp would output negative voltages while the transistor was on. I'm using an LM358 opamp and an LM339 comparator.
I'm sure I've done something terribly wrong, but please don't throw things, I just came up with this off the top of my head!