The LM339 is a quad comparator manufactured by Motorola, Inc. (Part ID: LM339). It consists of four independent voltage comparators designed to operate from a single power supply or dual supplies. The device compares two input voltages and outputs a digital signal indicating which input is higher.
Key features of the LM339 include:
The LM339 is widely used in:
Its versatility and reliability make it a popular choice in both industrial and consumer electronics.
Parameter | Value |
---|---|
Supply Voltage (Vcc) | 2V to 36V (single supply) |
Dual Supply Voltage (Vcc) | ±1V to ±18V |
Input Offset Voltage | 2mV (typical) |
Input Bias Current | 25nA (typical) |
Output Sink Current | 6mA (typical) |
Response Time | 1.3µs (for 5mV input overdrive) |
Operating Temperature Range | -40°C to +85°C |
Package Types | DIP-14, SOIC-14, TSSOP-14 |
The LM339 is typically available in a 14-pin package. Below is the pinout and description:
Pin Number | Pin Name | Description |
---|---|---|
1 | Output 1 | Output of Comparator 1 |
2 | Output 2 | Output of Comparator 2 |
3 | Vcc | Positive power supply |
4 | Output 3 | Output of Comparator 3 |
5 | Output 4 | Output of Comparator 4 |
6 | Inverting Input 4 | Inverting input of Comparator 4 |
7 | Non-Inverting Input 4 | Non-inverting input of Comparator 4 |
8 | Non-Inverting Input 3 | Non-inverting input of Comparator 3 |
9 | Inverting Input 3 | Inverting input of Comparator 3 |
10 | Non-Inverting Input 2 | Non-inverting input of Comparator 2 |
11 | Inverting Input 2 | Inverting input of Comparator 2 |
12 | Non-Inverting Input 1 | Non-inverting input of Comparator 1 |
13 | Inverting Input 1 | Inverting input of Comparator 1 |
14 | GND | Ground (0V reference) |
The following example demonstrates how to use the LM339 to compare two voltages and read the output using an Arduino UNO.
// LM339 Comparator Example with Arduino UNO
// This code reads the output of the LM339 and turns on an LED if the output is HIGH.
const int comparatorOutputPin = 2; // LM339 output connected to Arduino Pin 2
const int ledPin = 13; // Onboard LED pin
void setup() {
pinMode(comparatorOutputPin, INPUT); // Set comparator output as input
pinMode(ledPin, OUTPUT); // Set LED pin as output
Serial.begin(9600); // Initialize serial communication
}
void loop() {
int comparatorState = digitalRead(comparatorOutputPin); // Read LM339 output
if (comparatorState == HIGH) {
digitalWrite(ledPin, HIGH); // Turn on LED if comparator output is HIGH
Serial.println("Comparator Output: HIGH");
} else {
digitalWrite(ledPin, LOW); // Turn off LED if comparator output is LOW
Serial.println("Comparator Output: LOW");
}
delay(500); // Wait for 500ms before next reading
}
No Output Signal:
Incorrect Output:
Noise or Instability:
Floating Inputs:
Q: Can the LM339 be used with a 3.3V power supply?
A: Yes, the LM339 can operate with a supply voltage as low as 2V, making it compatible with 3.3V systems.
Q: Why is a pull-up resistor required on the output?
A: The LM339 has an open-collector output, which requires a pull-up resistor to define the output voltage level.
Q: Can the LM339 handle AC signals?
A: Yes, the LM339 can compare AC signals, but ensure the input signals are within the common-mode voltage range.
This concludes the documentation for the LM339 quad comparator.