Implementation of PLC-based PID algorithm in constant water level control
2026-04-06 06:47:11··#1
Abstract: This paper focuses on the ongoing automation upgrade project of the Shiyuan Water Plant in Zhengzhou. A modular design scheme with implementation control functions is adopted, fully utilizing the capabilities of the configuration software and employing a PLC-based PID algorithm to achieve constant water level control in the water plant's filter tanks. The upgraded filter tanks can now operate automatically at a constant water level, achieving unattended operation and significantly reducing the labor intensity of workers. The system operates normally and has practical value. Keywords: filter; PID algorithm; constant water level; computer control Abstract: Aiming at the automatic transformation of the filter in Zhengzhou Shiyuan Waterworks, this article adopts a modular design plan with instant control function, develops the functions of Configuration Software to the full extent, and makes good use of PID algorithm based on PLC to achieve the control of constant water level in the filter. The transformed filter can achieve automatic constant water level movement and realize self-service. The design reduces the labor intensity of the workers. It works well and is applicable. Key words: filter; PID algorithm; constant water level; computer control 1 Introduction As an important link in ensuring water quality, the role of the filter is receiving increasing attention. The constant water level control technology of the filter has also been continuously developed. From analog PID, digital PID to optimal control, adaptive control, and then to intelligent control, each step has improved the control performance. This paper takes the Shiyuan Water Plant in Zhengzhou City as an example and applies the improved PID algorithm to the automatic control process of the filter tank so that it can control the opening of the clear water valve in real time according to the change of water level, so that the water level can always be kept in balance. 2 Implementation of PID algorithm in constant water level control 2.1 PID control algorithm PID (Proportional Integral Differential) control algorithm is the classic closed-loop control. It is the most mature and widely used adjustment method in continuous systems. The essence of PID adjustment is to calculate according to the input deviation value, according to the proportional, integral and derivative functional relationship, and the calculation result is used for output control [1]. When the absolute value of the system output error is large, the system adopts the saturated output working mode, which can reduce the time delay of the liquid level system. At the same time, in order to prevent the system from having too large overshoot, when the absolute value of the system error is relatively small, the integral coefficient is increased, which can improve the steady-state accuracy of the system [2]. The differential control algorithm is simple, the parameter adjustment is convenient, and it has a certain control accuracy and can sense the trend of error change. Increasing the differential control action can speed up the system response, reduce the overshoot, and obtain a more satisfactory control effect. Therefore, it has become the most widely used control algorithm. The control law of the PID controller is: ………………(2-1) Since equation (2-1) is an analog expression, and the PLC program can only handle discrete digital quantities, the continuous differential equation must be transformed into a discrete difference equation. Let…………… (2-2) Then we can obtain the positional digital PID algorithm……………(2-3) Using a positional PID digital controller will cause integral accumulation of PID operations, resulting in system overshoot, which is not allowed in the production process. Therefore, after conversion, the incremental algorithm is obtained……………(2-4) The incremental PID control algorithm processes the deviation increment and then outputs the increment of the control quantity, that is, the increment of the actuator position. The incremental PID digital controller will not saturate, and when the computer malfunctions, it can maintain the output value of the previous sampling time, keeping the system stable. Therefore, the incremental algorithm is used as a programming algorithm in this system. 2.2 Constant Water Level Control To ensure production safety, the flow rate of water to be filtered and the flow rate of water after filtration in each filter station should be kept basically balanced. Therefore, each filter cell should maintain a constant water level during filtration. During normal filtration operation, each filter group, under the control of the local PLC console, adjusts the opening of the filter valve in a timely manner according to the amount of incoming water to ensure constant water level operation. When backwashing conditions are met or forced backwashing is performed manually, the local control cabinet of each filter group sends a backwashing request to the main station. The main PLC sorts the filter groups that need backwashing, using a first-in-first-out stack management system. After the backwashing conditions are met, the valve status of the filter group to be backwashed first is adjusted. After the water level drops to a certain height, the blower is started for air washing. After the air washing is completed at the agreed time, the backwash pump is started for combined air and water washing. After the combined washing is completed, the blower is turned off, and another backwash water pump is started for water washing. After water washing is completed, the normal filtration state of this filter group is restored, and the next group is backwashed. After all backwashing is completed, the normal constant water level filtration cycle begins. Since the fundamental purpose of constant water level is to ensure that the flow rate of the filtered water and the flow rate of the filtered water are basically constant, it is transformed into controlling the water level of each filter cell to keep it basically constant [3]. PID closed-loop control can control the opening of the clear water valve in real time according to the change of water level, and transform all the above conditions affecting the change of water volume into the control of the filter cell water level. 2.3 PID logic control instructions and parameter settings for clear water valve When the inflow increases or the outflow decreases due to the increase of head loss in the pool, the water level rises above the set water level. The water level deviation e is positive. The larger e is, the larger u is, so the opening of the outlet valve increases, and the outflow also increases accordingly, so the water level drops to the set water level. When the inflow decreases or the water level drops below the set water level due to other factors, the water level deviation e is negative. The larger the absolute value of e is, the smaller u is, so the opening of the outlet valve decreases, and the outflow also decreases accordingly, so the water level rises to the set water level, so the water level is controlled within a certain fluctuation range centered on the set water level. As can be seen from the integral control term in equation (2-1), the controller output u is inversely proportional to the integral time T. When T is small, the same water level deviation will result in a large integral control action. If the integral control action is too strong, it will cause overshoot: when the water level deviates from the set water level, the strong integral control action will cause the outlet valve opening to change too much, causing the water level correction to be too large, resulting in large oscillations. The smaller the integral time T, the more serious the overshoot phenomenon, and the larger the oscillation amplitude of the controlled variable (water level), eventually exceeding the allowable range. Therefore, correctly setting the control parameters is an important prerequisite for ensuring that the control system can meet the design requirements [4]. For actual production processes, accurately determining the mathematical model is quite difficult. This system determines the control parameters through experimental methods. 2.3.1 Special processing in parameter design: After setting the parameters, some program processing can be performed in the external program according to the actual situation on site. The following processing was done in this project: ① The PID calculation result is placed in an intermediate variable. When the water level is within 5cm above or below the set water level, the PID calculation result is output to the output template once every 3 minutes; otherwise, the PID calculation result is output once every 10 seconds. This is to minimize the operation of the clear water valve when the water level is within an acceptable range, but to prioritize production safety and water quality when it exceeds the range. At the same time, it largely eliminates the calculation error caused by external interference to the input analog quantity. ② Even under the above conditions, the program will compare the difference between the current PID calculation result and the previous output value. If the opening degree is within two opening degree ranges, the current PID calculation result will not be output; otherwise, the calculation result will be output. Because the opening degree of the clear water valve is within two opening degrees, it has little effect on water level regulation. However, adjusting the clear water valve with a small opening degree will cause the valve opening degree to be insufficient, resulting in frequent operation of the solenoid valve. ③ When the opening degree of the clear water valve is less than 10 opening degrees, the water flow is basically the same as when it is fully closed. Therefore, we directly output the fully closed signal when the PID calculation result is less than 7 opening degrees. 2.4 PID control ladder diagram subroutine The implementation of the automatic control part of each filter requires 28 digital input points, 18 digital output points, and 13 analog input and output points. The entire PLC automatic control system has self-protection and power failure data protection functions. In the event of power supply or other serious faults, it can immediately enter the emergency processing state. The process conditions and program time are memorized. After the fault is eliminated, the system can immediately return to the state before the fault, which greatly improves the reliability of the whole machine [5]. Table 1 is the I/O address table of the PLC system. Only the main I/O addresses are listed here. Table 1. PLC Control I/O Address Allocation Table (Partial) The above parameters enable the corresponding control process. During the installation and commissioning phase of the water plant filter automation, the data sampling frequency is constant. System commissioning personnel adjust the corresponding parameters to make the opening degree of the filtered water valve change with the water level in the filter, thereby keeping the water level in the filter basically within the range of (2.00 ± 0.20) m. The following figure shows a partial ladder diagram program of the filter during backwashing: [align=center] Figure 1: Partial ladder diagram program of the filter during backwashing[/align] 3. Comparison of Operating Effects Before and After After commissioning, we statistically found that the number of times the clear water valve operates per day is less than 200 times, which is much less than the average of 4000 times per day in other water plants. It is basically the same as the effect of manually adjusting the clear water valve based on experience, but greatly reduces the labor intensity of workers. However, the actual situation of each water plant is different, so the methods used in the system commissioning process will also be different, and the parameter settings will also be different. After analyzing the data before and after the filter improvement, the following fluctuation curve comparison chart is drawn. As shown in Figure 3, the water level in the filter bed changes very little after PID adjustment, and the filter bed liquid level can maintain a constant operating level. [align=left] 4. Summary This project was applied to the automated retrofit system of the filter beds at the Shiyuan Water Plant in Zhengzhou City. The system uses an industrial control computer as its core and adopts a fuzzy integral separation digital PID control scheme, ladder diagram language, and KingSCADA software. After three months of operation, the system fully meets production requirements. The system's reliability, ease of operation, and information capacity have been greatly improved, truly realizing automated management of the filter beds on-site. It achieves automatic filtration, timed automatic queuing, and backwashing, and the new system has greatly improved the water purification effect of the filter beds. The use of standard PID control software package realizes closed-loop automatic control of the filter bed water level, enabling multiple groups of filter beds to operate automatically simultaneously, maintaining the operating water level within 4% of the working water level. The constant water level control reduces the number of filter bed backwashings, reduces water and electricity consumption by 1/3, and generates economic benefits of 3 million yuan. It significantly reduces production costs and improves water quality, demonstrating significant application value. The innovation of this paper is to combine the improved incremental PID algorithm with constant water level control, optimize the constant water level control method, reduce water and electricity consumption, reduce the labor intensity of workers, and improve the automation level and efficiency of filter water treatment. References: [1] Liu Jinhun. Advanced PID Control and its MATLAB Simulation [M]. Beijing: Electronic Industry Press. 2003.25 [2] Ding Fang, Li Yanfang, Fei Yulong. Application of Intelligent PID Algorithm in Liquid Level Control System [J]. Microcomputer Information, 2006, 6-1: 103-105. [3] He Guojin, Ren Qiang. Fully Automatic Quasi-Constant Pressure Water Supply System for Residential Communities Controlled by PLC [J]. Water Supply and Drainage. 2005, 31(3): 97-100. [4] Li Youchun, Gong Li. Development and Utilization of PLC Control System for Waterworks [J]. Industrial Control Computer. 2000, 13(4): 15. [5] STEP 7 Ladder Diagram Logic Reference Manual [Z]. Siemens, 1999.