A standard circuit diagram of comparator circuitry using a dedicated IC like the LM393 requires three fundamental elements: a voltage divider feeding the non-inverting input, a reference threshold on the inverting input, and a pull-up resistor on the open-collector output. Unlike general-purpose operational amplifiers, comparators are designed to operate in an open-loop configuration, snapping their output to a defined logic state the millisecond the differential input voltage crosses zero.

In this guide, we will dissect the topology of an LM393-based comparator, select real-world component values for a light-sensing application, and walk through the exact breadboard testing sequence. We will also cover the failure modes that occur when components are shorted or opened at the extremes.

The Core Topology: Inside a Standard Comparator Circuit Diagram

To understand the circuit diagram of comparator designs, we must look at the internal topology of the LM393 dual differential comparator. The IC contains two independent comparators, each featuring a high-gain differential input stage and an open-collector NPN output transistor.

Node Labels and Pinout (DIP-8 Package)

  • VCC (Pin 8): Positive supply rail (2V to 36V for single supply).
  • GND (Pin 4): Ground reference.
  • IN+ (Pin 3 for Comparator A): Non-inverting input. When voltage here exceeds IN-, the output transistor turns OFF.
  • IN- (Pin 2 for Comparator A): Inverting input. When voltage here exceeds IN+, the output transistor turns ON (sinks current to GND).
  • OUT (Pin 1 for Comparator A): Open-collector output. Requires an external pull-up resistor to define the HIGH state voltage.

Why This Topology Over the Op-Amp Alternative?

A common beginner mistake is substituting an LM358 or LM741 op-amp in a comparator circuit diagram. While an op-amp can technically compare voltages, the LM393 topology wins for three critical reasons:

  1. No Phase Reversal: If an LM358's input voltage exceeds its common-mode range, the output can unexpectedly flip states (phase reversal). The LM393 is immune to this.
  2. Speed: Op-amps contain an internal compensation capacitor to prevent oscillation in closed-loop feedback, which limits their slew rate (e.g., 0.5V/µs for the LM358). Comparators lack this capacitor, allowing them to switch states in roughly 1.3µs.
  3. Open-Collector Flexibility: The LM393's open-collector output allows you to pull the logic HIGH up to a completely different voltage domain than the IC's VCC, making level-shifting trivial.

Design Walkthrough: Picking Real Component Values

Let us design a practical circuit: a dusk-activated switch that pulls a microcontroller GPIO LOW when ambient light drops below a specific threshold. We will use a 5V logic system.

Component Selection

  • IC: LM393 (Single supply, VCC = 5V, GND = 0V).
  • Sensor Divider (IN+): A standard Cadmium Sulfide (CdS) Photoresistor (LDR) connected from VCC to IN+, and a 10kΩ fixed resistor from IN+ to GND. In bright light, the LDR drops to ~1kΩ, pulling IN+ near 4.5V. In the dark, it rises to ~100kΩ, pulling IN+ near 0.45V.
  • Reference Threshold (IN-): A 10kΩ multi-turn trimpot connected between VCC and GND, with the wiper feeding IN-. This allows precise calibration of the trigger point (e.g., setting IN- to 2.5V).
  • Output Pull-up: A 10kΩ resistor from OUT to the 5V microcontroller VCC. This limits current to 0.5mA when the output sinks LOW, well within the LM393's 16mA maximum sink capability.

Behavior Table: Element Changes and Circuit Response

Understanding how the circuit reacts to component variations is crucial for debugging. Refer to the Analog Devices MT-045 tutorial for deeper mathematical proofs of comparator behavior.

Element Changed Modification Effect on Node Voltages Resulting Output State
LDR (Sensor) Resistance increases (Darkness falls) IN+ voltage drops below IN- threshold Output transistor turns ON; OUT goes LOW (~0.2V)
Trimpot (IN-) Wiper moved toward VCC IN- threshold voltage rises Output stays HIGH longer; triggers only in deeper darkness
Pull-up Resistor Changed from 10kΩ to 1kΩ Increases sink current when OUT is LOW Output LOW voltage drops closer to 0V (sharper logic edge)
VCC Supply Drops from 5.0V to 4.5V Both IN+ and IN- scale down proportionally Trigger point shifts slightly; output HIGH drops to 4.5V

Breadboard Testing and Failure Modes at the Extremes

Before soldering, you must validate the circuit diagram of comparator on a breadboard. Follow this exact sequence to avoid floating nodes and erratic behavior.

