Send an Inquiry

To receive a quote for your project, please fill in the following information, and we’ll get back to you promptly.

Name*
Company*
Email Address*
Phone/WhatsApp
Part Number*
Quantity*
Message
Submit Inventory List

Please fill in the following information, and we’ll get back to you promptly.

Name*
Company*
Email Address*
Phone/WhatsApp
Upload My List
Message

Comparator Circuit: Voltage Thresholds, Op-Amp Differences, LM393 and Practical Design

Article Details

A comparator circuit converts the polarity of a voltage difference into one of two output states. When the voltage at the non-inverting input is higher than the voltage at the inverting input, the comparator selects one state. Reversing that relationship selects the other state. The switching decision may involve only a few millivolts, while the output can interface with a microcontroller, logic gate, transistor driver or protection circuit.

The triangle symbol alone does not define the voltage that appears at the output. A push-pull comparator drives both HIGH and LOW. An open-collector or open-drain comparator actively pulls the output LOW and relies on an external pull-up resistor to create the HIGH state. Input common-mode limits, offset voltage, propagation delay, output topology and power sequencing must therefore be checked alongside the nominal threshold.

Basic decision rule: for a conventional comparator, V+ > V selects the HIGH output state, while V+ < V selects the LOW state. With an open-collector device such as an LM393-class comparator, "HIGH" means that the output transistor is off and the external pull-up establishes the output voltage.

How a Voltage Comparator Circuit Works

A voltage comparator has a non-inverting input, an inverting input and an output. Its open-loop voltage gain is high, so a small differential input drives the output toward one of its two defined states. The circuit is normally used as a decision element rather than as a linear amplifier.

Input condition Comparator decision Push-pull output Open-collector output
V+ > V Positive input is higher Actively driven HIGH Output transistor off; pull-up produces HIGH
V+ < V Negative input is higher Actively driven LOW Output transistor on; output is pulled LOW
V+ ≈ V Near the switching threshold Offset, noise and hysteresis determine the actual transition

The ideal comparison changes state at zero differential voltage. A real device has input offset voltage, input bias current, noise and finite gain. If the nominal reference is 2.000 V, the actual switching point will be displaced by the comparator's offset and by errors in the reference network. A stable production design uses guaranteed limits at the required supply voltage and temperature rather than a typical offset value measured on one sample.

Non-inverting and inverting voltage comparator circuits showing VIN, VREF and the correct output polarity for each configuration
Figure 1. Non-inverting and inverting comparator connections. The selected input determines whether the output rises or falls when VIN crosses VREF.

Non-Inverting and Inverting Comparator Circuits

Non-inverting comparator

In a non-inverting comparator circuit, VIN connects to the positive input and VREF connects to the negative input. The output selects HIGH when VIN rises above VREF. It selects LOW when VIN falls below VREF.

VIN > VREF → output HIGH
VIN < VREF → output LOW

This polarity suits overvoltage indicators, light-level detectors, temperature alarms and power-good signals that should become active when a measured voltage exceeds a boundary.

Inverting comparator

In an inverting comparator circuit, VIN connects to the negative input and VREF connects to the positive input. The output selects LOW when VIN rises above the reference and returns HIGH when the input falls below it.

VIN > VREF → output LOW
VIN < VREF → output HIGH

This arrangement is useful when an active-LOW fault, shutdown or interrupt signal is required. The electrical output may already be active LOW when an open-collector comparator is used, allowing several fault outputs to share a wired logic node if the data sheets permit it.

Setting the Comparator Threshold with a Voltage Divider

A two-resistor divider can derive VREF from a regulated supply. With RTOP connected from VS to the reference node and RBOTTOM connected from the reference node to ground:

VREF = VS × RBOTTOM / (RTOP + RBOTTOM)

For a 5 V source, RTOP = 30 kΩ and RBOTTOM = 20 kΩ produce a nominal 2 V reference. The divider current is 100 µA, and the Thévenin resistance seen by the comparator input is 12 kΩ.

