basics of opamp as comparator, Vout not going to VCC when Vinput>Vref

Thread Starter

ashokraj

Joined Feb 1, 2018
151
I am trying to understand a basic comparator circuit using OPAMP. In the below circuit I have connected a reference voltage of 2.5V to inverting terminal, to a non inverterting terminal have connected input voltage varying from 0~3V. My understanding is :
1. when the voltage of VG1/VF1 crosses 2.5 output of opamp should go high until that point the voltage should be 0 but in my circuit below that is not happening, voltage is always 1V even though VG1 is less than 2.5V! what could be reason for this ?
2. when VF1 >2.5V, the output voltage should be equal to VCC/5V but it is reaching to 4V only, what could be the reason for this?
Any suggestions please?

1737819457180.png
1737819429636.png
 

ronsimpson

Joined Oct 7, 2019
4,647
Many op-amps cannot pull their output to the supply voltage(s).
"OPAMP" dose not tell me much. A real part "LM321" has a data sheet where we can find what happens. A generic part in SPICE, I do not know how it works. The 0 to 4V output is not a surprise.
 

DC_Kid

Joined Feb 25, 2008
1,242
See post #2. They rarely get to supply voltage.

I would also modify the ckt to have a load on the output, like a 10k or something, then read the Vout.

Can you malke J1 6v and see what happens?
 

crutschow

Joined Mar 14, 2008
38,322
Apparently the op amp model you are using only goes to within 1V of the supply rails (here 5V and ground).
That's generally typical of op amps that aren't rail-rail types.
Look at the model parameters of the op amp.
 

DickCappels

Joined Aug 21, 2008
10,661
There is a reason that they make comparators. Op-amps have a capacitor in the circuit that limits how fast it can respond, and they tend to make relatively poor comparators. Best to use a comparator for this and leave op-amps for linear uses. No kidding...
 

crutschow

Joined Mar 14, 2008
38,322
There is a reason that they make comparators. Op-amps have a capacitor in the circuit that limits how fast it can respond, and they tend to make relatively poor comparators. Best to use a comparator for this and leave op-amps for linear uses. No kidding...
Depends.
Many commonly used IC comparators (such as the LM339 have an open collector output, which requires a pullup resistor to generate an output signal.
That feature can be good or bad depending on the application.

Op amps have a push-pull output that can either source or sink current to a load.
But you need a rail-rail op amp if you want the output to go between ground and the power rail.
Single supply op amps, such as the LM324, have an output that goes from near ground to within about 1.5V of the supply voltage
So if comparator speed is not of the essence, then an op amp used as a comparator could be better, especially if a spare op amp is already available in the circuit for such use.

Otherwise I wouldn't necessarily say that they "tend to make relatively poor comparators".

Conversely, I have used comparators as op amps, when a comparator was already available in the circuit.
A comparator can stably operate as a closed-loop op amp with proper feedback compensation (albeit generally with a low closed-loop frequency response).
 

MisterBill2

Joined Jan 23, 2018
27,186
The fact that for a few applications an op-amp can function in a manner sort of similar to a comparator is no reason to expect that it will be close in another application.

If the TS wants to understand the operation of a comparator, use a comparator.

Further, the output DOES go "high", but not to the supply voltage, and the output DOES go "low", but not to the supply common voltage.

That might work for some applications, but as several have stated, "an op-amp will not serve as a GOOD comparator".
Adequate for some applications, useless for some other applications.
 
Last edited:

Ian0

Joined Aug 7, 2020
13,097
Some op-amps won't work at all as comparators. An example is the NE5534, because it has back-to-back diodes between the inputs. This is a common configuration in many op-amps, especially those intended for audio.
There are plenty of comparators with push-pull outputs, TLV3702 for example.
 

Thread Starter

ashokraj

Joined Feb 1, 2018
151
hi ash,
What type of OPA are you using?
E
in TINA I have used a general purpose OPAMP, even if i change the opamp to industry standard what ever is available in the below list its response remained "similar" i.e., i dont have control over vout high and low voltage levels. I would like to understand the reason for this theoretical vs practical disparity that would be help me find an appropriate compartor/opamp for a future projects. 1737884597059.png
 

Thread Starter

ashokraj

Joined Feb 1, 2018
151
Apparently the op amp model you are using only goes to within 1V of the supply rails (here 5V and ground).
That's generally typical of op amps that aren't rail-rail types.
Look at the model parameters of the op amp.
how can i control the 1V? what is the spec/parameters that i will have to focus to opt to make it 0 when Vin<Vref and to VCC when Vin>Vref
 

DickCappels

Joined Aug 21, 2008
10,661
An external pull-up resistor on the output should get you closer the V+ power supply voltage.

What do you plan to drive with the output?
 

Thread Starter

ashokraj

Joined Feb 1, 2018
151
I have understood the reason by going through the following link and few suggestions from above:
link
I have simulated opamp & comparator circuit at the same time, got the satisfactorily results. Thanks everyone.
1737893271664.png
1737893413477.png
 

ronsimpson

Joined Oct 7, 2019
4,647
Here are the internal workings of a LM358. Pulling up on the output are Q6 and Q5. Each transistor needs 0.7V from B-E to turn on. The 100uA current source cannot pull up to V+. It needs 0.3V to work. (0.7+0.7_0.3= 1.7V) This amp probably cannot pull up more than Supply-(1.7 to 2V). (depends on load and temperature)

On the pull-down side A13 needs 0.7V and Q12 0.3V. (if there is a load more than 50uA)
If the load is very small a 50uA current source pulls down to 0.3V.
1737902191524.png
 

MisterBill2

Joined Jan 23, 2018
27,186
Going back to post #1: " I am trying to understand a basic comparator circuit using OP-AMP. ", we see that the selected op-amp serves rather poorly as a snappy comparator. And that is exactly what I would expect. It would drive a CMOS gate running on 15 volts rather well, though.
 
Top