Liquid Level Control System Based on AT89S51

Publisher:电子设计探索者Latest update time:2012-01-31 Source: 微计算机信息 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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

Reference address:Liquid Level Control System Based on AT89S51

Previous article:Design of parking lot management function board based on microcontroller
Next article:Design of 0.01℃ digital thermometer based on AT89C51 control

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号