Phone

    00852-6915 1330

LM339 Circuit: How to Make Water Level Indicator?

  • Contents

I Description

This blog mainly discusses and solves the following problem: How to use an LM339 voltage comparator to make a reservoir water level gauge?

According to water level, this design performs signal processing and controls the potential of multiple voltage comparators, so the output will change accordingly. Therefore, under its drive, LED can not only emit light but also achieve the effect of indicating the water level.

lm339

Figure 1. LM339

Catalog

I Description

II Introduction

III Woking Principle

IV Device selection and Component Production

4.1 device selection

4.2 Part Production

V Installation and Debugging

5.1 Detection Part

5.2 Display Part

VI Conclusion

FAQ

Ordering & Quantity

II Introduction

Due to insufficient water supply in some residential areas, pump workers must first store water in the reservoir and then supply water in a regular manner. In this way, the pump worker must know the water level of the reservoir at any time in the pump room.

In the past, electrodes such as copper rods or stainless steel were used to detect the water level of the pool. However, due to electric corrosion, the function of the electrode is lost soon after use. For this reason, this blog uses an LM339 voltage comparator to make water level gauge

This not only eliminates the pain of often changing electrodes but also simple and easy. How simple is it? Only two wires need to be connected from the reservoir to the pump room. After more than two years of operation, its performance has been stable and reliable, achieving the expected results.

III Woking Principle

The main circuit of the water level gauge is composed of 4 LM339  voltage comparators,  This kind of integrated circuit has the characteristics of easy purchase, low price, single power supply operation, and wide differential range.

Each LM339  has 4 independent voltage comparators  (15 in this design). As long as the potential difference between the positive and negative input terminals is 10mV, the output terminal can be reliably switched from one state to another.

  • When the positive input terminal is 10mV higher than the negative input terminal, its output terminal is high;
  • When the negative input is 10mV higher than the positive input, its output is low. In addition, LEDs can be driven directly.

Then how to make the output end of LM339  have high and low-level changes? In specific use, an appropriate resistance is generally added between the output terminal and the positive power supply. This resistor is called a pull-up resistor. That is, when the output terminal of LM339  is in a high impedance state, the potential of the output terminal is pulled up by the resistor.

block diagram of water level gauge

Figure 2. Block Diagram of Water Level Gauge

The principle block diagram of the device is shown in Figure 2.

The voltage signal measurement consists of a reed switch and a voltage divider resistor. The ring magnets suspended in the water are in different positions. Due to the principle of electromagnetic induction, not only the corresponding dry reed switch normally open contacts are closed, but also the corresponding voltage divider resistor is connected. Therefore, the circuit will pick up different voltage signals.

The potential of the negative input terminal of the comparator is formed by a fixed voltage divider resistor. The measured voltage signal is compared with the set potential. The result of this is that the LED displays the water level when driven. In addition, an alarm is issued when the highest water level is reached to remind the pumper to stop water injection to prevent water overflow.

The concrete circuit is shown as in Fig. 3.

water level gauge circuit diagram

Figure 3. Water Level Gauge Circuit Diagram

In Figure 3, the power supply is + 12 V, and the depth of the pool is divided into 15 segments for display.

In this picture:

  • A1~A15 are voltage comparators  composed of LM339  ;
  • GK1~GK15 are dry reed switches, the normally open contact is closed when the ring magnet is close to a certain dry reed switch;
  • The voltage divider circuit composed of resistors R 1 to R 15 determines the potential of the positive input terminal of each comparator. The voltage of the positive input terminal of LM339  changes due to the different positions of the magnetic steel.
  • The voltage divider circuit composed of resistors R 01 ~ R 030 determines the potential of the negative input terminal of each comparator. The potential of each negative input terminal is fixed after the determination.

When the magnetic steel floating on the water surface is close to a certain dry reed switch, due to the partial pressure of R 1, R 2,…, R 15, the positive input terminals of the comparators A1, A2, …, A15 have different inputs. After this signal is compared with the potential set at the negative input of the comparator, there will be a corresponding output.

From Figure 3, when GK1 pulls in, it is equivalent to holding the magnetic steel float at the upper limit water level. The positive input of each comparator is equal to the ground potential, which is lower than their negative input. Therefore, the output terminals are all low level, so all LEDs are lit. At this time, the output of A1 drops from high level to low level, and NE555 is triggered through capacitor C.

NE555 is connected as a monostable circuit. Once triggered, its 3 pin will output a high level, which will drive the buzzer to alarm. Its duration is determined by the RC components connected to the 6 and 7 pins. When GK2 is closed, LED 2 ~ LED 15 should be on, and LED 1 should be off. At this time, the potential of the positive input terminal of each comparator is higher than the potential of the negative input terminal of A1 and lower than the potential of the negative input terminal of A2~A15, and so on.

