Liquid Level Detection System Based on AT89C52 Single Chip Microcomputer

Publisher:asd123yuiLatest update time:2012-07-17 Source: 21ic Keywords:AT89C52 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

With the development of modern measurement technology, higher and higher requirements are put forward for the measurement system. In the automatic distillation measurement and control system, the accurate and timely detection of the first drop of liquid distilled from the condenser during the distillation process is the prerequisite for obtaining the initial distillation point; the real-time and accurate measurement of the change in the volume of the recovered liquid in the measuring cylinder is the basis for controlling the different distillation speeds at different times during the distillation process. However, there are many unsatisfactory aspects in the completion of the tasks of detecting, recovering, measuring, and measuring the speed of the droplets distilled from the condenser, and a more complete and reasonable droplet and liquid level detection tracking control system is needed.

From the perspective of the liquid level measurement method, it can be divided into two categories according to whether the detector is in contact with the liquid: one is contact measurement, and the other is non-contact measurement. When it is necessary to determine the volume change by measuring the liquid level change, the non-contact measurement method is generally used. However, in most non-contact measurements, the liquid level sensor has a large test range and an absolute resolution greater than 0.5ml. Therefore, when the volume change range is 0-100ml and the liquid level change range is 0-200mm, it is difficult for ordinary sensors to achieve a resolution of 0.1ml. For this reason, it is necessary to develop a high-precision liquid level detection system that measures the real-time change of liquid volume in an ordinary 100ml glass measuring cylinder.

In view of the above problems, this paper introduces a liquid level detection system with AT89C52 single chip microcomputer as the core, which realizes the purpose of high-precision volume measurement of changing liquid level.

1. Principle of area measurement

Due to the volume of the measuring cylinder

is certain and made evenly, then the height corresponding to a certain volume of liquid in the measuring cylinder is also certain. The sensor and the screw are coupled to each other, and the top of the screw is directly connected to the middle axis of the stepper motor. Every time the stepper motor takes a step, the screw turns a small angle. Therefore, when the motor step and the screw pitch are constant, the unit height of the measuring cylinder is proportional to the number of motor steps. Therefore, the volume of the liquid in the measuring cylinder can be directly converted into the number of motor steps, that is, how many milliliters of liquid is represented by each step of the motor.

The schematic diagram of volume measurement is shown in Figure 1. In order to determine the conversion relationship between the number of steps of the motor and the volume of the liquid in the measuring cylinder in milliliters, we need to calibrate the system. The specific calibration method is:

1. Measure the number of motor steps for a liquid volume of 10 ml and set its value to L1;

2. Measure the number of motor steps for a volume of 100 ml of liquid and set its value to L2;

Volume measurement diagram

According to the data recorded in the above steps, calculate the volume in milliliters represented by each step of the motor, and set its value as T, then the following calculation formula is obtained: T=90/(L2-L1). In this way, the volume of liquid tracked by the tracker can be easily calculated.

2. Hardware circuit composition and principle

The basic components of this system are: infrared photoelectric sensor, input circuit, clock circuit, reset circuit, display circuit, stepper motor and drive circuit, single-chip real-time processing and control circuit, etc.

Its basic working principle is: the various signals detected by the infrared photoelectric sensor are converted into electrical signals after passing through the signal processing circuit, and the electrical signals are sent to the single-chip microcomputer for judgment and calculation processing, and then control instructions are issued to control the stepper motor to complete the detection and tracking of the changing liquid level.

The hardware circuit block diagram is shown in Figure 2:

Hardware circuit block diagram

1. Infrared photoelectric sensor

The infrared photoelectric sensor is composed of an infrared emitting diode and a sensitive transistor. The wavelength of the infrared light emitted by the infrared emitting diode is the same or similar to the wavelength of the light received by the sensitive transistor. When there is no obstacle between the emitting tube and the receiving tube, the sensitive transistor is turned on due to receiving the infrared light signal, and the circuit output level is low; when there is an obstacle between the emitting tube and the receiving tube, the sensitive transistor is turned off due to not receiving the infrared light signal, and the circuit output level is high.