Step-by-Step Breadboard Verification

  1. Establish Power Rails: Connect your bench power supply to 5.0V and GND. Verify with a multimeter before inserting the IC.
  2. Seat the LM393: Straddle the center trench. Connect Pin 8 to 5V and Pin 4 to GND. Leave the unused Comparator B pins (5, 6, 7) unconnected, but tie Pin 7 (OUT B) to GND or VCC via a 10kΩ resistor to prevent it from acting as an antenna.
  3. Build the Dividers: Insert the LDR and 10kΩ resistor for IN+. Insert the 10kΩ trimpot for IN-. Do not connect the outputs of these dividers to the IC pins yet.
  4. Verify Thresholds: Power on. Use your multimeter to probe the trimpot wiper. Adjust it to exactly 2.50V. Probe the LDR divider node; cover the LDR with your finger and watch the voltage drop. Once verified, connect these nodes to Pin 3 (IN+) and Pin 2 (IN-).
  5. Install Pull-up and Load: Connect the 10kΩ pull-up resistor from Pin 1 (OUT) to 5V. Connect your oscilloscope probe or multimeter to Pin 1.
  6. Trigger Test: Slowly cover the LDR. The output should snap from 5.0V to ~0.2V sharply. Uncover it; it should snap back to 5.0V.
Callout Tip: If your multimeter reads a voltage between 1.5V and 3.5V on the output pin instead of a clean 0V or 5V, your input voltages are too close together. The comparator is operating in its linear transition region. Separate the IN+ and IN- voltages by at least 20mV to force a hard logic state.

What Breaks at the Extremes (Failure Modes)

Testing the limits of your breadboard build reveals the robustness of the topology:

  • Shorting OUT to VCC: If you accidentally wire the output pin directly to 5V without a pull-up resistor, and the input conditions cause the internal NPN transistor to turn ON, you create a dead short from VCC to GND through the silicon. The IC will overheat and fail catastrophically within seconds.
  • Open Pull-up Resistor: If the pull-up is removed or breaks, the open-collector output floats when the transistor is OFF. A microcontroller reading this pin will see erratic noise, phantom interrupts, and unstable logic levels.
  • Input Voltage Exceeding VCC: If a sensor spike drives IN+ above VCC + 0.3V, you forward-bias the internal ESD protection diodes. This causes parasitic latch-up, drawing massive current from the VCC rail and potentially destroying the IC.
  • Shorting IN+ to IN-: The output will become highly unstable, oscillating at high frequencies due to thermal noise and the IC's high open-loop gain. This will not damage the IC but will cause excessive power consumption and noise on the supply rail.

Frequently Asked Questions About Comparator Circuits

Why does a standard circuit diagram of comparator require a pull-up resistor on the output?

The LM393 features an open-collector output topology. Internally, the output pin is simply the collector of an NPN transistor whose emitter is tied to ground. The IC has no internal mechanism to source current or drive the pin HIGH. When the transistor is OFF, the pin is effectively disconnected (high impedance). The external pull-up resistor provides the necessary current path to pull the voltage up to your desired logic HIGH level (e.g., 3.3V or 5V) when the transistor is not sinking it to ground.

How do I add hysteresis to a circuit diagram of comparator to prevent oscillation?

When the input signal changes slowly (like a temperature sensor or LDR), noise can cause the input voltages to cross back and forth over the threshold, resulting in rapid output chatter. You fix this by adding positive feedback to create hysteresis (a Schmitt trigger effect). Connect a high-value resistor (e.g., 1MΩ) between the OUT pin and the IN+ pin. When the output snaps HIGH, the 1MΩ resistor slightly raises the IN+ voltage, moving the threshold further away from the IN- voltage. The input must now drop significantly lower to trigger the opposite state, creating a "dead band" that eliminates chatter.

Can I use a circuit diagram of comparator to drive a relay coil directly?

No, you cannot drive a standard 12V or 5V mechanical relay directly from an LM393 output. The LM393's open-collector transistor has a maximum continuous sink current rating of roughly 16mA to 20mA. A typical small signal relay coil requires 30mA to 80mA to pull in the armature. Attempting to drive it directly will exceed the IC's thermal limits and destroy the output transistor. Instead, use the LM393 output to drive the gate of a logic-level N-channel MOSFET (like the IRLZ44N) or the base of an NPN BJT (like the 2N2222), which then switches the relay coil. Always remember to place a flyback diode (e.g., 1N4007) in reverse parallel across the relay coil to suppress inductive kickback.