Op Amps

Operational amplifier: a high-gain differential amplifier IC. The fundamental building block of analog circuits — amplification, filtering, comparison, and signal conditioning all start here.

Why It Matters

Raw sensor signals are weak, noisy, or at the wrong voltage level. Op amps scale, shift, filter, and buffer signals before they reach an ADC (ADC and DAC). Without them, the analog world cannot talk reliably to digital systems.

How It Works

Ideal Op Amp Rules

Two rules that make analysis simple (real op amps get close enough):

  1. No current flows into the inputs (infinite input impedance, I_in = 0)
  2. V+ = V- when negative feedback is present (virtual short)

If there is no feedback (open loop), the output saturates to one of the supply rails.

Inverting Amplifier

           Rf
    Vin ──[===]──┐
                  |
    Rin           |
    ──[===]──(-)──+──── Vout
              |
             (+)
              |
             GND

Vout = -(Rf / Rin) x Vin

With Rf = 100k and Rin = 10k: gain = -10. A 0.1V input produces -1.0V output (inverted).

Input impedance equals Rin (the virtual ground holds the inverting input near 0V).

Non-Inverting Amplifier

                 Rf
             ┌──[===]──┐
             |          |
    Vin ──(+)           +──── Vout
          (-)──[===]──GND
                Rin

Vout = (1 + Rf / Rin) x Vin

With Rf = 90k and Rin = 10k: gain = 10. Input impedance is very high (the op amp’s own input impedance).

Voltage Follower (Buffer)

Non-inverting with Rf = 0 and Rin = open. Gain = 1.

    Vin ──(+)
          (-)──┐
               +──── Vout = Vin

Use this to isolate a high-impedance source (like a voltage divider) from a low-impedance load. The op amp supplies the current so the source does not have to.

Summing Amplifier

    V1 ──[R1]──┐
    V2 ──[R2]──┤──(-)──┐
    V3 ──[R3]──┘   |   +──── Vout
                   Rf   |
                ──[===]─┘
               (+)
                |
               GND

Vout = -Rf x (V1/R1 + V2/R2 + V3/R3)

If all R values equal R: Vout = -(Rf/R) x (V1 + V2 + V3). Used in audio mixing and DAC circuits.

Integrator and Differentiator

Integrator (replace Rf with capacitor): Vout = -(1/RC) x integral(Vin dt). Converts square wave to triangle wave.

Differentiator (replace Rin with capacitor): Vout = -RC x dVin/dt. Detects edges. Noisy in practice — add a small series resistor to limit high-frequency gain.

Comparator (with Hysteresis — Schmitt Trigger)

No negative feedback. Output slams to rail based on which input is higher.

            R1        R2
    Vin ──(-)    Vout──[===]──┐
          (+)──────────[===]──┤
            |                 |
           Vref              GND

Upper threshold: Vth_h = Vref x (1 + R1/R2) ... depends on topology

Hysteresis prevents chattering when the input signal is noisy near the threshold. The gap between the upper and lower thresholds is set by the resistor ratio. Essential for cleaning up noisy digital signals.

Rail-to-Rail Considerations

Standard op amps cannot swing output to the supply rails — they stop 1-2V short. Rail-to-rail op amps can reach within millivolts of Vcc and GND, critical in low-voltage (3.3V) designs where headroom is tight.

Common Op Amp ICs

PartSupplyNotes
LM3583-32VDual, general purpose, cheap, not rail-to-rail
LM3243-32VQuad, same as LM358 but four in one package
OPA3402.7-5.5VSingle, rail-to-rail, low noise, good for 3.3V
MCP60021.8-6VDual, rail-to-rail, micropower, cheap
TL072+/-15VDual, JFET input, audio favorite, needs dual supply

Calculation Example

# Non-inverting amplifier: amplify 0-0.5V sensor to 0-3.3V for ADC
v_in_max = 0.5
v_out_target = 3.3
gain_needed = v_out_target / v_in_max  # 6.6
 
# Vout = (1 + Rf/Rin) * Vin  ->  Rf/Rin = gain - 1 = 5.6
# Choose Rin = 10k, Rf = 56k (standard value)
rin = 10e3
rf = 56e3
actual_gain = 1 + rf / rin         # 6.6 (exact match with standard values)
actual_vout = actual_gain * v_in_max  # 3.3V
 
# Schmitt trigger thresholds (inverting config with positive feedback)
vcc = 5.0
r1, r2 = 100e3, 10e3
v_thresh_high = vcc * r2 / (r1 + r2)   # 0.45V
v_thresh_low = 0  # simplified, depends on output low voltage
hysteresis = v_thresh_high - v_thresh_low