In this system, the detection of the liquid surface in the measuring cylinder is basically based on the scattering principle. The liquid on the surface of the liquid in the glass measuring cylinder will undergo epitaxy or adsorption to form a ring-shaped surface, which is just for our detection. It is composed of a pair of infrared photoelectric tubes. The liquid on the surface of the liquid in the glass measuring cylinder will undergo epitaxy or adsorption to form a ring-shaped surface. Due to the scattering effect, the receiving tube cannot receive the infrared light signal of the transmitting tube and is cut off, and the circuit output level is high. Therefore, the level of the liquid surface can be detected by the level of its output, and its output signal is then output to the single-chip interface circuit and the display drive circuit through the cable for processing. In order to meet the special requirements of this system, we install the infrared transmitting and receiving tubes on both sides of the U-shaped plate, and the distance between the two tubes is greater than the diameter of the glass measuring cylinder. In order to reduce the interference of external natural light, a certain depth of light guide hole groove is installed on the transmitting and receiving heads of the two tubes. On the one hand, it reduces the interference of external light, and on the other hand, it can limit the beam diameter to improve the detection resolution.

2. Stepper motor and drive circuit

When the stepper motor is working, its power supply mostly adopts unipolar 直流电\'); companyAdEvent.show(this,\'companyAdDiv\',[5,18])"> direct current . By energizing each phase winding of the stepper motor in an appropriate timing manner, it can be made to perform step rotation. The motor used in this system is a four-phase motor. When the two-phase winding is energized, the corresponding two magnetic poles form NS poles respectively, generate a magnetic field, and form a magnetic circuit with the rotor. Under the action of the magnetic field, the rotor will rotate a certain angle so that the rotor teeth are aligned with the stator teeth, so that the stepper motor "walks" forward one step. Therefore, the control of the motor rotation is mainly based on the requirements of the motor rotation direction, and the corresponding control signal can be output sequentially by the single-chip microcomputer.

The following takes forward rotation as an example. When rotating forward, it is required to output positive pulses with a width of 8ms in the order of ABCDA, and there is a small delay between the two pulses. Therefore, a series of signals such as 1000, 0100, 0010, 0001, 1000 can be output to the PC0~PC3 ports of 8255 in sequence. Each high level is maintained for 8ms, and the output time interval is 1ms, which can meet the control needs. Similarly, the motor can also be controlled to reverse, but the order of the output signal is reversed. Therefore, the initial control word in the register can be set to 00010001B (i.e. 11H). For each step of the motor, the content of this register is shifted to the left (forward) or right (reverse) by one position, and then the content of this register is taken out and output, and the control of the motor can be completed. [page]

3. Single chip microcomputer real-time processing and control

For this topic, the hardware circuit should be as simple as possible, and some circuits that can be realized by software should not be hardware circuits as much as possible, so as to achieve the purpose of miniaturization, low price and reliable performance of the product. When choosing a single-chip microcomputer, its convenience and practicality should also be fully considered. The biggest disadvantage of the 8031 ​​single-chip microcomputer is that it needs an external EPROM, the circuit is complicated, and the EPROM is erased by ultraviolet light, which is very inconvenient to use. After extensive comparison, it was determined to use the AT89C52 FLASH single-chip microcomputer of ATMEL. It not only has all the functions of the 8031 ​​single-chip microcomputer, but also has many functions that the 8031 ​​does not have. It has an 8KB internal FLASH program memory that can be erased multiple times, which can be erased electrically, which is very convenient.

The AT89C52 microcontroller has the following main features:

(1) Compatible with MCS-51 products;

(2) It has 8KB rewritable FLASH internal program memory and can perform 1000 erase/write operations;

3) Full static operation: 0Hz to 24MHz;

(4) Three-level program memory encryption;

(5) 256 bytes of internal RAM;

(6) 32 programmable I/O lines;

(7) Three 16-bit timers/counters;

(8), 8 interrupt sources;

(9) Programmable serial port;

(10) Low power idle and power-down modes.

The main function of the single-chip real-time processing and control part is to receive the converted electrical signal from the infrared photoelectric sensor and receive the status information sent by the input circuit. After judgment and calculation, on the one hand, it issues control instructions to control the operation of the motor and detect and track the liquid level; on the other hand, it sends the required data to display the data and indicate the status. Therefore, this part is the key part of this system, and its performance is directly related to the performance of the entire system. The specific hardware circuit is based on the AT89C52 single-chip microcomputer and is realized by expanding the parallel port 8255. The circuit is shown in Figure 3.

Circuit

