The LM393 is a dual voltage comparator that is widely used in sensor circuits, voltage monitoring, signal processing, and microcontroller-based applications. It allows you to compare two voltages and output a digital HIGH or LOW signal based on the comparison.
๐น 1. What is LM393?
- LM393 is a dual comparator, meaning it has two independent voltage comparators inside a single package.
- Unlike an operational amplifier (Op-Amp), it is designed specifically for fast voltage comparison.
- Outputs either HIGH (logic 1) or LOW (logic 0), making it ideal for microcontroller interfacing.
๐ Key Features:
- Dual comparators in one package (can compare two separate voltage pairs).
- Open-collector output (allows interfacing with different voltage levels).
- Low power consumption.
- Can operate from a single power supply (2V – 36V).
- Fast response time (~1.3ยตs switching speed).
๐ Common Applications:
- Zero-crossing detection (detects when a signal crosses 0V).
- Overvoltage and undervoltage protection.
- Analog-to-digital conversion (ADC) circuits.
- IR sensors, motion detectors.
- Battery level monitoring.
๐น 2. LM393 Pinout & Functions
The LM393 comes in an 8-pin DIP/SOIC package.
Pin No. | Name | Function |
---|---|---|
1 | OUT1 | Output of Comparator 1 |
2 | IN1- | Inverting Input (-) of Comparator 1 |
3 | IN1+ | Non-Inverting Input (+) of Comparator 1 |
4 | GND | Ground (0V) |
5 | IN2+ | Non-Inverting Input (+) of Comparator 2 |
6 | IN2- | Inverting Input (-) of Comparator 2 |
7 | OUT2 | Output of Comparator 2 |
8 | VCC | Power Supply (2V – 36V) |
๐ How it works:
- Each comparator compares two voltages (
IN+
andIN-
). - If
IN+
>IN-
, the output is LOW (0V). - If
IN-
>IN+
, the output is HIGH (open-collector, needs a pull-up resistor).
๐น 3. How LM393 Works
- The LM393 outputs a digital HIGH or LOW based on the voltage difference between
IN+
andIN-
. - Unlike Op-Amps, the output is open-collector, meaning it requires a pull-up resistor to function properly.
๐ Logic Table for LM393 Comparator:
Condition | Output (OUTx Pin) |
---|---|
IN+ > IN- | LOW (0V, sinks current) |
IN+ < IN- | HIGH (Needs pull-up resistor to VCC) |
๐น 4. Using LM393 for a Sensor Circuit
๐ Required Components
- 1x LM393 Comparator
- 1x LDR (Light Dependent Resistor)
- 1x 10kฮฉ Resistor (Pull-down)
- 1x 100kฮฉ Resistor (Reference Divider)
- 1x LED + 330ฮฉ Resistor (Output Indicator)
- 1x 5V Power Supply
- Jumper Wires
๐ Wiring
LM393 Pin | Connection |
---|---|
VCC (Pin 8) | +5V |
GND (Pin 4) | GND (0V) |
IN1+ (Pin 3) | LDR voltage divider output |
IN1- (Pin 2) | Reference voltage (via 100kฮฉ resistor) |
OUT1 (Pin 1) | LED + 330ฮฉ Resistor to VCC |
๐ How it works:
- When LDR detects bright light,
IN+
voltage increases aboveIN-
, and the output goes LOW (LED OFF). - When LDR detects darkness,
IN+
drops belowIN-
, and the output goes HIGH (LED ON).
๐น 5. Arduino Code for LM393 (Reading Output)
This code reads the output of LM393 and prints the light level.
#define SENSOR_PIN 7 // LM393 output connected to Arduino D7
void setup() {
pinMode(SENSOR_PIN, INPUT);
Serial.begin(9600);
}
void loop() {
int state = digitalRead(SENSOR_PIN);
if (state == LOW) {
Serial.println("Bright Light Detected");
} else {
Serial.println("Darkness Detected");
}
delay(500);
}
๐ What happens?
- When it’s bright, the output is LOW (0V) โ The Arduino detects “Bright Light Detected”.
- When it’s dark, the output is HIGH โ The Arduino detects “Darkness Detected”.
๐น 6. LM393 for Battery Level Monitoring
๐ Can be used to monitor battery voltage and trigger alerts when voltage drops below a threshold.
โ Example: Low Battery Indicator
LM393 Pin | Connection |
---|---|
VCC (Pin 8) | Battery Positive |
GND (Pin 4) | Battery Negative (0V) |
IN1+ (Pin 3) | Voltage Divider (Battery Voltage Sampling) |
IN1- (Pin 2) | Fixed Reference Voltage (Zener or Resistor Divider) |
OUT1 (Pin 1) | Connects to LED or Microcontroller for alert |
๐ If battery voltage drops below threshold, LM393 output goes HIGH, triggering an alert.
๐น 7. Applications of LM393
โ
Light Sensing (LDR Circuits) โ Used for automatic street lights.
โ
Zero-Crossing Detection โ Detects when AC voltage crosses 0V.
โ
Overvoltage/Undervoltage Protection โ Prevents damage to circuits.
โ
DC Motor Speed Monitoring โ Used in tachometers.
โ
Touchless IR Sensors โ Common in motion detection systems.
๐น 8. LM393 vs Other Comparators
Feature | LM393 | LM358 (Op-Amp) | LM339 (Quad Comparator) |
---|---|---|---|
Number of Comparators | 2 | 2 (Op-Amps, not true comparators) | 4 |
Operating Voltage | 2V โ 36V | 3V โ 32V | 2V โ 36V |
Output Type | Open-Collector | Push-Pull | Open-Collector |
Best For | Logic-level voltage detection | Analog amplification | Multi-channel voltage comparison |
๐ Verdict:
- LM393 is ideal for digital-level voltage comparisons (requires pull-up resistor).
- LM358 is an Op-Amp, better for analog signal amplification.
- LM339 is a quad comparator (similar to LM393 but with four comparators).
๐ฏ Conclusion
- LM393 is a dual voltage comparator with an open-collector output.
- Used in light sensing, battery monitoring, zero-crossing detection, and voltage protection.
- Requires a pull-up resistor for output.
- Ideal for microcontroller-based applications (low power, fast switching).