IV Device selection and Component Production

4. 1 device selection

a. Set the negative input potential of each comparator to V sh.

The negative input potential of each comparator is set artificially according to the number of segments divided into the power supply and water depth. Because the pool depth has been divided into 15 segments for display, starting from 2.0 V, the difference between each adjacent negative input terminal is 0.4 V. As shown in the first row in Table 1.

b. Select the resistance between the negative input terminal of each comparator and the power supply, that is, the voltage divider resistance R 01 = R 03 =… = R 029 = 20 kΨ, set to R.

c. Calculate the ground resistance R 02, R 04,..., R 030, which is R r.

Suppose the resistance of the negative input terminal to the ground is R r, and the potential of each negative input terminal is V sh, according to circuit diagram 3:

(1)

From this formula:

(2)

For example, to make the potential of the negative input terminal of the voltage comparator A1 V sh = 2 V, according to equation (2), we can get

As shown in the second row and the first column in Table 1. The selection of the other resistors R 04, R 06,…, R 030 can be calculated according to the above formula (the result is a theoretical value, see the data shown in the second row in Table 1 for details).

d. Determine the nominal resistance R b from R r. In fact, the nominal value of commercially available resistors is different from this calculated value. In specific applications, a nominal resistance R b with a similar resistance value can be selected. The specific value is shown in the third row of Table 1.

e. Determine the potential V of the negative input terminal of each comparator A by R b. When the nominal value of resistance R b is selected, use the following formula to check the potential V generated by this resistance.

(3)

The specific potential value is shown in the 4th row of Table 1, compared with the set value in the 1st row, as long as it does not exceed ±0.1V.

f. Determine the resistances R 1, R 2,…, R 15 of the positive input terminals of each comparator and set them as R zh.

First find R 1, set the positive input potential of each comparator as V zh, when GK1 pulls in, it can be seen from Table 1 that 2V <V zh <2. 4 V, set V zh = 2. 2 V, R = 20 kΨ, according to formula (3), it can be listed

The solution is that R zh = R 1 ≈ 4.5 kΨ. This resistance is not the nominal value. Choose a similar nominal value of 4.8 kΨ. Then find the other resistances R 2, R3, …, R 15, which can all be calculated by this method. The result is the theoretical value, which has a slight deviation in practice. After correction, the value is shown in the fifth row of Table 1.

After the above parameters are selected in this way, it can be ensured that when the water level in the pool reaches the lowest limit and the float holding the magnetic steel sinks to the lowest position, the magnetic steel separates from all the reed switches and the LEDs are all extinguished; And when the first reed switch GK1 is closed (equivalent to the water level in the pool reaches the highest limit, the float holding the magnetic steel rises to the highest position) LEDs are all on. When the float is at a certain position in the middle, the corresponding LED and the LEDs below are all on, and the LED above it is off, to show the water level. After the above calculation, the specific data shown in Table 1 is obtained.

4.2 Part Production

It is necessary to measure the height from the lowest water level of the reservoir to the limit water level, and divide this height into 15 segments. The distance of each segment is less than 200mm, this distance can ensure that the magnetic steel can always attract an adjacent dry reed switch, so as to avoid display breakpoints. That is to prevent the magnetic steel from not attracting the upper dry reed pipe or the lower dry reed pipe during operation, so that the LED display is all extinguished, causing the illusion of waterlessness.

For the connections of GK1, R1~GK15, R15, first solder them to a small printed circuit board with a width less than or equal to 20mm, and then use wires to connect them at a distance of less than or equal to 200mm, and encapsulate them in a 25mm hard plastic tube. . The upper and lower mouths of the pipe should be tightly sealed to prevent water leakage.

The tube is covered with a ring-shaped magnet. After dropping a non-ferromagnetic heavy object on the lower end of the hard plastic pipe, the plastic pipe is vertically sunk into the bottom of the reservoir.

A ring float is placed under the magnetic steel and is sleeved on the tube, and the upper end of the tube is fixed on the observation port above the reservoir. Due to the function of the float, the magnetic steel is always suspended on the water surface, rising and falling with the water surface. Note that the plane of the magnetic steel should always be parallel to the water surface, and the plastic pipe should be vertical to the water surface to prevent the magnetic steel from being stuck by friction with the pipe wall when the water level rises and falls.

V Installation and Debugging

The whole device consists of two parts:

  1. It is a detection part composed of a reed switch and various voltage dividers;
  2. It is the signal processing display part composed of LM339.