The Aetrix Voltage Divider Calculator can be used to check the reference voltage and resistor ratio. Final values still need an error calculation that includes source tolerance, resistor tolerance, input offset voltage, input bias current, leakage and temperature.

The input-bias contribution can be estimated from the divider's Thévenin resistance:

Approximate bias-current error = IB × (RTOP ∥ RBOTTOM)

Large resistor values reduce divider current but increase sensitivity to input bias current, PCB contamination, coupled noise and parasitic capacitance. Very small values waste power and may load the reference source. The acceptable range depends on the comparator, required accuracy, response time and operating environment.

A threshold calculated from nominal resistor values is not yet a guaranteed trip point. Use the worst-case comparator offset, divider tolerance and reference tolerance to determine the minimum and maximum switching voltages.

Comparator Input Limits That Affect the Decision

The voltage on each input must remain inside the valid input common-mode range. This requirement is separate from the absolute maximum rating. A pin can remain undamaged while operating outside the common-mode range, yet the output state may be incorrect or unspecified.

Specification What it controls Design check
Input common-mode range Input voltage range over which comparison behavior is specified Check both inputs at minimum and maximum supply voltage, including startup and fault conditions
Differential input range Allowed voltage difference between the two inputs Check normal operation and large transient differences
Absolute maximum input voltage Damage boundary Do not use it as a normal operating limit
Input offset voltage Displacement of the actual switching point Include the guaranteed maximum and its temperature range in the threshold budget
Input bias current Error developed across source resistance Calculate the error using the resistance seen by each input
Input overdrive Voltage beyond the switching point Use the data-sheet test condition when comparing propagation-delay values

Many LM393-family comparators accept input voltages down to ground on a single supply but do not provide a rail-to-rail input range up to the positive supply. Newer comparators may offer rail-to-rail inputs, wider common-mode operation or fault-tolerant pins. The exact manufacturer, revision and orderable suffix must be checked; a familiar part number does not make every vendor version electrically identical.

Open-Collector, Open-Drain and Push-Pull Outputs

Open-collector and open-drain outputs

An open-collector comparator contains an output transistor that sinks current. It cannot source the HIGH state. An external resistor connects the output node to a permitted pull-up voltage.

When the transistor is off, the resistor pulls the output HIGH. When it is on, current flows through the resistor and the comparator pulls the output LOW. The pull-up value must satisfy the LOW-state sink-current limit, HIGH-state leakage requirement and required rise time.

ISINK = (VPU − VOL) / RPU

For a 3.3 V pull-up, a 4.7 kΩ resistor and an assumed 0.2 V LOW output, the comparator sinks approximately 0.66 mA. The calculated current must be compared with the guaranteed VOL specification at the intended temperature.

The rising edge is created by the pull-up resistor charging the total output capacitance. A useful first-order estimate for the 10% to 90% rise time is:

tR ≈ 2.2 × RPU × CLOAD

With 4.7 kΩ and 100 pF, the estimated rise time is about 1.03 µs. Reducing the resistor accelerates the rising edge but increases LOW-state current. The falling edge is actively produced by the output transistor and is often much faster, so an open-collector output can have visibly asymmetric edges.

Push-pull outputs

A push-pull comparator actively sources and sinks current. It does not require a pull-up resistor for ordinary logic operation, although its HIGH and LOW output voltages still depend on load current and supply voltage. Push-pull outputs are useful when fast, balanced edges are required and the receiving logic operates from a compatible voltage domain.

Output type HIGH-state source Main advantage Main design concern
Open collector External pull-up resistor Flexible pull-up voltage and wired logic capability Pull-up current, leakage and RC rise time
Open drain External pull-up resistor CMOS implementation with similar external behavior Output voltage rating and rise time
Push-pull Internal upper transistor Actively driven HIGH and LOW states Voltage-domain compatibility and output contention

LM393 Comparator Circuit Example

The LM393 is a dual voltage comparator with open-collector outputs. A common circuit powers the comparator from 5 V, applies a sensor voltage to IN+, places a 2 V reference on IN− and pulls the output up to a 3.3 V microcontroller rail.

