Skip to content
Tutorials Center
My learning

Topics

Lesson 7 of 57 ยท Digital Foundations

Operational Amplifiers, Comparators and Schmitt Triggers

Learn the ideal op-amp rules, inverting, non-inverting and summing amplifiers, the comparator and Schmitt trigger, and key specs such as CMRR and slew rate, with Python models.

Digital circuits live between two voltage levels, but the world outside them is analog: a microphone, a thermistor, a battery. The bridge between the two worlds is built mostly from one analog component, the operational amplifier (op-amp). It turns tiny sensor voltages into usable ones, compares a voltage with a threshold to make a clean 0 or 1, and forms the heart of the data converters in Digital versus Analog.

This lesson covers the ideal op-amp, the handful of circuits you will meet again and again, and the specifications that separate a textbook op-amp from a real one.

What an op-amp is

An op-amp is an amplifier with two inputs and one output. The non-inverting input (+) and the inverting input (-) are compared, and the output is a very large multiple of the difference:

Text
Vout = A_open x (V+ - V-)         with A_open around 100,000 or more

Because the gain is so large, the output cannot rise above the supply: it saturates at roughly +Vsupply or -Vsupply. Two operating modes follow.

  • With negative feedback (part of the output fed back to the - input), the circuit settles where V+ = V-. The gain is then set by the resistors around the op-amp, not by the op-amp itself.
  • Without feedback (open loop), any tiny difference pushes the output to a rail. The op-amp becomes a comparator.

The ideal op-amp is a useful mental model with three rules:

  1. The input draws no current (infinite input impedance).
  2. The output can drive any load without its voltage dropping (zero output impedance).
  3. With negative feedback, V+ = V- (the "virtual short").

The basic amplifier circuits

Circuit Gain Notes
Inverting amplifier -Rf / Rin Output is flipped in sign.
Non-inverting amplifier 1 + Rf / Rg Never less than 1. Same sign as input.
Voltage follower (buffer) 1 Output pin tied to the - input. Isolates a source from a load.
Summing amplifier Vout = -Rf (V1/R1 + V2/R2 + ...) Adds weighted inputs. The basis of a simple DAC.
Difference amplifier (R2/R1)(V2 - V1) Amplifies the difference and rejects what is common.
Integrator / differentiator Capacitor in feedback / input Output is the integral / derivative of the input.

Derivation of the inverting case: the + input is at ground, so by the virtual short the - input is also at 0 V. The input current is Vin / Rin, and since no current enters the op-amp it all flows through Rf, so Vout = -Rf x Vin / Rin.

Python Closed-loop gains, with saturation

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The last two inputs in the first two loops hit the rail: with gain 10 or 11 an input of 1.5 V would need 15 V or more, so the output sticks at 12 V. That is clipping, and it is the first thing to check when an amplifier circuit gives a flat top.

The comparator

With no feedback, the op-amp decides which input is larger:

Text
V+ > V-   ->  output at the positive rail (logic 1)
V+ < V-   ->  output at the negative rail (logic 0)

A comparator is a one-bit analog-to-digital converter. Stack several of them with a resistor ladder that provides evenly spaced reference voltages, and you get a flash ADC: a 3-bit converter needs 7 comparators, whose outputs (a "thermometer code") are turned into binary by a priority encoder, like the ones in Decoders and Encoders.

A slow or noisy input crossing the threshold makes a plain comparator chatter: the output flips back and forth many times. The cure is a Schmitt trigger, a comparator with positive feedback that uses two thresholds: a higher one to switch up and a lower one to switch down. The gap between them is the hysteresis. Schmitt-trigger inputs are used to clean up switch contacts and slowly changing signals before they enter digital logic.

Python Flash ADC and Schmitt trigger

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

An op-amp as a DAC

A digital-to-analog converter can be built from a summing amplifier. Give each input bit a resistor that doubles in value for each less-significant bit (R, 2R, 4R, 8R) and each bit contributes half as much as the one above it. With a feedback resistor R and reference Vref:

Text
Vout = -Vref (b3 + b2/2 + b1/4 + b0/8)

Four bits give 16 evenly spaced output levels. Real converters use the R-2R ladder instead, which needs only two resistor values and matches far better.

Specifications that matter

Real op-amps fall short of the ideal, and datasheets list how. The common ones:

  • Input impedance: huge for FET-input parts (billions of ohms), smaller for bipolar ones. A source with high impedance needs an op-amp with an even higher input impedance, or the input loads it.
  • Output impedance: small, so the output barely drops under load.
  • Input bias current and offset: tiny currents and voltages that appear even with the inputs grounded. They matter when amplifying microvolt signals.
  • CMRR (common-mode rejection ratio): how well the op-amp ignores a voltage that appears on both inputs, such as hum picked up by a long cable. CMRR(dB) = 20 log10(A_diff / A_common). Higher is better, often 80 to 120 dB.
  • SVRR or PSRR (supply voltage rejection ratio): how well the output ignores ripple on the power supply.
  • Slew rate: the maximum rate at which the output voltage can change, in V/microsecond. A fast, large signal gets distorted if it asks for more than the slew rate allows. The highest undistorted sine frequency is f = SR / (2 pi Vpeak).
  • Gain-bandwidth product: gain times usable bandwidth is roughly constant, so a gain of 100 leaves one hundredth of the bandwidth of a gain of 1.

Op-amps are also classified by what they amplify. The usual voltage amplifier turns a voltage difference into a voltage. A transconductance amplifier turns a voltage into a current. A transimpedance amplifier turns a current (for example from a photodiode) into a voltage. A current amplifier turns a current into a current.

Python CMRR and slew-rate numbers

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. An inverting amplifier has Rin = 10 kohm and Rf = 100 kohm. What is its gain?

    The inverting gain is -Rf/Rin = -100k/10k = -10.
  2. 2. What does an op-amp without feedback act as?

    Open loop, any small difference between the inputs drives the output to a supply rail, which is how a comparator behaves.
  3. 3. What is the purpose of the hysteresis in a Schmitt trigger?

    Two different switching thresholds mean small noise around one threshold cannot flip the output repeatedly.
  4. 4. How many comparators does a 3-bit flash ADC need?

    An n-bit flash ADC needs 2^n - 1 comparators, so 7 for 3 bits.
  5. 5. What does CMRR measure?

    Common-mode rejection ratio compares the gain for the differential signal with the gain for a common-mode signal.

Summary

  • An op-amp amplifies the difference of its inputs; with negative feedback the resistors set the gain and V+ = V-.
  • Standard circuits: inverting (-Rf/Rin), non-inverting (1 + Rf/Rg), follower, summing, difference.
  • With no feedback it becomes a comparator, the building block of flash ADCs; a Schmitt trigger adds hysteresis to stop chatter.
  • A summing amplifier with binary-weighted resistors is a simple DAC.
  • Key specifications: input and output impedance, bias current, CMRR, SVRR, slew rate and gain-bandwidth product.

Next: Binary Codes.