Hook a 1 kΩ load to a simple voltage divider built from two 10 kΩ resistors on 5 V, and the 2.5 V it was meant to produce collapses to 0.42 V. Put one op-amp between the divider and the load, wired as a buffer, and the output holds at 2.500 V. An op-amp is a small chip with two inputs and one output, and the same part can buffer a signal, amplify it, or compare two voltages. It does the first two jobs very well and the third one badly enough that a separate chip exists for it. The figures below come from ngspice simulations using a simple op-amp model with properties close to the common LM358: gain of 100,000, about 1 MHz bandwidth, a slew rate of 0.3 V per microsecond, and an output that can’t reach the top 1.5 V of a 5 V supply.
What an op-amp does on its own
A huge amplifier of a difference
An op-amp has a non-inverting input (+), an inverting input (−), and an output. On its own, with nothing connected back from output to input, it multiplies the difference between its two inputs by an enormous number, tens or hundreds of thousands. A difference of one millivolt is enough to slam the output to one end of its range.
That raw behavior is almost never used directly. Op-amps become useful when part of the output is fed back to the inverting input, which lets resistors, not the chip’s wild internal gain, set what the circuit does.
Negative feedback settles the inputs
The All About Circuits textbook page on negative feedback describes what happens when the output is connected back to the inverting input: the circuit settles where the difference between the inputs is nearly zero, a self-stabilizing system. That gives two working rules for any op-amp circuit with negative feedback:
- The output moves to whatever voltage makes the two inputs equal.
- Almost no current flows into either input.
Nearly every op-amp circuit can be worked out from those two lines.

The buffer: copying a voltage without loading it
The circuit
Connect the output straight to the inverting input and feed the signal into the non-inverting input. All About Circuits calls this a voltage follower: the output follows the input with a gain of 1, with high input impedance, low output impedance and high current gain. Its job is to repeat a voltage while taking almost nothing from the source.
The test
Two identical dividers, each two 10 kΩ resistors across 5 V, should each produce 2.5 V. The simulation hung a 1 kΩ load on each, one directly and one through a buffer:
| Divider output | Voltage |
|---|---|
| With 1 kΩ load connected directly | 0.417 V |
| Unloaded | 2.500 V |
| Through an op-amp buffer, into 1 kΩ | 2.49997 V |
The 1 kΩ load sat in parallel with the bottom 10 kΩ resistor and pulled the divider far off its intended value. Through the buffer, the divider saw only the op-amp’s input, which draws almost nothing, and the 2.5 mA the load needed came from the op-amp’s supply instead.
Where buffers earn their place
All About Circuits describes followers as voltage buffers that boost the current-sourcing ability of signals too weak to drive a load directly. A sensor divider feeding a long cable, a reference voltage shared by several circuits, or a high-impedance source feeding a microcontroller’s analog input are all classic places for one.
The non-inverting amplifier: gain from two resistors
The formula
Put a resistor divider in the feedback path, so the inverting input sees only a fraction of the output. The All About Circuits page on divided feedback gives the gain of this non-inverting amplifier as (R2 / R1) + 1, where R2 runs from output to the inverting input and R1 from the inverting input to ground. The output has the same polarity as the input, and the gain can’t drop below 1; with R2 at zero ohms, the circuit becomes a follower again.
The test
With R2 at 100 kΩ and R1 at 10 kΩ, the gain should be 11. A 0.1 V input produced 1.0999 V at the output. The tiny shortfall comes from the op-amp’s finite internal gain, which the page notes barely matters as long as it is very high. Swap the resistors for 1% parts and the gain is set to 1% accuracy, regardless of how much the chip’s own gain varies from one unit to the next.
The ceiling
The output can’t go anywhere the chip can’t reach. The LM358 datasheet from Texas Instruments lists an output that swings to about 1.5 V below the positive supply with a 2 kΩ load on 5 V, and an input range that runs from the negative supply up to 1.5 V below the positive one at room temperature. On a 5 V supply, a gain-of-11 amplifier with that chip tops out around 3.5 V, so any input above about 0.32 V clips. “Rail-to-rail” op-amps exist to remove that limit, and they are the usual choice for 3.3 V and 5 V microcontroller projects.