When the sensor voltage exceeds the reference, the output transistor turns off and the 3.3 V pull-up produces a logic HIGH. When the sensor voltage falls below the reference, the transistor turns on and pulls the node LOW.

Connection Example Required verification
Comparator supply 5 V Supply range, local decoupling and startup behavior
IN+ Sensor voltage Common-mode range, source impedance and possible transients
IN− 2 V reference Divider tolerance, source accuracy, noise and input-bias error
Output pull-up 4.7 kΩ to 3.3 V Output-pin voltage rating, sink current, leakage, rise time and power-off state
Receiving input 3.3 V MCU GPIO VIH, VIL, leakage and maximum input-voltage rating
LM393 open-collector comparator powered from 5 V with a 2 V reference and a 3.3 V pull-up connected to a microcontroller input
Figure 2. Representative LM393 circuit with a 5 V comparator supply and a separately verified 3.3 V output pull-up.

A separate pull-up supply can simplify logic interfacing, but it is not automatic level translation. The comparator's output rating, receiver thresholds, leakage and unpowered behavior must all permit the connection. The broader threshold and stress checks are covered in the 3.3 V to 5 V Logic Level Shifter Guide.

Representative LM393 pin functions

Pin Function Engineering note
1 OUT1 Open-collector output for comparator 1
2 IN1− Inverting input for comparator 1
3 IN1+ Non-inverting input for comparator 1
4 GND Negative supply or ground in single-supply operation
5 IN2+ Non-inverting input for comparator 2
6 IN2− Inverting input for comparator 2
7 OUT2 Open-collector output for comparator 2
8 VCC Positive supply

This eight-pin arrangement is widely used, but the package drawing and pin assignment must be confirmed for the exact orderable part. Similar comparator names do not guarantee the same pinout, grade, supply range or power-off behavior.

Comparator vs Op Amp

An op amp and a comparator may use the same triangular symbol, but their intended operating conditions differ. A comparator is designed to operate open-loop and move between two output states. An operational amplifier is normally designed for linear closed-loop operation.

Design point Comparator Operational amplifier
Normal operating mode Open-loop voltage comparison Linear operation with negative feedback
Output behavior Logic-like transition; open-collector, open-drain or push-pull options Analog output intended to settle at a commanded voltage
Large differential input Expected during normal operation, within rated limits May be limited or produce undocumented behavior
Saturation recovery Designed for repeated switching between states Some devices recover slowly after deep saturation
Logic compatibility Often specified for logic interfacing Output swing may not meet receiver thresholds
Propagation specification Usually specified using defined input overdrive and output loading Slew rate and settling specifications may not predict comparator behavior
Hysteresis May be integrated or added with positive feedback Possible externally, but open-loop suitability still requires verification

An op amp can function as a slow comparator in selected circuits when its differential-input range, common-mode range, output swing, saturation recovery and phase behavior have been checked. Substituting an available op amp without those checks can create delayed transitions, excessive supply current, phase reversal or a logic HIGH that never reaches the receiver's guaranteed threshold.

The linear behavior and feedback configurations of operational amplifiers are covered separately in the Operational Amplifier Guide.

Adding Hysteresis to Prevent Output Chatter

A slowly changing or noisy input can cross one threshold repeatedly. Without hysteresis, millivolts of noise may produce multiple output transitions. Positive feedback creates two switching thresholds: an upper threshold for one input direction and a lower threshold for the opposite direction.

The difference between these thresholds is the hysteresis width:

ΔVT = VT+ − VT−

The hysteresis window should exceed the expected noise near the decision level while preserving the required measurement accuracy. Loaded output levels must be used in the threshold calculation. For an open-collector comparator, the HIGH feedback voltage depends on the pull-up supply, resistor, leakage and connected load.

Detailed inverting and non-inverting threshold equations are available in the Schmitt Trigger and Hysteresis Guide.

A capacitor may reduce high-frequency noise, but filtering alone does not create two switching thresholds. Hysteresis establishes a defined state-retention region around the decision point.

Propagation Delay, Overdrive and Output Rise Time