As can be seen from Figure 3, the input circuit is connected to the P1 port of AT89C52, receives the input status information and sends it to the single-chip microcomputer. The liquid level signal is directly sent to the P3.0 port. During automatic tracking, the single-chip microcomputer continuously queries the P3.0 port and makes judgments and processes once there is a signal. The droplet signal is connected to the P3.2 port (i.e., the INT0 interrupt pin). Since the droplet detection is at any time, it needs to be controlled by interrupts. When the droplet signal comes, the interrupt responds and records the number of droplets. The upper and lower limit signals are connected to the P3.4 and P3.5 ports respectively. During operation, once the upper and lower limit signals appear, it means that the predetermined operating range has been exceeded. After receiving the signal, the single-chip microcomputer issues a control instruction to stop the rotation of the motor. Other control signals such as display and motor drive are sent to 8255 by the bus in time-sharing to complete the predetermined tasks.

The chip select signal /CS and the port address select lines A0 and A1 of 8255 are provided by P2.7 and P0.0, P0.1 of AT89C52 respectively after address latching, so the addresses of port A, port B, port C and control port of 8255 are 7FFCH, 7FFDH, 7FFEH and 7FFFH respectively. D0~D7 of 8255 are connected to P0.0~P0.7 of AT89C52 respectively, and its /RD, /WR are connected to /RD, /WR of AT89C52 one by one.

3. Software Design

System software is an important part of the whole system. Only under its command and control can the hardware circuit work and complete the corresponding functions. Moreover, the defects of some hardware circuits can be compensated by software programming. According to the functional requirements of the system, the software is in MCS-96 assembly language, with a modular structure, consisting of a main program, automatic detection and tracking subroutine, calibration subroutine, display subroutine, etc. In this system, the realization of high-precision measurement is largely guaranteed by software.

The main program includes system parameter initialization and cyclic working process, and is the core of the software part of this system. Its main tasks are: first, to initialize the system of single-chip microcomputer state parameters and program-defined state parameters; second, to manage and control each subroutine, arrange corresponding instructions, and provide subroutine entry data to achieve the purpose of completing system functions.

The function of the liquid level automatic detection and tracking subroutine is to control the liquid level tracker to take the bottom liquid level as the starting position, continuously track the change of the liquid level, and convert the actual liquid volume value to display it in real time. Its execution steps are: first, the infrared photoelectric sensor automatically detects the liquid level, and sets this liquid level as the bottom liquid level to be tracked, and displays it as "0". Then, it enters the real-time tracking state. As long as the liquid level changes (rises), the detector will automatically track and display the volume of the liquid in real time until the liquid level no longer changes.

The calibration subroutine is performed every time the measuring cylinder is replaced. The purpose is to find the corresponding relationship between the volume of the liquid in the measuring cylinder and the number of steps of the motor, and then send it to the microcontroller. When performing volume calculations, there will be a new standard to improve measurement accuracy.

IV. Conclusion

The liquid level detection system implemented by AT89C52 single chip microcomputer can achieve a resolution of 0.1ml in a standard 100ml glass measuring cylinder when the liquid level changes in the range of 0-200mm. Practice has proved that this liquid level detection system has high performance-price ratio and reliable control method. Its design ideas and methods can be used as reference for automatic distillation measurement and control systems, and have broad application prospects.

Keywords:AT89C52 Reference address:Liquid Level Detection System Based on AT89C52 Single Chip Microcomputer

Previous article:Design of ultrasonic ranging and anti-collision alarm system based on AT89C52
Next article:Realization of RS-485 multi-machine communication based on single chip microcomputer

Recommended ReadingLatest update time:2024-11-16 16:47

Application of magnetoresistive sensors in robot toy control systems
0 Background The control of direction is particularly important in the design of robot toy control system, which directly reflects the control accuracy and overall effect of robot toys. The problem to be solved in this paper is to control the angle between the robot's movement direction and the goal, so tha
[Test Measurement]
Application of magnetoresistive sensors in robot toy control systems
AT89C52 controls the temperature sensor DS18B20 and displays it on the LM016L_LCD
//-------------------------------------------------------- //File name: Temperature_Control // //File description: AT89C52 is used as the master control to obtain, process and send data in real time and perform global control; // DS18B20_Sensor temperature (-50 ~ 255℃) data is input in real time; // LM016L_LCD tempera
[Microcontroller]
Control design of AT89C52 microcontroller BH1415F FM station
BH1415F FM console control C program uses keilC51 through debugging //Use AT89C52 microcontroller, 12MHz crystal oscillator, and common anode four-digit LED digital tube //P0 port outputs segment code, P2 port scans //#pragmaSRC(d:aa.asm) #include“reg52.h” #include "intrins.h" //_nop_(); for delay function #defineDi
[Microcontroller]
Control design of AT89C52 microcontroller BH1415F FM station
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号