Using an op-amp as a comparator
The idea
With no feedback at all, an op-amp’s output slams high when the + input is above the − input and low when it is below. That is exactly what a comparator does, so an op-amp with a reference on one input and a signal on the other looks like a free comparator.
What the simulation showed
A 10 kHz sine wave swinging 0.5 V either side of a 2.5 V reference went into the model op-amp and into an ideal comparator. The ideal one switched the instant the signal crossed 2.5 V. The op-amp’s output took about 6.8 microseconds to reach its midpoint after the crossing, and its rising edge took 8.3 microseconds to climb from 0.5 V to 3.0 V. That rise matches the slew rate: the LM358 datasheet gives 0.3 V per microsecond, so 2.5 V takes around 8 microseconds.
At 10 kHz, a delay of several microseconds is a noticeable fraction of every cycle. A dedicated comparator switches in nanoseconds to a few microseconds depending on the part, and its output stage is designed for logic levels: many comparators have open-drain outputs that need a pull-up resistor, which also makes them easy to connect to a microcontroller running at a different voltage.
Why op-amps are slow at it
An op-amp is designed to stay in its linear region under feedback, and most are deliberately slowed internally so feedback circuits stay stable. Driving one to its limits with no feedback, then asking it to swing to the other side, works against that design. For slow signals, such as a thermostat or a light sensor checked once a second, an op-amp comparator is fine. For anything with edges that matter, the chip built for the job does better.
Hysteresis: stopping the chatter
The problem
A slowly changing signal with a little noise on it crosses a threshold many times as it drifts past. The Analog Devices tutorial MT-083 on comparators describes it: noise can cause the output to toggle between levels many times, especially when a slow signal is compared with a DC reference, and hysteresis generally helps.
Counting the transitions
A simple numerical model ramped an input from 2.4 V to 2.6 V over 10,000 steps, added 10 mV of random noise to each step, and counted how often a comparator with a 2.5 V threshold changed its mind. The noise model is a simplification (real noise depends on bandwidth), but the pattern is clear:
| Comparator | Output transitions during one slow crossing |
|---|---|
| No hysteresis | 557 |
| 20 mV hysteresis | 117 |
| 50 mV hysteresis | 1 |
Without hysteresis, the output chattered hundreds of times during what should have been one switch. A microcontroller counting those edges as button presses or heater cycles would misbehave badly.
How hysteresis is added
Hysteresis splits the threshold into two: the output switches high at a slightly higher voltage than the one where it switches back low. The usual way is a large resistor from the output back to the non-inverting input, so the output’s own state nudges the threshold. In a common non-inverting arrangement, the width of the window is roughly the output swing times the ratio of the input resistor to the feedback resistor; a 5 V swing with 10 kΩ and 1 MΩ gives about 50 mV. Texas Instruments publishes worked designs for exactly this, including its circuit note on comparators with and without hysteresis (SBOA219). The window needs to be wider than the noise and narrower than the accuracy the application cares about.

Choosing the right part
Quick guide
- Buffering a voltage or driving a load from a weak source: op-amp follower.
- Amplifying a small sensor signal: op-amp non-inverting amplifier, with a rail-to-rail part on low-voltage supplies.
- Turning an analog level into a clean digital on/off: a comparator chip, with hysteresis if the signal is slow or noisy.
- A slow threshold check where a spare op-amp is already on the board: an op-amp comparator is acceptable, with hysteresis added the same way.
Common mistakes
The datasheet limits catch more designs than the theory does. An input pushed above the common-mode range, an output expected to reach the supply rail, or a single-supply circuit with a signal that dips below ground will each give results the two golden rules don’t predict. Reading the input range, output swing and slew rate figures before choosing a part takes five minutes.
The op-amp’s reputation as a universal building block is earned. It just isn’t universal in the way its symbol suggests. A triangle with two inputs and one output can mean a precision amplifier or a sluggish switch, and the difference is printed in a table on page five of the datasheet.
Sources
- Negative Feedback, All About Circuits: https://www.allaboutcircuits.com/textbook/semiconductors/chpt-8/negative-feedback/
- Divided Feedback, All About Circuits: https://www.allaboutcircuits.com/textbook/semiconductors/chpt-8/divided-feedback/
- LM358 datasheet, Texas Instruments: https://www.ti.com/lit/ds/symlink/lm358.pdf
- MT-083 Comparators, Analog Devices: https://www.analog.com/media/en/training-seminars/tutorials/MT-083.pdf
