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.
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.
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.
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.
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.
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.
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:
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:
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.
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.
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.
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:
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.
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 |
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 |
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.
| 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.
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.
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:
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.
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:
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.
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.
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.
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.
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.
| 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 |
| 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 |
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.