0 Introduction
Liquid level is one of the important parameters in many industrial productions. In the fields of chemical industry, metallurgy, medicine, aviation, etc., the measurement and control of liquid level directly affects the quality of products. Single-chip microcomputers are widely used in production due to their small size, low power consumption, high control accuracy, and reliable operation. This paper discusses a liquid level control system developed with AT89C51 as the core. The system can not only perform patrol detection, display and alarm of liquid level, but also intelligently control the liquid level.
1 System Hardware Design
The block diagram of the system hardware is shown in Figure 1. It is mainly composed of AT89S51, input circuit and output circuit.
Figure 1 System hardware block diagram
1.1 Microcomputer system
The core of the system is an AT89S51 microprocessor. This is a low-power, high-performance CMOS 8-bit microprocessor compatible with the MCS-51 series chips and with 4KB flash erasable read-only memory. In addition to normal operation, it can also work in low-power idle and power-down modes, further reducing the power consumption of the chip. In addition to 4K FLASH, it also has 128 bytes of RAM, 2 16-bit timers/counters, 5 two-level interrupt source structures, 32-bit parallel input/output ports and a full-duplex serial port, watchdog timing circuit, etc. Since the AT89C51 integrates FLASH, RAM, I/O, and serial ports, only a small amount of peripheral circuits are required to form a liquid level intelligent control system, and the structure of the entire system is very compact. This compact structure helps to reduce power consumption and improve system reliability.
1.2 Keyboard, display and alarm part
P1.0 ~ P1.5 are used as keyboard interfaces to connect a 2×4 keyboard. They can respectively realize the functions of liquid level upper and lower limit display, liquid level upper and lower limit setting, etc. The display is composed of 4-digit LEDs, which are used to display the height of each liquid level in real time, as well as the upper and lower limit values of the liquid level.
The alarm function is to sound and light alarm when the liquid level exceeds the set value range.
1.3 Data acquisition and output control part
The data acquisition part consists of a liquid level transmitter, an amplifier circuit, and an A/D converter. The output of the liquid level transmitter is a 4 ~ 20mA current signal, which is converted into a 0 ~ 5V voltage signal that can be received by A/D0809 through a conversion amplifier circuit. Under the control of the AT89C51 microcontroller, the liquid level data is collected in real time and processed.
The output control part controls the flow valve through a stepper motor according to the results of the PID algorithm to achieve the purpose of liquid level control.
2 Software Design
The system software mainly consists of a main program, a sampling program, a PID algorithm program and some subprograms.
2.1 Main Program
The flow chart of the main program is shown in Figure 2.
Figure 2 Main program flow chart
The main function of the main program is to complete the initialization of AT89C51, set the upper and lower limits of the liquid level, display the real-time liquid level value, key scanning and other tasks.
2.2 Sampling and data processing module
This system uses a timing cycle to take turns to sample 8 liquid levels in real time, processes the real-time data, and adopts a PID control scheme.
Since the actuator of this system is a stepper motor, we use incremental PID control. According to the incremental principle, we can get
According to the above derivation, the program flow chart of the incremental PID control algorithm is shown in Figure 3.
Figure 3 Flowchart of incremental PID control algorithm
2.3 Other functions
The user can set the upper and lower limits of the liquid level through the keyboard, and display the upper and lower limits of the liquid level at any time. When the liquid level exceeds or falls below the set value, an audible and visual alarm will be issued to remind the operator to take timely action.
3 Anti-interference measures
3.1 Hardware anti-interference design
The system power supply is an important component and is directly connected to the external power grid. In order to prevent interference signals from the power supply system, a low-pass filter is set at the power input to filter out high-order harmonic components. In addition, the watchdog timer in AT89S51 is used to further improve the system hardware's anti-interference ability.
3.2 Software Anti-interference Design
When designing the program, each program module is partitioned and stored, leaving some storage units between each other, and filling these units with FF (RST instruction). At the same time, three NOP instructions are added before the important jump and subroutine call instructions in the program to ensure the correctness of the program flow, because if the PC makes a mistake in one digit, the entire program will be completely unrecognizable, causing confusion in the detection system.
The sliding average filtering method is used to calculate the average value. The liquid level values obtained by the last 6 samplings are removed, and the arithmetic mean of the remaining 4 data is calculated.
4 End
The liquid level intelligent control system uses a single-chip microcomputer as the main controller, which has a simple structure, high reliability and strong anti-interference. Due to the application of the PID control scheme, the system has a fast response speed, small overshoot, good system stability and has certain practical value.
References
1 AT89S51 manual, http://www.atmel.com
2 Liu Jinkun, Advanced PID Control and Its MATLAB Simulation, Beijing, Publishing House of Electronics Industry, 2003
3 Zhou Hangci, Microcontroller Application Programming Design Technology, Beijing, Beijing University of Aeronautics and Astronautics Press, 1991
Previous article:Design of parking lot management function board based on microcontroller
Next article:Design of 0.01℃ digital thermometer based on AT89C51 control
- Popular Resources
- Popular amplifiers
- Introduction to Artificial Intelligence and Robotics (Murphy)
- A Microprocessor Performance Analysis Approach Based on Microbench and Ideal Bound
- Principles and Applications of Single Chip Microcomputers and Embedded Systems
- 2004_High Frequency High-Efficiency Voltage Regulators for Future Microprocessor
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- How to choose between different chips in TI's Sub-1GHz product line?
- Design of optimal horn antenna based on HFSS
- How to connect several cameras to a 100M switch
- Nvidia is said to acquire Arm for 40 billion pounds. Will the situation of domestic chips get worse?
- Operational issues of XDS100V3.0 emulation motoware built-in project
- GD32E231 Learning 3: SPI driving OLED
- What documents does the patch welding factory need?
- [Show goods] + Water Group Wholesale Department
- Pnp transistor collector connected to power supply problem
- China's 3G is silent