Ugenz Academy/IoT Tutorial

Comparators

9 min read1,612 words

Reading progress

Keep learning

Comparators

1. What Is a Comparator?

A comparator is an electronic circuit that compares two input voltages and produces an output indicating which voltage is higher.

Comparators are commonly used in sensor circuits, automatic lighting systems, battery voltage monitoring, temperature control, and electronic switching circuits.

A comparator has three main functional connections:

  • Non-inverting input (+): Receives one of the voltages being compared.
  • Inverting input (−): Receives the other voltage, often a reference voltage.
  • Output: Changes state according to the relationship between the two input voltages.

LM393 Dual Comparator IC DIP-8 - synthCube

synthcube.com

For example, a comparator can compare a light sensor's voltage with a reference voltage to determine whether the surrounding area is bright or dark.

2. Working Principle of a Comparator

A comparator compares the voltage at its two inputs.

Its basic operation is:

  • If V_+>V_−V\_+>V\_-, the output goes toward its high state.
  • If V_+\<V_−V\_+\<V\_-, the output goes toward its low state.

Here, V_+V\_+ is the non-inverting input voltage, and V_−V\_- is the inverting input voltage.

Was Komparatoren leisten und wo sie eingesetzt werden

all-electronics.de

Unlike a typical linear amplifier circuit, a comparator is generally designed to switch between output states rather than produce a continuously amplified version of the input difference.

Example

Suppose the reference voltage is 3 V.

Sensor voltageReference voltageComparator output tendency
1 V3 VLow
2 V3 VLow
3.5 V3 VHigh
4.5 V3 VHigh

This table assumes the sensor is connected to the non-inverting input and the reference is connected to the inverting input.

The actual output voltage levels depend on the comparator's power supply and output design.

3. Comparator Circuit Diagram

A basic comparator circuit can be constructed using a comparator IC such as the LM393.

LM2903-N: Figure Error in the Datasheet - Amplifiers forum - Amplifiers - TI E2E support forums

e2e.ti.com

In a typical circuit:

  1. A sensor provides the input voltage.
  2. A reference voltage sets the switching threshold.
  3. The comparator compares the two voltages.
  4. The output changes state when the sensor voltage crosses the threshold.

The LM393 has an open-collector output, so an appropriate pull-up resistor is normally required. Its output does not independently drive itself high.

4. Types of Comparators

Comparators are commonly classified according to their input arrangement and switching behavior.

A. Non-Inverting Comparator

In a non-inverting comparator, the signal being measured is connected to the non-inverting input, while the reference voltage is connected to the inverting input.

What is comparator | Electronics Forums

electronics-lab.com

Its operation is:

  • When V_in>V_refV\_{in}>V\_{ref}, the output tends toward its high state.
  • When V_in\<V_refV\_{in}\<V\_{ref}, the output tends toward its low state.

Example: A light sensor voltage increases as the light intensity increases. The comparator can switch an output when the voltage rises above a selected threshold.

B. Inverting Comparator

In an inverting comparator, the input signal is connected to the inverting input, and the reference voltage is connected to the non-inverting input.

Op Amp vs Comparator Explained: Differences, Working Principles, and Applications

ic-components.com

Its operation is:

  • When V_in\<V_refV\_{in}\<V\_{ref}, the output tends toward its high state.
  • When V_in>V_refV\_{in}>V\_{ref}, the output tends toward its low state.

The output behavior is opposite to that of a non-inverting comparator with the same input and reference voltages.

5. What Is a Reference Voltage?

A reference voltage is a known voltage against which another voltage is compared.

It establishes the point at which the comparator changes its output state.

For example, if a circuit must detect when a battery voltage falls below 3.3 V, a suitable 3.3 V reference can be applied to one comparator input.

When the battery voltage crosses the threshold, the comparator changes its output state.

A reference voltage can be produced using:

  • A voltage divider made from resistors.
  • A voltage reference IC.
  • A Zener diode circuit.
  • An adjustable potentiometer circuit.

Voltage Divider | Free SVG

freesvg.org

For a simple unloaded voltage divider:

V_ref=V_inR2R1+R2V\_{ref}=V\_{in}\frac{R_2}{R_1+R_2}

Where:

  • V_inV\_{in} = Supply voltage.
  • R1R_1 = Upper resistor.
  • R2R_2 = Lower resistor.
  • V_refV\_{ref} = Voltage at the midpoint.

Example: A 5 V supply is connected to a divider containing a 10 kΩ upper resistor and a 10 kΩ lower resistor.

V_ref=51010+10V\_{ref}=5\frac{10}{10+10} V_ref=2.5 V\boxed{V\_{ref}=2.5\text{ V}}