5.1 Detection Part

Before encapsulating the plastic tube, put some silica gel in the tube to absorb the moisture in the tube and prevent the line in the tube from getting damp.

If ring-shaped magnetic steel is used as the detection element, the reed pipe connected in series in the plastic tube should be realized by two staggered reed pipes.

According to the electromagnetic induction theory, the analysis of the magnetic field lines of the magnetic steel shows that there are a small section of magnetic field lines parallel to the plane of the magnetic steel at the upper and lower openings of the magnetic steel.

When this section is close to the reed switch, the direction of its magnetic field line is perpendicular to the direction of the reed of the reed switch. At this time, although the reed switch is very close to the magnetic steel, the contact is still released and disconnected, which will make all the LEDs go out. If two staggered reed pipes are used instead, the problem can be solved, and the staggered distance can be determined in experiments.

5.2 Display Part

The water level of each segment is displayed by green Υ10 LED, and the limit water level is displayed by eye-catching red LED. If the LEDs are arranged neatly together, the water level in the pool can be clearly seen according to the on or off of the LEDs. Equipped with a buzzer, it will give the pump worker a clearer reminder.

Note: From the detector in the pool to the circuit board of the pump room, it is best to use shielded wire to prevent interference signals from entering. We should also note that the power supply must be regulated.

lm339Fugure 4. lm339

VI Conclusion

The negative input potential of the voltage comparator A1~A15 composed of  LM339  should be set according to a certain rule, and the potential interval between each other depends on the depth of the cell. If the water level is deeper, the interval can be smaller, and the number of sections can be selected more.

The potential difference between adjacent comparators is generally 0.4V. If the potential difference is large, the selection of the resistance is easy; if the potential difference is small, because the nominal value interval of the general resistance is large, it is necessary to use an adjustable resistor to adjust the potential. Of course, in the case of small intervals, the smallest potential difference between each other should be greater than 10mV, otherwise, the input characteristics of  LM339 will not be able to distinguish the potential between each other.

In addition, the voltage of the power supply and the nominal value of each resistance must be considered. This method can also be applied to other fields. Such as monitoring the water depth of rivers, rivers, lakes, and bays, the oil level of gas stations, and the depth of water tanks in water plants.


FAQ

  • What is LM339?

LM339 is a voltage comparator IC from LMx39x series and is manufactured by many industries. The devices consist of four independent voltage comparators that are designed to operate from a single power supply.

  • What is the difference between LM324 and LM339?

The LM324 has a complementary output while the LM339 is open collector. In the complementary output, current can flow in either direction as required (either source or sink) while the open collector output can only sink current.

  • How does LM339 comparator work?

The LM339 is a quad op amp comparator. A comparator works by a simple concept. Each op amp of a comparator has 2 inputs, a inverting input and a noninverting input. If the inverting input voltage is greater than the noninverting input, then the output is drawn to ground.

  • What is comparator ic?

A comparator is an electronic circuit, which compares the two inputs that are applied to it and produces an output. The output value of the comparator indicates which of the inputs is greater or lesser. Please note that comparator falls under non-linear applications of ICs.

  • What is the replacement for LM339?

LM311, LM324, LM397, LM139, LM239, LM2901

  • What is a comparator circuit?

A comparator circuit compares two voltages and outputs either a 1 (the voltage at the plus side; VDD in the illustration) or a 0 (the voltage at the negative side) to indicate which is larger. Comparators are often used, for example, to check whether an input has reached some predetermined value.

  • What is the use of LM339?

LM339 is used in applications where a comparison between two voltage signals is required. In addition with four of those comparators on board the device can compare four pairs of voltage signals at a time which comes in handy in some applications.

Kynix

Kynix was founded in 2008, specializing in the electronic components distribution business. We adhere to honesty and ethics as our business philosophy and have gradually established an excellent reputation and credibility in our international business. With the accurate quotation, excellent credit, reasonable price, reliable quality, fast delivery, and authentic service, we have won the praise of the majority of customers.

Join our mailing list!

Be the first to know about new products, special offers, and more.

Leave a Reply

We'd love to hear from you! Feel free to share your thoughts and comments below. Rest assured, your email address will remain private.

Name *
Email *
Captcha *
Rating:

Kynix

  • How to purchase

  • Order
  • Search & Inquiry
  • Shipping & Tracking
  • Payment Methods
  • Contact Us

  • Tel: 00852-6915 1330
  • Email: info@kynix.com
  • Follow Us

authentication

Kynix

© 2008-2026 kynix.com all rights reserved.