Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use LM339: Examples, Pinouts, and Specs

Image of LM339Design with LM339 in Cirkit Designer

Introduction

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:

Explore Projects Built with LM339

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Mega2560-Controlled Automation System with Non-Contact Liquid Level Sensing and Motor Control: A project utilizing LM339 in a practical application
Mega2560-Controlled Automation System with Non-Contact Liquid Level Sensing and Motor Control

This circuit appears to be a complex control system centered around an Arduino Mega2560 R3 Pro microcontroller, which interfaces with multiple sensors (XKC-Y26-V non-contact liquid level sensors and an LM35 temperature sensor), servo motors, a touch display, and an IBT-2 H-Bridge motor driver for controlling a planetary gearbox motor. The system also includes a UART TTL to RS485 converter for communication, likely with the touch display, and a power management subsystem with a switching power supply, fuses, and circuit breakers for safety and voltage regulation (XL4016). The absence of embedded code suggests that the functionality of the microcontroller is not defined within the provided data.

Open Project in Cirkit Designer
Image of WiFi LoRa Environmental Monitoring System with INMP441 Mic and Multiple Sensors: A project utilizing LM339 in a practical application
WiFi LoRa Environmental Monitoring System with INMP441 Mic and Multiple Sensors

This circuit is a solar-powered environmental monitoring system that uses a WiFi LoRa 32V3 microcontroller to collect data from various sensors, including a microphone, UV light sensor, air quality sensor, and temperature/humidity/pressure sensor. The collected data is processed and transmitted via LoRa communication, making it suitable for remote environmental data logging and monitoring applications.

Open Project in Cirkit Designer

Common Applications

The LM339 is widely used in:

Its versatility and reliability make it a popular choice in both industrial and consumer electronics.


Technical Specifications

Key Specifications

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

Pin Configuration and Descriptions

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)

Usage Instructions

How to Use the LM339 in a Circuit

  1. Power Supply: Connect the Vcc pin (Pin 3) to a positive voltage source (2V to 36V for single supply) and the GND pin (Pin 14) to ground.
  2. Input Connections: Connect the voltage signals to be compared to the inverting and non-inverting input pins of the desired comparator.
    • For example, to use Comparator 1, connect the signals to Pin 13 (Inverting Input 1) and Pin 12 (Non-Inverting Input 1).
  3. Output: The output pin of the comparator (e.g., Pin 1 for Comparator 1) will provide a digital signal:
    • Low (0V): When the voltage at the inverting input is higher than the non-inverting input.
    • High (Vcc): When the voltage at the non-inverting input is higher than the inverting input.
  4. Pull-Up Resistor: The LM339 has an open-collector output, so a pull-up resistor is required on each output pin to ensure proper operation.

Important Considerations

Example: Using LM339 with Arduino UNO

The following example demonstrates how to use the LM339 to compare two voltages and read the output using an Arduino UNO.

Circuit Setup

  1. Connect the LM339's Vcc pin to the Arduino's 5V pin and GND to the Arduino's GND.
  2. Connect the voltage signals to the inverting and non-inverting inputs of one comparator.
  3. Use a 10kΩ pull-up resistor on the output pin of the comparator.
  4. Connect the comparator's output to a digital input pin on the Arduino (e.g., Pin 2).

Arduino Code

// 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
}

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Output Signal:

    • Ensure the pull-up resistor is connected to the output pin.
    • Verify that the input voltages are within the LM339's common-mode range.
  2. Incorrect Output:

    • Check the polarity of the input signals (inverting vs. non-inverting).
    • Ensure the power supply voltage is within the specified range.
  3. Noise or Instability:

    • Add a decoupling capacitor (0.1µF) near the Vcc pin.
    • Use shielded cables for input signals to reduce noise interference.
  4. Floating Inputs:

    • Connect unused comparator inputs to ground or Vcc to prevent erratic behavior.

FAQs

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.