This calculation assumes the comparator input draws negligible current and the reference node is not significantly loaded.

6. Comparator Output Types

Comparator ICs can have different output designs.

A. Push-Pull Output

A push-pull output actively drives the output both high and low.

Advantages:

  • Can actively produce both output states.
  • Often does not require an external pull-up resistor.
  • Can provide relatively fast switching.

The output voltage range and load-driving ability still depend on the device specifications.

B. Open-Collector Output

An open-collector comparator output can pull the output low but cannot independently drive it high.

An external pull-up resistor connects the output to a suitable positive supply.

operational amplifier - Comparator, inverting/non-inverting terminal voltage is more than supply voltage - Electrical Engineering Stack Exchange

electronics.stackexchange.com

When the internal output transistor is OFF, the pull-up resistor raises the output voltage. When the transistor turns ON, it pulls the output low.

Open-collector outputs are useful for interfacing circuits with different voltage levels, provided the output ratings and electrical compatibility are respected.

7. Comparator With Hysteresis (Schmitt Trigger)

A comparator can sometimes switch rapidly between high and low states when the input voltage is close to the reference voltage, especially if the signal contains noise.

This behavior can cause unwanted switching.

Hysteresis solves this problem by using positive feedback to establish two different switching thresholds:

  • Upper threshold: The input must rise above this voltage to switch the output in one direction.
  • Lower threshold: The input must fall below this voltage to switch the output back.

onsemi Community

onsemineworg.my.site.com

For example, a circuit could switch ON when a sensor voltage rises above 3.2 V and switch OFF when it falls below 2.8 V.

Between 2.8 V and 3.2 V, the output retains its previous state.

This prevents rapid switching when the input fluctuates near the threshold.

8. Comparator vs. Operational Amplifier

A comparator and an operational amplifier (op-amp) may look similar internally, but they are generally designed for different purposes.

FeatureComparatorOperational Amplifier
Main purposeCompare voltages and switch statesAmplify voltage differences
Typical operationSwitchingLinear amplification with feedback
Output behaviorHigh or low stateVariable output within its operating range
Switching speedDesigned for fast transitionsDepends on the amplifier
Output structureOften open-collector or push-pullDepends on the op-amp design
FeedbackOften used for hysteresisCommonly uses negative feedback
ExamplesLM393, LM311LM358, LM741

An op-amp can sometimes be used as a comparator in suitable applications, but a dedicated comparator is usually preferable for reliable switching because its design and specifications are intended for that purpose.

9. Comparator vs. Rectifier

Although their names sound similar, comparators and rectifiers perform different functions.

FeatureComparatorRectifier
Main functionCompares two voltagesConverts AC into unidirectional current
Common componentsComparator IC or op-amp circuitDiodes or controlled semiconductor devices
OutputSwitching state based on input comparisonPulsating or filtered DC
ExampleBattery voltage detectorBridge rectifier

10. Applications of Comparators

Comparators are used in many electronic systems.

Comparator - Night Light - jpralves.net

Automatic Lighting

Detects whether ambient light is below a selected threshold and switches a light accordingly.

Adjustable Low-Battery Threshold Detector Extends Battery Runtime | Analog Devices

Battery Monitoring

Detects when a battery voltage crosses a low-voltage or high-voltage threshold.

PPT - EMT 212/4 ANALOG ELECTRONIC II CHAPTER 2: OP-AMP APPLICATIONS & FREQUENCY RESPONSE PowerPoint Presentation - ID:5469985

Temperature Control

Compares a temperature-dependent sensor voltage with a reference to control a fan, alarm, or other suitable output.

Modulo Sensor Obstaculo Infravermelho LM393 com Trimpot

Obstacle Detection

Converts a changing sensor signal into a switching output for robotics and automation.

Other applications include zero-crossing detection, waveform generation, overvoltage protection, and analog-to-digital conversion circuits.

11. Important Comparator Parameters

ParameterMeaning
Input offset voltageSmall input difference that may cause a switching error
Propagation delayTime between an input crossing the threshold and the output responding
Input common-mode rangePermitted range of input voltages
Output voltage levelsHigh and low output voltages under specified conditions
Input bias currentSmall current flowing into or out of the input terminals
HysteresisDifference between upper and lower switching thresholds
Supply voltage rangePermitted operating power-supply range

These specifications determine whether a comparator is suitable for a particular sensor, voltage level, and switching speed.

In summary: A comparator compares two input voltages and changes its output state depending on which voltage is higher. Its main applications include sensor detection, automatic switching, battery monitoring, and threshold detection. Hysteresis improves stability when the input voltage is noisy or fluctuates near the switching threshold.

Keep learning. Keep building. Keep growing.

© 2026 Ugenz Academy