2
\$\begingroup\$

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")

enter image description here

EDIT 2: New screenshot (with irrelevant circuitry / components removed)

enter image description here

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ If you are using a pull-up and the circuit is still not behaving correctly then the problem is your circuit, not the open collector output. I suggest revisiting your schematic (posting here might be helpful) and figure out why it's not working \$\endgroup\$ – DerStrom8 Feb 13 '17 at 11:53
  • \$\begingroup\$ Do you have a resistor in series with the base of your NPN transistor? \$\endgroup\$ – RoyC Feb 13 '17 at 11:57
  • \$\begingroup\$ This question is likely to get closed as a request for a recommendation for a particular product. You could possibly reword it as a request for help with your wider problem. \$\endgroup\$ – RoyC Feb 13 '17 at 12:09
  • \$\begingroup\$ @RoyC: I hadn't any base resistors, but I added them. I also rewrote the post to avoid deletion. Thanks. \$\endgroup\$ – bos Feb 13 '17 at 12:20
  • 1
    \$\begingroup\$ @DerStrom8 Symptoms of chronic insomnia I suppose. \$\endgroup\$ – Asmyldof Feb 13 '17 at 14:19
5
\$\begingroup\$

The part of your circuit to drive Q2 from the output of U1A looks OK, although there is no need for R10. The current thru the base will already be limited by R8. R10 will only slow down the transitions.

I didn't look up the LM393, but make sure that the open collector output is really with respect to the negative supply, which is ground in your case. Otherwise, Q2 won't be reliably turned off, or at all.

If the output of U1A really isn't going high, first check that the supply pins are at the expected voltages. You don't show what voltage VM is. Check the datasheet and make sure this is high enough for the LM393 to operate properly.

Then check the input pins. Maybe the bug is in not driving them to a state that should make the output high.

\$\endgroup\$
3
\$\begingroup\$

If the output of the 393 is "on" (not pulled to ground through the internal transistor) and you're measuring the voltage directly on the output, then you're just measuring the output of a voltage divider made up of R8 and R10. The output voltage would be (VM-0.7)*(1k/(3k+1k)) = 1.075 volts assuming VM=5V. The 0.7 volt drop comes from the base-emitter junction of the NPN, which is effectively just a diode.

\$\endgroup\$
1
\$\begingroup\$

You can only expect about 1V on the output. Your base resistor is 1k and the transistor appears to the op amp as a diode to the negative rail. Increase your base resistors to about 47k on Q2 and Q3.

You may want to take a look at the other resistor values in your circuit. 1k to pull off a mosfet gate is at least 10 times to small.

\$\endgroup\$
1
\$\begingroup\$

The LM393 is functionally a comparator by design. It is configured as an open-collector device since its typical use is as a switch. You may find it easier to analyse the operation of your circuit if you consider it in that sense rather than as a (general-purpose) op-amp.

So rather than thinking of the 393 in combination with the pull-up resistor as forming an op-amp, think of the 393 as a (open-collector NPN) switch which can pull down the base of Q2 to turn it off by removing the drive current being supplied to it by R8.

If connecting R7 to the "output" - being pin 1 of the LM393 - causes the output to stay low then you probably have a wiring fault, or other circuit conditions are not as you describe/expect.

(As an aside, while it doesn't achieve your specified goal to "drive a NPN-transistor from the LM393-output", you may also like to consider how you might use the LM393 without Q2, which you may find to be an interesting exercise, too.)

\$\endgroup\$
  • \$\begingroup\$ Re the last paragraph; that was my first task. Obviously, I didn't succeed :-) \$\endgroup\$ – bos Feb 13 '17 at 18:25
0
\$\begingroup\$

around 1V on the output when opamp is "high". It's supposed to be 5V, but isn't.

1v is about right on the opamps output, because it got pulled down by the 1k and B-E junction of the NPN.

\$\endgroup\$
0
\$\begingroup\$

Not sure what your supply voltage is, but... The common-mode input range for the 393 is 0 to supply minus 2 volts. If both inputs are above this range, the output goes low. Try adjusting R9 and/or R6 so that the voltage on the inverting input (with Q3 off) is at least 2V below the supply voltage. It's a good idea to always have one input within the common-mode range.

The circuit might be latching as power is coming up. You can try adding circuitry to ensure that it initializes to the correct state after power-on.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.