I'm trying to learn how to use opamps as a comparator. uA741 was easy, but it's way too slow for an uncoming lab I'm going to do, so I switched it to LM393 instead which is rail-to-rail and very fast.
Problem: LM393 is open-collector, and I have been pulling my hair for two hours now and can't get it to work. I follow datasheet guidelines (3k pull-up), but everything connected to the output (NPN-transistor, etc) does NOT behave as there is a "1" coming on that signal.
So for now I give up open-collector, I will re-try this another day when I got more time.
What I'm trying to achieve is to drive a NPN-transistor from the LM393-output. Using 3k pull-up, I measure around 1V on the output when opamp is "high". It's supposed to be 5V, but isn't.
That's why the next step won't work either: as soon as the opamp has gone high, I'm trying to latch the output high by sending the output to another NPN which pulls in- to GND. in+ can only be 5V or 1V (never GND) so the output will always be high.
But I can't get it to work because of the open collector confusing me. I get it to work out-of-the-box with a non-open-collector (like uA741).
EDIT: See schematic. I added R10 as per the comments suggesting this. Q2 does now open, but the opamp-output is around 2V (why not 5?). If I raise R10 to 10k, opamp-output is ~5V which is expected, but I think 10k is a bit too high for the NPN-base, isn't it?
If I connect the feedback-resistor R7 to the output, the output slams down to GND no matter what the output is supposed to be. The purpose of R7 + Q3 is to latch in- to GND, so the opamp-output is permanently high until powered off.
I am probably making multiple errors here. I'm trying to learn, so please bear with me.
(Side-question: Which common opamp / comparator, without open-collector output, is a good replacement for LM393? "Common", as in "Go into RadioShack to buy")
EDIT 2: New screenshot (with irrelevant circuitry / components removed)
This shows how the circuit works without the latch. The red line is the voltage supposed to be strangled permanently after the first hi-to-low-transition, i.e. the first time opamp goes low. The green line is the opamp output: High at first (correct), then low when triggered (correct), but then it goes high again, and this is incorrect. It's supposed to stay low here on.
I've added a temporary Q3 to the circuit. In theory, this should bring the in- to ground, making in+ higher at all times. But, because the opamp starts high, it means Q3 will bring in- to ground immediately, which I do not want.
I don't know if I can use Q3 like this, but I'm just trying to show a point here, how I'm thinking.
Instead of Q3, I have also tried to add another LM393 (there's two in the IC), trying to make the feedback go through it instead of Q3, but the results are roughly the same.
How can I solve this? That is, latch the opamp in low / "off" state as soon as one first transition has been done.