Comparator speed cannot be judged from one headline propagation-delay number. The specified delay is measured with stated supply voltage, input overdrive, output load, pull-up resistance and threshold points. Changing those conditions changes the observed timing.

Input overdrive is the amount by which the differential input exceeds the switching point. Small overdrive can increase decision time. Large overdrive may improve response but must stay inside the allowed differential-input range.

For open-collector devices, two delays contribute to a LOW-to-HIGH output transition:

  1. The internal comparator and output transistor must respond to the input crossing.
  2. The external pull-up resistor must charge the output capacitance to the receiver's HIGH threshold.

The receiving circuit does not wait for the output to reach 100% of the pull-up voltage. It changes state when the waveform crosses its own VIH or VIL boundary. Logic compatibility should therefore use guaranteed thresholds and loaded output limits, as described in the TTL vs CMOS Logic Levels Guide.

Window Comparator Circuit

A window comparator uses two thresholds to determine whether VIN is inside or outside a permitted voltage range. One comparator detects the lower boundary and the other detects the upper boundary.

With a dual open-collector device, the two outputs can be configured so both output transistors are off only while the input remains between VLOW and VHIGH. A shared pull-up then produces a HIGH "inside window" signal. If either boundary is violated, the corresponding transistor pulls the combined output LOW.

Inside window: VLOW < VIN < VHIGH

This topology is used for supply monitoring, battery limits, sensor validation and analog fault detection. The two reference tolerances, both comparator offsets and any hysteresis must be included when calculating the guaranteed acceptance window.

Window comparator circuit using two open-collector comparators to detect whether VIN remains between lower and upper voltage thresholds
Figure 3. A window comparator verifies that an input remains between independent lower and upper limits.

Zero-Crossing Comparator Circuits

A zero-crossing comparator uses 0 V as its nominal reference and changes state when an AC waveform changes polarity. The name does not remove the comparator's input limits. A single-supply device whose input cannot move below ground requires level shifting, attenuation or input protection before it can monitor a bipolar signal.

Near zero volts, signal noise can produce several transitions during one crossing. A small hysteresis window prevents chatter, although it moves the rising and falling switching points away from exactly 0 V. The acceptable shift depends on the timing accuracy required by the application.

Power-Up, Power-Down and Unused Inputs

A comparator may receive an input or output pull-up voltage before its own supply becomes valid. The data sheet must explicitly permit that condition. Protection structures can otherwise conduct current into an unpowered device, disturb the monitored rail or create an undefined output.

Unused comparator inputs should not float. Configure the unused channel for a stable, defined output state using input voltages that remain inside the valid common-mode range. Tying both inputs together does not guarantee a quiet state because input offset and noise can select either output condition.

A 100 nF ceramic decoupling capacitor placed close to the supply pins is a practical starting point for many general-purpose comparators. Fast devices may require additional local capacitance, controlled ground return paths and tighter layout than an LM393-class circuit.

Comparator Selection Parameters

Parameter Why it affects the circuit What to verify
Supply-voltage range Defines permitted operating rails Minimum, maximum, startup and transient supply conditions
Input common-mode range Limits valid input voltages Both inputs across every operating state
Input offset voltage Creates threshold error Guaranteed maximum over temperature
Input bias current Produces error across source resistance Worst-case current and resistor-network impedance
Propagation delay Sets response time Input overdrive, output direction and test load
Output topology Determines pull-up and logic-interface requirements Open collector, open drain or push-pull
Output voltage and current Determines valid logic levels VOL, VOH, sink/source current and leakage
Internal hysteresis Controls noise immunity and switching points Minimum and maximum hysteresis, not only typical value
Quiescent current Affects standby power Maximum current across voltage and temperature
Temperature and qualification Defines environmental suitability Operating grade, package, AEC-Q100 or other required qualification

Common Comparator Circuit Problems

