 Home Technical Articles LM311  Oct 16 2020

# LM311 Voltage Comparator: 4 Simple Circuit Diagram

## I Introduction

LM311 is a commonly used linear comparator. The LM311 is cost-effective, and this is the reason why it is widely used in various comparison circuits. This blog uses take the advantage of the LM311 to introduce and analyze a series of circuits that using the LM311 such as light control and water leak detection. These circuits have the characteristics of simple structure and low manufacturing cost, which makes the LM311 well used in the circuit. Figure 1. LM311 Voltage Comparator

## Catalog

 I Introduction II LM311 Basic Circuit III LM311 Gas Detection Circuit IV LM311 Light Controller Circuit V LM311 Water Leakage Detection Circuit FAQ

## II LM311 Basic Circuit Figure 2. LM311 Basic Circuit

The basic circuit diagram based on the LM311 design above has the following features and precautions:

• Sliding rheostat to divide the voltage, and the maximum resistance can be selected.
• If you want to make a zero-crossing comparator, the 3 pin is directly grounded.
• The pull-up resistor at the output end and pin 1 should be connected to ground.

The voltage comparator LM311 has 8 pins in total. The 7th pin among them is the output, which is an open collector structure, that is, the so-called open collector gate, or OC gate for short. Its role is to meet some special needs, such as driving LEDs, lights, relays, and level compatibility with the following digital circuits.

Therefore, when the high level should be output, the high level will not be obtained. It is necessary to connect a resistor between pin 7 and pin 8 of the positive power supply, such as about 1kΩ, so that the collector is no longer open.

## III LM311 Gas Detection Circuit Figure 3. LM311 Gas Detection Circuit

The terminal 3 of the integrated voltage comparator LM311 has a constant input of 5V.

Since the sensor output current is proportional to the indoor gas (smoke) concentration, that is:

I = kC

• I : sensor output current
• C : indoor gas concentration
• k : proportional constant

Therefore, we can use the sensor and potentiometer 1R to convert the gas concentration is converted into a voltage signal and input to terminal 2 of LM311 (that is, V=kC*1R).

The voltage comparator can convert the analog signal into a binary signal. LM311 is a general-purpose integrated comparator with low open-loop gain, large offset voltage, and low common-mode rejection ratio; however, it has a fast response speed, short transmission delay time, and can directly input high-level signals to the microcontroller.

It can be seen from the above analysis that the upper limit of the indoor alarm concentration can be adjusted by adjusting the resistance of the potentiometer.

## IV LM311 Light Controller Circuit

This circuit is based on the voltage comparator integrated circuit LM311, and the resistors R3 and R4 at the non-inverting input of IC1 give a 6V reference voltage. Because the resistance of the photoresistor can reach several megohms in the dark, when the potential of the inverting input terminal is high and the comparator is low, Q1 is not turned on, and the relay does not pull in.

On the contrary, because the resistance of the photoresistor when illuminated is 5-10K, when the potential of the inverting input terminal is low, the output of the comparator is high, and when Q1 is turned on, the relay pulls in. If you swap the LM311 input + -, the situation is exactly the opposite. By adjusting R1, we can set how much illuminance to start the relay. Figure 4.  LM311 Light Controller Circuit

## V LM311 Water Leakage Detection Circuit

Principle of water leak detector:

When water leaks between the two electrodes of the water receiving plate, the resistance value between the two electrodes will change greatly, so that it can be detected whether there is water leakage.

The bridge circuit is a circuit that measures various physical quantities by a comparison method. The simplest is a circuit composed of four branches, each branch is called the "arm" of the bridge. In the actual detection circuit, using the excellent characteristics of the bridge circuit in detecting resistance, the change in resistance value is detected by voltage detecting bridge. Figure 5.  LM311 Water Leakage Detection Circuit

It can be considered that the water leakage detection electrode is a variable resistor, which serves as a branch of the bridge, and the remaining three branches have the same resistance value. The specific resistance value can be determined according to the resistance value of the water leakage electrode in the presence and absence of water. The range should be between the resistance value when there is water and the resistance value when there is no water, and the middle value can be taken as the value of the remaining three-way resistance.

In the detection bridge, if there is no water leakage from the detection electrode, its resistance value is large, so V+﹥V﹣, namely V_id﹥0, V_out﹥0.

If the detection electrode has water leakage, its resistance value is small, so V+﹤V﹣, namely: V_id﹤0, V_out﹤0. In this way, it is possible to accurately detect whether there is water leakage. In other words, the level of the output level of the voltage comparator LM311 represents the presence or absence of water leakage. Figure 6. Leak Sensor PCB

When designing LM311 comparator circuit, it should be noted that when a high-speed comparator is used for high-speed input signals and low source impedance input signals, the normal output response should be fast and stable.

However, when the input signal is a slowly changing signal or a high-impedance signal source, the comparator may oscillate at the comparison threshold point, which is caused by the high gain and broadband of the comparator, and the presence of interference also causes this oscillation. One of the direct reasons. In application, we must avoid such oscillation and instability. The generation of oscillation has a lot to do with the arrangement of structure.

The signal output end should be far away from the input pin, and also should be far away from the two balanced end pins. Filter capacitors should be added to the positive and negative power supplies to filter out the interference of the power supply, and the capacitors should be placed near the pins. Increase the amplitude of the input signal to reduce the possibility of oscillation. Pulling a resistor at the output of the comparator and connecting a capacitor of appropriate capacity at both ends has a significant effect on filtering and reducing oscillation.

## FAQ

• How to use LM311?

LM311 is a single-channel comparator. When using it, connect the reference voltage and the compared signal voltage to its non-inverting and inverting input terminals (pin 2 and pin 3), and its output is the result of the comparison. If you want the foward output result, pin 7 is connected to the positive power supply and pin 1 is the output. If the result is to be output in reverse, pin 1 is grounded and pin 7 is the open collector output.

• lm311 and lm393 are both voltage comparators, so what is the difference between them?

LM311 is single voltage comparaotor, LM393 is dual voltage copatpr. LM311 has a load current of up to 50MA and a voltage of 40V. It can drive relays with a minimum power supply voltage of 5V.

The LM393 load current is 16MA, and the minimum voltage is 2V for a single power supply.

• Whats the difference between LM311 and LM111?

Their functions are the same, and the 1XX series can be used in harsher environments.

The 3XX series can only be used in a commercial environment, typically the applicable temperature range of the device.

The price of 1xx is much more expensive than 3xx.

• What does the 5 and 6-pin balance strobes of LM311 mean?

The function of balancing the mirror current of the reverse circuit is realized by connecting a potentiometer in the middle. In addition to the balance function, the 6 pin also has a strobe function, and the 6 pin can be grounded through the transistor drive circuit for strobe output.

• ### What is the difference between lm311 voltage comparator dual power supply and single power supply?

The comparators are all open-collector outputs, without load resistance, they cannot output voltage signals.

Dual power supplies can detect signals lower than 0, and single power supplies can only detect signals higher than 0.

• ### Can the lm311 comparator be powered by a positive and negative five-volt dual power supply?

Of course, LM311 can be powered by ±5V dual power supply. Its requirement for working power supply is that the voltage difference between the positive and negative power supply (or single power supply voltage) is at least 3.5V and the maximum is 30V, as long as it is within this range.

After reading the blog, have you better understand LM311 comparator circuit?