Op Amp comparator

What is an op amp comparator ?

An op-amp comparator is used in electronics to compare two voltage signals or currents and determine which is greater, less, or equal. It is an analog comparator that can take analog voltage as a reference. Typically, it outputs a high voltage level (e.g., VCC) when one input is greater than the other and a low voltage level (e.g., VEE or ground) when the opposite condition is true.

Opamp in open loop configuration

Comparators have a high voltage gain, which means they amplify the small differences between input signals to produce a clear digital (saturated) output. That is why an opamp is a suitable candidate for comparator operation.

Positive comparator

op amp in comparator mode
Fig 1 : Op amp positive comparator

Here’s how a positive op-amp comparator (as shown in the above figure) typically works:

  1. If the voltage at the non-inverting input is greater than the voltage at the inverting input, the output of the comparator goes to its positive supply voltage (often denoted as VCC).
  2. If the voltage at the inverting input is greater than the voltage at the non-inverting input, the output of the comparator goes to its negative supply voltage (often denoted as VEE.
  3. When the input voltages are approximately equal, the output state can be unpredictable, and the comparator may exhibit some hysteresis.

Negative comparator

op amp in negative comparator mode
Fig 2 : Op amp negative comparator

The operation of a negative op-amp comparator is similar to that of a positive comparator, with the key difference being the polarity of the output:

  1. If the voltage at the non-inverting input is greater than the voltage at the inverting input, the output of the negative op-amp comparator goes to its negative supply voltage (often denoted as VEE).
  2. If the voltage at the inverting input is greater than the voltage at the non-inverting input, the output of the negative comparator goes to its positive supply voltage (often denoted as VCC).
  3. When the input voltages are approximately equal, the output state can be unpredictable, and the comparator may exhibit some hysteresis.

Disadvantages of using op amp as comparator

Usually, opamps have a compensation capacitor inside it which limits the slew rate. The purpose of putting the compensation capacitor is to make the step response of the closed loop opamp stable. In comparator mode, the opamp is never used in a closed loop. The compensation capacitor limits the slew rate so it slows down the comparator response. That is why a dedicated comparator is suitable for high-speed operation where the compensation capacitor is not present.

Window comparator

This circuit determines if an analog voltage is within a range of voltage. It utilizes two comparators in parallel (positive and negative comparators) and does something similar to XOR logic.

window comparator using opamp
Fig 3 : Op amp window comparator

We can use op-amps as a comparator, as shown in Fig 3. The upper op-amp gives a high output if the input voltage exceeds Vref2. It turns on the BJT switch and pulls down the output node. The lower op-amp produces a high output when Vin goes below Vref1. It turns on the lower BJT and pulls down the output node. If Vin is between the two reference voltages, then the output of both the opamps is zero. This makes BJT switches open circuits. Since no current is flowing through the resistor, the output is pulled high.

Op amp comparator waveform

positive comparator circuit

In the above figure, an op-amp is configured as a positive comparator. The signal voltage is attached to the non-inverting pin of the opamp (VIP), and the reference voltage is attached to the inverting pin of the opamp (VIM). The supply voltage is +5V and -5V. This means that the output voltage (VOUT) can go to a maximum of +5V and -5V.

op amp comparator waveform

Op amp comparator with hysterisis

The noise in the input signals (vip) leads to numerous transitions at the output (vout), as depicted below. This scenario is undesirable as it may cause multiple transitions at the output for a supposedly single event. The block next to such a comparator will see multiple edges. If an FSM is connected to the output of such a comparator, it will jump many states, resulting in failures.

op amp comparator waveform without hysterisis when noisy input is applied.

The solution to such a problem is to use a comparator with hysteresis. As soon as the first transition happens at the output voltage, the comparator’s trigger voltage (or reference) is changed. If the voltage hits the previous threshold again due to noise or glitch, the output won’t change because the present threshold is different.

op amp comparator with hysterisis

Leave a Reply

Your email address will not be published. Required fields are marked *

Quick Calculators

RC circuit
Time Constant (s) =

Cutoff Frequency (Hz) =

Time Constant (s) =

Cutoff Frequency (Hz) =

Impedance magnitude (Ω) =

Resonant frequency (Hz) =

Topics