Observed symptom Likely cause Measurement or correction
Output remains LOW Missing pull-up, reversed inputs, overloaded output or invalid common-mode voltage Measure the output with the load removed, confirm pull-up voltage and check both inputs at the IC pins
Output never reaches logic HIGH Pull-up resistance too large, excessive leakage or incompatible voltage domain Calculate the HIGH-state voltage using worst-case leakage and compare it with VIH(min)
Repeated transitions near the threshold Noise, slow input edge, inadequate hysteresis or poor grounding Observe input and output simultaneously; add calculated hysteresis and improve layout
Unexpectedly slow rising edge Open-collector pull-up and load capacitance form a large RC time constant Measure output capacitance, reduce RPU within sink-current limits or select push-pull output
Trip voltage differs between boards Offset, reference tolerance, resistor tolerance, leakage or contamination Build a worst-case threshold budget and measure the reference directly at the input pin
Incorrect state during startup Supply sequencing, undefined reference or pull-up active before comparator supply Capture all supply, input and output rails from power application through steady state
Op-amp replacement switches slowly Deep saturation or unsuitable open-loop behavior Review differential-input and saturation-recovery behavior or use a specified comparator

Comparator Circuit Design Checklist

  • Define whether the output should assert when VIN is above or below the reference.
  • Confirm the input polarity before assigning logic labels.
  • Calculate the nominal threshold and its worst-case error range.
  • Keep both inputs inside the guaranteed common-mode range.
  • Check differential-input and absolute maximum limits during faults.
  • Identify whether the output is open collector, open drain or push-pull.
  • For an open output, calculate pull-up current, leakage margin and RC rise time.
  • Compare output limits with the receiving circuit's VIH and VIL.
  • Add enough hysteresis for the expected noise and input slew rate.
  • Check propagation delay using the applicable input-overdrive condition.
  • Verify startup, shutdown and partial-power-down behavior.
  • Bias unused comparator channels to defined, valid input states.
  • Place decoupling close to the IC and keep threshold nodes away from switching traces.
  • Validate the final circuit across supply, temperature, source tolerance and production component limits.

A comparator circuit is reliable when its threshold is treated as an error range, its output stage is treated as part of the signal path and every input remains inside the device's specified operating region. Bench testing should cover the minimum and maximum expected input slew rate, noise, load capacitance, supply sequence and temperature rather than a single room-temperature transition.

Frequently Asked Questions

What is a comparator circuit?

A comparator circuit compares the voltages at its non-inverting and inverting inputs and selects one of two output states according to which input is higher.

When does a comparator output go HIGH?

A conventional comparator selects its HIGH state when V+ is greater than V. A push-pull device actively drives HIGH. An open-collector or open-drain device turns off its output transistor so an external pull-up can produce the HIGH voltage.

Can an op amp be used as a comparator?

Some op amps can be used as slow comparators after their common-mode range, differential-input limit, saturation recovery, output swing and logic compatibility have been verified. A dedicated comparator is normally more predictable for repeated open-loop switching.

Why does an LM393 need a pull-up resistor?

The LM393 has open-collector outputs. Its output transistor can sink current and create a LOW state, but it cannot source the HIGH state. The external pull-up resistor creates the HIGH voltage when the transistor is off.

Can an LM393 powered from 5 V be pulled up to 3.3 V?

This is possible when the exact LM393 version permits the output voltage, the receiving input accepts 3.3 V logic, and power-off leakage and sequencing are valid. The connection must be checked against both devices' guaranteed specifications.

What causes comparator output chatter?

Noise or a slow-moving input can cross a single threshold repeatedly. Positive feedback adds hysteresis so the rising and falling transitions occur at different voltages.

How is a comparator pull-up resistor selected?

The resistor must be low enough to meet HIGH-state leakage and rise-time requirements but high enough to keep LOW-state sink current within the comparator's guaranteed VOL condition.

What is a window comparator?

A window comparator uses lower and upper thresholds to indicate whether an input voltage is inside or outside an allowed range. It normally requires two comparator channels.

Why can a comparator give the wrong result near the positive supply?

The input may be outside the comparator's guaranteed common-mode range even though it remains below the absolute maximum rating. A rail-to-rail-input comparator or a scaled input may be required.

Technical References

Search

Search

PRODUCT

PRODUCT

PHONE

PHONE

USER

USER