# Based on Improved Artificial Neural Network Sewage Monitoring Alarm System Method

Authors: Liping Chen; Ruichuan Zhao; Wenzheng Wu
Journal: Scientific Programming
 (2022)

---

## Abstract

Sewage discharge has become a key issue affecting the quality of the water environment, and how to effectively monitor and manage sewage discharge behavior has become a key factor to avoid water pollution and improve water quality. However, the current domestic sewage discharge monitoring system is not perfect, resulting in the lack of effective monitoring of enterprise sewage discharge by regulatory authorities, which provides an opportunity for enterprises to steal discharge. In the background of sewage treatment plant, the comprehensive design of sewage monitoring and alarm system is carried out based on the idea of physical information fusion. The design adopts a four-layer information physical architecture, which is divided into four parts: perception communication, fusion processing, push, and execution. In the fusion treatment part, the neural network intelligent algorithm is used to predict the dissolved oxygen, and the oxygen delivery is adjusted according to the predicted value to achieve accurate aeration and optimize the effluent quality. The push and execution parts adopt multiparameter monitoring to realize the smooth operation of equipment and ensure the system security. A new optimal control strategy of dissolved oxygen based on neural network is proposed. Through a large number of experiments and historical data, the intake index and dissolved oxygen value of the aeration tank under the condition of optimal outlet water are obtained as samples. According to the sample training, the BP neural network optimized by particle swarm optimization algorithm is adopted to achieve accurate prediction of dissolved oxygen under different inlet water conditions. The smooth operation of sewage treatment equipment is accomplished by the lower machine and the upper machine. In sewage treatment, each process section collects the equipment status in strict accordance with the order of sewage monitoring facilities. Then the communication network between the upper computer and the lower computer and the sensor is designed. The lower machine adopts PLC as the core, programming PLC through STEP7, and uses PID algorithm to control dissolved oxygen. The PC is developed in C language, so as to realize user login, real-time data display, over-limit fault alarm, report query, user management, etc. The PC integrates MATLAB neural network on the platform to predict dissolved oxygen through mixed programming quantity. The sewage alarm system based on improved artificial neural network is sensitive and has excellent performance. It provides a new idea for intelligent sewage detection and real-time monitoring.


---

## Body

## 1. Introduction

“Gold mountains and silver mountains are not as good as lucid waters and lush mountains.” Water resources protection has always been a major national policy of our country. The Party Central Committee has thoroughly implemented the sustainable development strategy for many years, promoted the construction of a resource-saving and environment-friendly society, improved water treatment and discharge standards, and continuously increased large investment in the construction of livelihood projects related to sewage treatment. From 2011 to 2018, the daily treatment capacity of urban sewage in our country increased from 113.03 million cubic meters to 168.8 million cubic meters, and the number of sewage treatment plants increased from 1,588 to 2,321, an increase of 46% in 8 years. According to relevant policies and regulations, our country will achieve full coverage of sewage treatment in 2020, requiring the urban sewage treatment rate to reach 90% [1–3].In recent years, more and more attention has been paid to sewage treatment in China. The increase in the number of sewage plants requires more skilled operators and consumes a lot of money. By contrast, automated monitoring systems that manage equipment according to established procedures can reduce the stress of staffing [4]. At the same time, through the accurate measurement of data by measuring instrument, the timely transmission of data by stable high-speed communication network, and the personification of data by intelligent control method, the sewage treatment process can be effectively managed on the basis of energy saving. Therefore, according to the actual needs, the introduction of intelligent control methods and advanced automation equipment, based on the design of sewage treatment monitoring system, has important significance for the development of economic society, in line with the requirements of industry development [5].In the past decades, technological innovation has brought great changes to our lives, and intelligent algorithms have been widely applied in various fields [6]. The concept of intelligent algorithm has been widely recognized around the world since its introduction. Scholars from all countries agree that it is necessary to give full play to the excellent achievements made by human beings in the field of electronic information, closely combine information and physics, turn industrial system to intelligence, and form cyberphysical system [7]. A mature and intelligent sewage treatment monitoring system can realize real-time monitoring of various parameters of the equipment and, through intelligent methods, according to different sewage water quality, adjust the treatment strategy and adjust the parameter settings in key steps. This can not only reduce energy consumption but also optimize the quality of the effluent after treatment; the intelligent monitoring system can also improve the stability of the equipment and the level of intelligent informatization and reduce production costs; in the end, it can liberate labor and allow technicians. A lot of energy is put on the improvement of sewage treatment process and the development of sewage treatment equipment, so as to realize the requirements of constructing economical production and develop productivity.


## 2. Related Work

After the industrial revolution in the 19th century, economic and social changes took place in foreign countries, which also led to a series of environmental pollution problems, including water pollution. So far, the sewage treatment system has gone through the stages shown in Table1.Table 1
Sewage treatment control stages.
Development phaseCharacteristicManual control stageManual detection, recording data, by human controlSemiautomatic control stageInstrument detection data, manual recording data, mechanical operationAutomatic control stageInstrument detection record data, storage data, central control operationInformation control stageAutomatic control, engineering optimization, information management, group managementIn foreign countries, the problem of water pollution caused by the development of industrialization appeared earlier. During the 1950s and 1960s, developed countries gradually realized the need for early detection and treatment of sewage.The United States, with the strongest comprehensive national strength, had built more than 20,000 sewage treatment plants, of which four-fifths were secondary treatment plants. Sweden had a small population and a well-developed sewer system that can collect almost all sewage. Britain and Germany had a sewage treatment plant for every 7,000 people on average, and the treatment effect could basically achieve the effect of secondary treatment, and Germany was the country that developed sewage treatment industry earlier. The largest sewage treatment plant in the United States in the 20th century had a maximum capacity of 5 million cubic meters per day, while Japan’s largest sewage treatment plant had a capacity of nearly 2.5 million cubic meters per day.Now automatic control systems are widely used in sewage treatment plants abroad. A variable number of on-site detection instruments are used, such as physical treatment (precipitation, filtration), drug delivery and pump room and other sewage treatment of each link to monitor, and then measured data through the network to the central control room computer, convenient data recording, storage, and fault alarm. The role of automatic control was not only reflected in the control of equipment but also reflected in the actual processing process. Pierson John used the relationship between ORP (REDOX potential) and the removal rate of COD and ammonia nitrogen to control the ORP in the pretreatment process of poultry wastewater and successfully controlled the content of COD and ammonia nitrogen in effluent below 7% and 65% [8]. Zipper et al. used ORP as a control parameter to shorten the nitrification cycle, reduce the sludge load, and save energy while improving the sewage treatment rate [9]. Puznava et al. kept dissolved oxygen between 0.5 and 3 mg/L in the aeration process through active intervention, extended the denitrification reaction time in nitrification and denitrification, and reduced the aeration capacity in the aeration tank by half on the basis of meeting the water quality discharge standard, which played an energy-saving role [10].Some detection instruments are placed in the equipment, respectively, and the data in the sewage is collected through the PLC CPU. The lower computer PLC controls and handles the fault, and alarms are sent in time to remind the staff to eliminate the fault. Compared with the Ohio sewage discharge monitoring system in the United States, the chromatographic monitoring method at the river inlet and sending the information back to the computer in the central control room for analysis and processing has achieved good results in organic pollution treatment. At the same time, the control of sewage treatment in developed countries has also achieved a high degree of modernization: according to the process and treatment needs, a multilevel control system is adopted, which is divided into control stations according to its own different conditions. Different intelligent control methods are adopted to realize the automatic control of different control objects. High tech water quality analysis instruments are used to monitor the sewage treatment process online in real time, and the data are transmitted to the computer in the form of reports [11]. For example, the sewage treatment plant built in Geneva in 1989 is unattended, and operators can monitor the system at any time through mobile phones, the Internet, and other media. In Paris, France, the central server effectively monitors and warns organic pollutants by monitoring water quality and processing data, but the cost is high and information sharing is difficult [12]. Now, almost all factories in the United States have automatically controlled the main process parameters. As regards Macon’s sewage treatment plant in the Middle East, although the daily treatment capacity of a single equipment is not strong, its process is relatively perfect. The plant has achieved 24-hour telephone alarm duty, and there are no other staff on duty except normal office workers.To sum up, the foreign sewage automatic control system has such characteristics: advanced water quality intelligent analysis instrument was used to monitor the water quality of each link of sewage treatment, and the measured accurate data was transmitted to the subcontrol station, which would adjust the control parameters according to the preset intelligent control program. At the same time, it was transmitted to the computer in the central control room by the subcontrol station to record data, generate reports, and generate trend curves. These control stations had different control objects and different control strategies. Both the central control computer and the subcontrol station had redundancy design to ensure the reliability and security of the system. Operators could use telemetry and remote control devices (such as mobile phone networks, telephone lines, Internet, etc.) to respond to alarm information from afar.


## 3. Improved BP Neural Network Intelligent Prediction Model by Particle Swarm Optimization

### 3.1. Particle Swarm Optimization

The specific process of particle swarm optimization algorithm is not complicated. At the beginning, a group of particles are randomly generated in the solution space, and each of them represents a possible solution in the space and has a fitness value, which depends on the optimization function. Each particle has another speed to control the direction and distance of its movement. The particles then adjust their search strategy according to the current best particle. The particle adjusts its speed by referring to two extreme values. The first extreme value is the optimal solution found by the particle itself, which is called individual extreme valuepbest. The second is the optimal solution currently found for all particles, which is called the global extreme value gbest.The dimension of solution space that defines particle motion isD, and the number of particles in the initial generated particle group is N, so any particle represents a D-dimensional vector. Here, I particles are taken as an example. (1)Xi=xi1,xi2,⋯xiD,i=1,2…NThe velocity of particlei is also a D-dimensional vector.(2)Vi=vi1,vi2,⋯viD,i=1,2…D.The best position that particlei can find at the moment is the individual extremum:(3)pbest=Pi1,Pi2,⋯PiD,i=1,2…N.The best position that can be found for all particle swarms is the global extremum:(4)gbest=Pg1,Pg2,⋯PgD.After the individual and global extreme values are determined, the individual particle changes its velocity and orientation according to the following equation:(5)vik+1=w∗vik+c1r1pbesti−xik+c2r2gbesti−xik,xik+1=xik+vik+1.w in the above equation is called the inertial weight, and c1 and c2 are called the learning factors. r1 and r2 are random numbers between 0 and 1. In equation (1), the first term on the right side of the equal sign can be understood as a kind of “inertia” that particles are subjected to in the D-dimensional space. This inertia can give particles the ability to keep themselves moving towards the original direction. It provides the particles with an incentive to stay in their original motion. The middle term on the right side of the equation is usually understood as “own experience.” Just as people can choose the best way to solve problems according to their previous experience, particles modify their movement strategy according to the best solution they have found before. The right-hand end of the equation is usually understood as “social experience,” in which particles communicate through knowledge transfer to obtain the orientation of the best solution in the whole group and then modify their movement strategy according to this orientation, similar to interpersonal communication in human society. Parameter IV represents the speed of the particle itself. vi∈−vmax,vmax,vmax represents the maximum speed that the particle can obtain. The setting of the maximum speed ensures that the particle will not lose control of speed [13–15].


### 3.2. Further Optimization by Particle Swarm Optimization

#### 3.2.1. Improvement of Inertia Weight

In the traditional equation (1), the inertial weight w is set to a constant real number. This method will confine the convergence speed and convergence precision of particles to a specific value, and what is needed in this paper is that particles can choose and adjust their own search strategy according to their own search period. According to the analysis, it is better to have large w in the equation of PSO at the beginning of searching, which can make the whole group move at a high rate. At the end of the search, it is better for the equation to have smaller w, which enables the whole group to move more precisely to the optimal position. In this paper, a method is designed to decrease as the number of iterations increases, and its slope keeps changing all the time: (6)wk=wwminmax∗exp−15kMAXEPOCH3min,where k is the current iteration number of particle swarm; MAXEPOCH is the maximum number of iterations of particle swarm. In this design, wmax=0.9, wmin=0.4, and MAXEPOCH = 1000 are set.


#### 3.2.2. Learning Factor Improvement

In equation (1), c1 represents “self-experience” and c2 represents “social experience.” Similar to the change of the weight factor, the particle swarm can acquire more “own experience” and less “social experience” at the beginning of the search period, which can make the overall movement rate of the swarm higher. At the end of the search, there is less “self-experience” and more “social experience,” which enables the group as a whole to move more accurately to the optimal position. This requires c1 to start large and then small and c2 to start small and then large, and, after experimental analysis, linear change is difficult to meet the requirements of the system, the design also adopts nonlinear change, and the specific implementation method is [16–19](7)c1=41+expρ∗k/MAXEPOCH−0.5,(8)c2=4−c1.To control the descent speed ρ, this design takes 4.


### 3.3. Specific Flow of Particle Swarm Optimization

Step 1: initialize the particle swarm, and give the particle number, dimension, initial position, speed, and other parameters.Step 2: calculate the value according to the fitness equation, and give the overall best positiongbest and individual best position pbest.Step 3: reset the particle’s velocity and orientation according to equations (1)–(5).Step 4: after particle movement, if the current position is better thanpbest, then reset pbest to the current particle position. If it appears that the current position is better than gbest, the best position of the entire particle swarm, then gbest is reset to the current particle position.Step 5: if the value of the fitness equation is lower than the set stop value or the frequency of particle updating position exceeds the set maximum number of iterations, the optimal particle position is output. If the two conditions are not met, go back to Step 3.


### 3.4. Improved BP Neural Network by Particle Swarm Optimization

BP algorithm adopts the strategy of gradient descent and shows excellent local searching ability under nonlinear condition. If the parameter adjustment is already around the best parameter during the algorithm execution, the global optimization can be achieved in a short time. However, if the parameter adjustment is far from the optimal solution, it may fall into the trap of local optimization. Since BP algorithm adopts the strategy of gradient descent to correct system parameters, here is a vivid analogy: To find the optimal solution, the BP algorithm needs to search in a valley with multiple bumps. The algorithm error is very large. Particle swarm optimization (PSO) belongs to the category of algorithms based on global search. When the search starts, the convergence rate is relatively high. When it approaches the best solution of the whole, the convergence rate of its algorithm is relatively low, and sometimes it cannot meet the requirements. Therefore, such complementary advantages and disadvantages provide us with a way of thinking. If the two can be combined, local optimization can be avoided, while fast convergence can be achieved at the overall optimal point [20–22]. Particle swarm optimization belongs to the category of algorithms based on overall search. When the search starts, the convergence rate is relatively large. When it is close to the overall best solution, the convergence rate of the algorithm is relatively small, and sometimes it cannot meet the requirements. Therefore, the complementary advantages and disadvantages provide us with a way of thinking. If we can combine the two, we can avoid local optima and quickly converge at the overall optima.In the design, using the design idea of particle swarm, the BP algorithm is optimized through the initial weight and threshold so that the particles can search for the best solution vector in the weight and threshold, and then set the weight of the BP algorithm and the corresponding solution vector of the threshold, and train again. The detailed execution process is as follows: Set the search space dimension of particle swarm optimization algorithm to be equal to the total number of weights and thresholds in BP algorithm, and then the position to which the particle moves is a solution of the weight threshold. The fitness function of particle swarm is shown in the following equation:(9)f=1n∑j=1n∑k=1myk−tk2.In the above equation,n is the number of sample groups collected by training BP network, m is the number of neurons in the last layer of BP network, yk is the actual efferent value after input sample, and kt is the ideal efferent value. Given (9), the optimization process can be thought of as keeping f in the equation as small as possible. If the size of f during the operation of the algorithm is lower than the set stop quantity or the frequency of particle updating position exceeds the set stop number, the algorithm ends. At this point, the weight threshold represented by the optimal particle position is set as the initial weight threshold of the BP network, and then the BP neural network is trained.


### 3.5. Improved BP Neural Network Algorithm Flow

Step 1: set BP network parameters, such as the number of nodes at each layer. Set the number of individuals in the particle swarm, dimension (threshold number, weighted value number), and other parameters.Step 2: give the initial position of the particle, assign the corresponding value of the initial particle position to the neural network, calculate the value according to equation (6), and give the overall optimal position gbest and individual optimal position pbest.Step 3: reset the particle’s velocity and orientation according to equations (1)–(5).Step 4: after particle movement, if the current position is better thanpbest, then reset pbest to the current particle position. If it appears that the current position is better than gbest, the best position of the entire particle swarm, then gbest is reset to the current particle position.Step 5: check whetherf in equation (6) is lower than the set stop quantity or the frequency of particle updating position exceeds the set stop number, and go to the next step. If not, go back to Step 3.Step 6: set the weight threshold represented by the optimal particle position as the initial weight threshold of the BP network, and then train the BP neural network.


### 3.6. Dissolved Oxygen Improved BP Neural Network Prediction Model Simulation

The initial range of each particle is between [−1, 1]. According to the guidance of literature, the initial individual number of particle swarmm = 100, the minimum training stop error is set to 10−4, the maximum iteration number is set to 1000, and the learning factor starts to calculate c1 = 2.4861 according to formulas (7) and (8). c2=1.5139, wmax=0.9, wmin=0.4, vmax is set to 2, and ρ is set to 4. The training target precision is 10−5, and the training cycle times are set as 1000 times. Simulation results are shown in Figure 1.Figure 1
Improved neural network prediction results.As can be seen from the figure, the fitting effect of the improved neural network is very good, and the error is relatively small, which meets the standard of industrial application.


## 3.1. Particle Swarm Optimization

The specific process of particle swarm optimization algorithm is not complicated. At the beginning, a group of particles are randomly generated in the solution space, and each of them represents a possible solution in the space and has a fitness value, which depends on the optimization function. Each particle has another speed to control the direction and distance of its movement. The particles then adjust their search strategy according to the current best particle. The particle adjusts its speed by referring to two extreme values. The first extreme value is the optimal solution found by the particle itself, which is called individual extreme valuepbest. The second is the optimal solution currently found for all particles, which is called the global extreme value gbest.The dimension of solution space that defines particle motion isD, and the number of particles in the initial generated particle group is N, so any particle represents a D-dimensional vector. Here, I particles are taken as an example. (1)Xi=xi1,xi2,⋯xiD,i=1,2…NThe velocity of particlei is also a D-dimensional vector.(2)Vi=vi1,vi2,⋯viD,i=1,2…D.The best position that particlei can find at the moment is the individual extremum:(3)pbest=Pi1,Pi2,⋯PiD,i=1,2…N.The best position that can be found for all particle swarms is the global extremum:(4)gbest=Pg1,Pg2,⋯PgD.After the individual and global extreme values are determined, the individual particle changes its velocity and orientation according to the following equation:(5)vik+1=w∗vik+c1r1pbesti−xik+c2r2gbesti−xik,xik+1=xik+vik+1.w in the above equation is called the inertial weight, and c1 and c2 are called the learning factors. r1 and r2 are random numbers between 0 and 1. In equation (1), the first term on the right side of the equal sign can be understood as a kind of “inertia” that particles are subjected to in the D-dimensional space. This inertia can give particles the ability to keep themselves moving towards the original direction. It provides the particles with an incentive to stay in their original motion. The middle term on the right side of the equation is usually understood as “own experience.” Just as people can choose the best way to solve problems according to their previous experience, particles modify their movement strategy according to the best solution they have found before. The right-hand end of the equation is usually understood as “social experience,” in which particles communicate through knowledge transfer to obtain the orientation of the best solution in the whole group and then modify their movement strategy according to this orientation, similar to interpersonal communication in human society. Parameter IV represents the speed of the particle itself. vi∈−vmax,vmax,vmax represents the maximum speed that the particle can obtain. The setting of the maximum speed ensures that the particle will not lose control of speed [13–15].


## 3.2. Further Optimization by Particle Swarm Optimization

### 3.2.1. Improvement of Inertia Weight

In the traditional equation (1), the inertial weight w is set to a constant real number. This method will confine the convergence speed and convergence precision of particles to a specific value, and what is needed in this paper is that particles can choose and adjust their own search strategy according to their own search period. According to the analysis, it is better to have large w in the equation of PSO at the beginning of searching, which can make the whole group move at a high rate. At the end of the search, it is better for the equation to have smaller w, which enables the whole group to move more precisely to the optimal position. In this paper, a method is designed to decrease as the number of iterations increases, and its slope keeps changing all the time: (6)wk=wwminmax∗exp−15kMAXEPOCH3min,where k is the current iteration number of particle swarm; MAXEPOCH is the maximum number of iterations of particle swarm. In this design, wmax=0.9, wmin=0.4, and MAXEPOCH = 1000 are set.


### 3.2.2. Learning Factor Improvement

In equation (1), c1 represents “self-experience” and c2 represents “social experience.” Similar to the change of the weight factor, the particle swarm can acquire more “own experience” and less “social experience” at the beginning of the search period, which can make the overall movement rate of the swarm higher. At the end of the search, there is less “self-experience” and more “social experience,” which enables the group as a whole to move more accurately to the optimal position. This requires c1 to start large and then small and c2 to start small and then large, and, after experimental analysis, linear change is difficult to meet the requirements of the system, the design also adopts nonlinear change, and the specific implementation method is [16–19](7)c1=41+expρ∗k/MAXEPOCH−0.5,(8)c2=4−c1.To control the descent speed ρ, this design takes 4.


## 3.2.1. Improvement of Inertia Weight

In the traditional equation (1), the inertial weight w is set to a constant real number. This method will confine the convergence speed and convergence precision of particles to a specific value, and what is needed in this paper is that particles can choose and adjust their own search strategy according to their own search period. According to the analysis, it is better to have large w in the equation of PSO at the beginning of searching, which can make the whole group move at a high rate. At the end of the search, it is better for the equation to have smaller w, which enables the whole group to move more precisely to the optimal position. In this paper, a method is designed to decrease as the number of iterations increases, and its slope keeps changing all the time: (6)wk=wwminmax∗exp−15kMAXEPOCH3min,where k is the current iteration number of particle swarm; MAXEPOCH is the maximum number of iterations of particle swarm. In this design, wmax=0.9, wmin=0.4, and MAXEPOCH = 1000 are set.


## 3.2.2. Learning Factor Improvement

In equation (1), c1 represents “self-experience” and c2 represents “social experience.” Similar to the change of the weight factor, the particle swarm can acquire more “own experience” and less “social experience” at the beginning of the search period, which can make the overall movement rate of the swarm higher. At the end of the search, there is less “self-experience” and more “social experience,” which enables the group as a whole to move more accurately to the optimal position. This requires c1 to start large and then small and c2 to start small and then large, and, after experimental analysis, linear change is difficult to meet the requirements of the system, the design also adopts nonlinear change, and the specific implementation method is [16–19](7)c1=41+expρ∗k/MAXEPOCH−0.5,(8)c2=4−c1.To control the descent speed ρ, this design takes 4.


## 3.3. Specific Flow of Particle Swarm Optimization

Step 1: initialize the particle swarm, and give the particle number, dimension, initial position, speed, and other parameters.Step 2: calculate the value according to the fitness equation, and give the overall best positiongbest and individual best position pbest.Step 3: reset the particle’s velocity and orientation according to equations (1)–(5).Step 4: after particle movement, if the current position is better thanpbest, then reset pbest to the current particle position. If it appears that the current position is better than gbest, the best position of the entire particle swarm, then gbest is reset to the current particle position.Step 5: if the value of the fitness equation is lower than the set stop value or the frequency of particle updating position exceeds the set maximum number of iterations, the optimal particle position is output. If the two conditions are not met, go back to Step 3.


## 3.4. Improved BP Neural Network by Particle Swarm Optimization

BP algorithm adopts the strategy of gradient descent and shows excellent local searching ability under nonlinear condition. If the parameter adjustment is already around the best parameter during the algorithm execution, the global optimization can be achieved in a short time. However, if the parameter adjustment is far from the optimal solution, it may fall into the trap of local optimization. Since BP algorithm adopts the strategy of gradient descent to correct system parameters, here is a vivid analogy: To find the optimal solution, the BP algorithm needs to search in a valley with multiple bumps. The algorithm error is very large. Particle swarm optimization (PSO) belongs to the category of algorithms based on global search. When the search starts, the convergence rate is relatively high. When it approaches the best solution of the whole, the convergence rate of its algorithm is relatively low, and sometimes it cannot meet the requirements. Therefore, such complementary advantages and disadvantages provide us with a way of thinking. If the two can be combined, local optimization can be avoided, while fast convergence can be achieved at the overall optimal point [20–22]. Particle swarm optimization belongs to the category of algorithms based on overall search. When the search starts, the convergence rate is relatively large. When it is close to the overall best solution, the convergence rate of the algorithm is relatively small, and sometimes it cannot meet the requirements. Therefore, the complementary advantages and disadvantages provide us with a way of thinking. If we can combine the two, we can avoid local optima and quickly converge at the overall optima.In the design, using the design idea of particle swarm, the BP algorithm is optimized through the initial weight and threshold so that the particles can search for the best solution vector in the weight and threshold, and then set the weight of the BP algorithm and the corresponding solution vector of the threshold, and train again. The detailed execution process is as follows: Set the search space dimension of particle swarm optimization algorithm to be equal to the total number of weights and thresholds in BP algorithm, and then the position to which the particle moves is a solution of the weight threshold. The fitness function of particle swarm is shown in the following equation:(9)f=1n∑j=1n∑k=1myk−tk2.In the above equation,n is the number of sample groups collected by training BP network, m is the number of neurons in the last layer of BP network, yk is the actual efferent value after input sample, and kt is the ideal efferent value. Given (9), the optimization process can be thought of as keeping f in the equation as small as possible. If the size of f during the operation of the algorithm is lower than the set stop quantity or the frequency of particle updating position exceeds the set stop number, the algorithm ends. At this point, the weight threshold represented by the optimal particle position is set as the initial weight threshold of the BP network, and then the BP neural network is trained.


## 3.5. Improved BP Neural Network Algorithm Flow

Step 1: set BP network parameters, such as the number of nodes at each layer. Set the number of individuals in the particle swarm, dimension (threshold number, weighted value number), and other parameters.Step 2: give the initial position of the particle, assign the corresponding value of the initial particle position to the neural network, calculate the value according to equation (6), and give the overall optimal position gbest and individual optimal position pbest.Step 3: reset the particle’s velocity and orientation according to equations (1)–(5).Step 4: after particle movement, if the current position is better thanpbest, then reset pbest to the current particle position. If it appears that the current position is better than gbest, the best position of the entire particle swarm, then gbest is reset to the current particle position.Step 5: check whetherf in equation (6) is lower than the set stop quantity or the frequency of particle updating position exceeds the set stop number, and go to the next step. If not, go back to Step 3.Step 6: set the weight threshold represented by the optimal particle position as the initial weight threshold of the BP network, and then train the BP neural network.


## 3.6. Dissolved Oxygen Improved BP Neural Network Prediction Model Simulation

The initial range of each particle is between [−1, 1]. According to the guidance of literature, the initial individual number of particle swarmm = 100, the minimum training stop error is set to 10−4, the maximum iteration number is set to 1000, and the learning factor starts to calculate c1 = 2.4861 according to formulas (7) and (8). c2=1.5139, wmax=0.9, wmin=0.4, vmax is set to 2, and ρ is set to 4. The training target precision is 10−5, and the training cycle times are set as 1000 times. Simulation results are shown in Figure 1.Figure 1
Improved neural network prediction results.As can be seen from the figure, the fitting effect of the improved neural network is very good, and the error is relatively small, which meets the standard of industrial application.


## 4. Design of the Lower Computer of the Sewage Monitoring System

### 4.1. Collecting System Hardware

According to the needs of the overall design scheme of intelligent monitoring in this study, and taking into account the characteristics of each technological process and equipment and facilities in this study, we considered the following points when selecting the collection equipment: First, the collection equipment selected in this study came from regular manufacturers, the industry has a good reputation in the after-sales service, its product quality is superior, and the product maintenance is guaranteed. Second, it is strictly economical, is not blindly demanding the high-end equipment, and, on the premise of ensuring the quality of monitoring, chooses more domestic brands. Then it is necessary to take into account the waterproof performance and corrosion resistance of hardware equipment; the composition of sewage is complex, and the equipment with good water and corrosion resistance effect can work stably. Hardware acquisition system was similar to human perception cells, mainly composed of instruments and sensors. With the booming of intelligent automation industry, its figure widely existed in various plant equipment so as to provide sensory information for monitoring personnel. Because this perceptual information was the basis of subsequent processing, the selection of instruments and other hardware equipment should be fully considered to ensure the effect.In this paper, the data collection instruments were mainly COD meter, total nitrogen, total phosphorus determination apparatus, suspended solid concentration meter, electromagnetic liquid flowmeter, PH dollars, thermometer, DO dissolved oxygen meter, and liquid level meter, and equipment was started by reading relay internal register [23].


### 4.2. Programmable Logic Controller (PLC)

The core of the lower system of this project was the programmable logic controller, and PLC was used to coordinate the actions of the whole lower system. PLC used its own receiving unit to receive digital or analog signals collected by hardware equipment such as field instruments and transmitted the signal from the upper computer to the lower actuator to control the action of the actuator. All signals must pass through its processing. All signals must pass through its processing and relay, so it is particularly important.After absorbing the advantages of previous products, the S7 PLC produced by Siemens in Germany integrates the world's most advanced information technology and scientific achievements, especially in processing speed, code running, error self-checking, and information communication. S7 series could be divided into S7-200 type, S7-300 type, and S7-400 type according to the number of input and output ports.Figure2 shows the Siemens PLC structure diagram, the hardware modules are relatively independent in layout, but cooperate closely with each other, which is conducive to distributed control, and is also convenient for expansion and maintenance. Programming Languages Multiple programming languages are supported. And supports a variety of communication protocols, fully adapting to the instruments and sensors for parameter collection of various lower computers in sewage plants.Figure 2
Siemens PLC structure drawing.


### 4.3. Communication System Design

The lower computer and the upper computer were connected by industrial Ethernet, which is the most extensive local area network based on the IEEE 802.3 standard and is widely recognized in the world. Comprehensive consideration of industrial Ethernet in quality, compatibility, transmission timeliness, data stability, robustness, attack prevention, and other aspects had been greatly improved. Considering the cost performance, transmission rate, and safety and reliability factors, 100 Mb/s ring network optical fiber industrial Ethernet was selected.Signals involving digital and analog quantities were directly connected to the input and output ports of the equipment on the corresponding module of PLC. Digital input and output signals were high- and low-level signals, PLC according to the transmission of high level or low level to monitor the state of the field equipment, switch, start and stop, and so forth, in this design was mainly through the relay to operate. Analog signal had two kinds: voltage and current signal; PLC accorded to the numerical conversion formula to convert input and output values [18].


### 4.4. Programming the Lower Computer

STEP7 development platform was developed by Siemens, which was specially applied to the configuration and programming debugging of PLC of its owned brand. The software function of STEP7 contained many development modules: process equipment management module, symbol table module, program module, and others. When writing the program, the user can choose to connect PLC or not to connect, which will not have a bad influence on the program effect. STEP7 platform could easily set up a complete set of industrial control system solutions. Figure3 shows the process of establishing the whole industrial control system solution. The programming languages used for S7-300 are Ladder Logic (LAD) programming language, Instruction List Language (STL), and Function Block Diagram (FBD). The Ladder Logic programming language is a unique graphical representation method of the STEP7 programming language. Its grammar rules have many similarities with the relay ladder logic diagram: for example, if information is transmitted to each connection and finally reaches the output, we can find the entire transmission process of the signal according to the diagram.Figure 3
Steps to create an automated project.The PID control program of the system used the PID controller function module FB41 integrated in STEP7 software, and the PID control program was stored in the timing cycle interrupt OB35. When the system starts, FB41 is called through OB35, and the background data block DB20 is created for the function module.The core control of the lower machine of the system is here. Firstly, the influent COD, suspended solid SS, total nitrogen content, total phosphorus content, flow rate, PH value, and aeration tank temperature were collected by the sensor and stored in the DB block of PLC. The communication network was transmitted to the upper computer, and the upper computer predicted the precise dissolved oxygen (DO) value through intelligent algorithm. It was transmitted down through the communication network and stored in DB block at the address of DB3.DBD208. The actual measured DO value in the aeration tank was also stored in DB block at the address of DB3.DBD32. DB3.DBD208 was connected with SP_INT of FB41 module in PLC (set value), and DB3.DBD32 was connected with PV_IN of FB41 module in PLC (current time value). The algorithm’s flow chart is shown in Figure4.Figure 4
Flow chart of DO control.


## 4.1. Collecting System Hardware

According to the needs of the overall design scheme of intelligent monitoring in this study, and taking into account the characteristics of each technological process and equipment and facilities in this study, we considered the following points when selecting the collection equipment: First, the collection equipment selected in this study came from regular manufacturers, the industry has a good reputation in the after-sales service, its product quality is superior, and the product maintenance is guaranteed. Second, it is strictly economical, is not blindly demanding the high-end equipment, and, on the premise of ensuring the quality of monitoring, chooses more domestic brands. Then it is necessary to take into account the waterproof performance and corrosion resistance of hardware equipment; the composition of sewage is complex, and the equipment with good water and corrosion resistance effect can work stably. Hardware acquisition system was similar to human perception cells, mainly composed of instruments and sensors. With the booming of intelligent automation industry, its figure widely existed in various plant equipment so as to provide sensory information for monitoring personnel. Because this perceptual information was the basis of subsequent processing, the selection of instruments and other hardware equipment should be fully considered to ensure the effect.In this paper, the data collection instruments were mainly COD meter, total nitrogen, total phosphorus determination apparatus, suspended solid concentration meter, electromagnetic liquid flowmeter, PH dollars, thermometer, DO dissolved oxygen meter, and liquid level meter, and equipment was started by reading relay internal register [23].


## 4.2. Programmable Logic Controller (PLC)

The core of the lower system of this project was the programmable logic controller, and PLC was used to coordinate the actions of the whole lower system. PLC used its own receiving unit to receive digital or analog signals collected by hardware equipment such as field instruments and transmitted the signal from the upper computer to the lower actuator to control the action of the actuator. All signals must pass through its processing. All signals must pass through its processing and relay, so it is particularly important.After absorbing the advantages of previous products, the S7 PLC produced by Siemens in Germany integrates the world's most advanced information technology and scientific achievements, especially in processing speed, code running, error self-checking, and information communication. S7 series could be divided into S7-200 type, S7-300 type, and S7-400 type according to the number of input and output ports.Figure2 shows the Siemens PLC structure diagram, the hardware modules are relatively independent in layout, but cooperate closely with each other, which is conducive to distributed control, and is also convenient for expansion and maintenance. Programming Languages Multiple programming languages are supported. And supports a variety of communication protocols, fully adapting to the instruments and sensors for parameter collection of various lower computers in sewage plants.Figure 2
Siemens PLC structure drawing.


## 4.3. Communication System Design

The lower computer and the upper computer were connected by industrial Ethernet, which is the most extensive local area network based on the IEEE 802.3 standard and is widely recognized in the world. Comprehensive consideration of industrial Ethernet in quality, compatibility, transmission timeliness, data stability, robustness, attack prevention, and other aspects had been greatly improved. Considering the cost performance, transmission rate, and safety and reliability factors, 100 Mb/s ring network optical fiber industrial Ethernet was selected.Signals involving digital and analog quantities were directly connected to the input and output ports of the equipment on the corresponding module of PLC. Digital input and output signals were high- and low-level signals, PLC according to the transmission of high level or low level to monitor the state of the field equipment, switch, start and stop, and so forth, in this design was mainly through the relay to operate. Analog signal had two kinds: voltage and current signal; PLC accorded to the numerical conversion formula to convert input and output values [18].


## 4.4. Programming the Lower Computer

STEP7 development platform was developed by Siemens, which was specially applied to the configuration and programming debugging of PLC of its owned brand. The software function of STEP7 contained many development modules: process equipment management module, symbol table module, program module, and others. When writing the program, the user can choose to connect PLC or not to connect, which will not have a bad influence on the program effect. STEP7 platform could easily set up a complete set of industrial control system solutions. Figure3 shows the process of establishing the whole industrial control system solution. The programming languages used for S7-300 are Ladder Logic (LAD) programming language, Instruction List Language (STL), and Function Block Diagram (FBD). The Ladder Logic programming language is a unique graphical representation method of the STEP7 programming language. Its grammar rules have many similarities with the relay ladder logic diagram: for example, if information is transmitted to each connection and finally reaches the output, we can find the entire transmission process of the signal according to the diagram.Figure 3
Steps to create an automated project.The PID control program of the system used the PID controller function module FB41 integrated in STEP7 software, and the PID control program was stored in the timing cycle interrupt OB35. When the system starts, FB41 is called through OB35, and the background data block DB20 is created for the function module.The core control of the lower machine of the system is here. Firstly, the influent COD, suspended solid SS, total nitrogen content, total phosphorus content, flow rate, PH value, and aeration tank temperature were collected by the sensor and stored in the DB block of PLC. The communication network was transmitted to the upper computer, and the upper computer predicted the precise dissolved oxygen (DO) value through intelligent algorithm. It was transmitted down through the communication network and stored in DB block at the address of DB3.DBD208. The actual measured DO value in the aeration tank was also stored in DB block at the address of DB3.DBD32. DB3.DBD208 was connected with SP_INT of FB41 module in PLC (set value), and DB3.DBD32 was connected with PV_IN of FB41 module in PLC (current time value). The algorithm’s flow chart is shown in Figure4.Figure 4
Flow chart of DO control.


## 5. Monitoring System Upper Computer Design

The application development of the upper computer was a very critical task in the intelligent sewage project. The upper computer collected all the information in sewage treatment, and the staff could monitor the sewage treatment site comprehensively through the upper computer in the control room, which not only reduced the amount of operator activity but also saved time. In this study, the key parameters of each process section of the factory should be displayed on the main interface first, and then the intelligent dissolved oxygen control algorithm should be integrated into the software and the parameters should be transmitted to the lower computer. The upper computer client software was developed on Visual Studio 2010 platform, and the data was stored and managed in SQL Server 2012 database. The development language was C#.


### 5.1. C# Communication Implementation

The design of the upper computer hardware used Yanhua brand industrial computer, with excellent performance, through the Ethernet link and Siemens S7-300 PLC to establish a connection. In this design, the IP address of PLC was set as 192.168.0.1. Communication mode was MODBUS/TCP mode of Ethernet network architecture, port number was set as MODBUS, corresponding to 502, and the specific configuration of C# program is as follows:?xml version = “1.0” encoding = “utf-8” ?<configuration><appSettings><!--Modbus TCP configuration--><add key = “IP” value = “192.168.0.1”/><add key = “Port” value = “502”/></appSettings></configuration>


### 5.2. Database Design

The database uses SQL Server 2012, which was mainly divided into three parts. The first part was the report data part, which mainly stored the periodically inserted real-time display data. The second part was the alarm data part, which contained various alarm related information. The third part was the user part, which contained the user related information. Redundant fields were added between each table to realize join query of each table. There were other secondary tables, of course, but only five tables that were closely related to business logic are detailed here. The process section table and data table, respectively, are shown in Tables2 and 3 [23].Table 2
Table of process sections.
Field nameTypeExplanationProcessIdIntProcess segment IDProcessNameStringName of process sectionTable 3
Table of data.
Field nameTypeExplanationDataIdIntdataIDDataNameStringData nameDataValueFloatData valueIsAlarmBoolTo alarm or not to alarmProcessIdIntProcess segment IDSampleTimeDatetimeData insertion timeThe alarm data part consists of two tables. The first is table of alarms, which displays alarm information, and the second is alarm settings table, and they are shown in Tables4 and 5, respectively.Table 4
Table of alarms.
Field nameTypeExplanationAlarmIdIntThe police IDAlarmDescStringThe police describedAlarmTimeDatetimeTime of fire alarmingIsDealBoolProcessed or notDealTimeDatetimeProcessing timeUserIdIntID of the login userTable 5
Table of alarm settings.
Field nameTypeExplanationDataNameStringData nameProcessIdIntProcess segment IDAlarmHighFloatAlarm upper limitAlarmLowFloatAlarm lower limitAlarmPRIIntPriorityThe table of users is shown in Table6.Table 6
Table of users.
Field nameTypeExplanationUserIdIntUserIDUserNameStringUser namePasswordVarchar (50)User passwordRoleTypeIntCharacter typesRoleNameStringRole name


### 5.3. Host Client

The user login module mainly checked the security of the users who entered the remote intelligent management system, so as to prevent the illegal users from misoperating the system or controlling the system illegally after logging in. After the login window was opened, only the legitimate user account could log in to the system. The legitimate user account was manually assigned by the administrator.The main interface after logging in is the real-time parameter display interface. By directly reading the PLCDB block, it can directly send data and detect key indicators of each process section, including liquid level, PH value, COD, SS, nitrogen and phosphorus content, influent water flow, temperature, whether the device is running, running status, etc.When the parameter exceeds the threshold or the device displays a fault, the C# program will execute to insert a data into the alarm table in the database, including the alarm date and time (accurate to second) and alarm information, and this data will be extracted by the program in the alarm management interface. The remarks field at the back of each data was manually operated by technicians. When the technicians debug and eliminate the fault, the processing button on the right of the list is manually clicked, and the fault status changes to processed. In this case, a piece of data is inserted into the UserId field of the alarm table in the database, namely, the login user name of the software platform. The value of UserId represents the fault handler, namely, the login user. The data was extracted and displayed in the handler column.The design and verification of the measurement model of dissolved oxygen in aeration tank were completed by testing and simulation on Matlab platform. For neural networks, which needed a lot of matrix calculation, Matlab modeling and simulation had twice the result with half the effort. At present, scholars at home and abroad in the field of neural network research also relied on Matlab simulation results for comparison. Therefore, the design and performance verification of the dissolved oxygen measurement model mentioned were all carried out in the Matlab environment. In practical application, the running results of Matlab could be called in Windows form written under VS platform through mixed programming and the predicted results could be displayed.


## 5.1. C# Communication Implementation

The design of the upper computer hardware used Yanhua brand industrial computer, with excellent performance, through the Ethernet link and Siemens S7-300 PLC to establish a connection. In this design, the IP address of PLC was set as 192.168.0.1. Communication mode was MODBUS/TCP mode of Ethernet network architecture, port number was set as MODBUS, corresponding to 502, and the specific configuration of C# program is as follows:?xml version = “1.0” encoding = “utf-8” ?<configuration><appSettings><!--Modbus TCP configuration--><add key = “IP” value = “192.168.0.1”/><add key = “Port” value = “502”/></appSettings></configuration>


## 5.2. Database Design

The database uses SQL Server 2012, which was mainly divided into three parts. The first part was the report data part, which mainly stored the periodically inserted real-time display data. The second part was the alarm data part, which contained various alarm related information. The third part was the user part, which contained the user related information. Redundant fields were added between each table to realize join query of each table. There were other secondary tables, of course, but only five tables that were closely related to business logic are detailed here. The process section table and data table, respectively, are shown in Tables2 and 3 [23].Table 2
Table of process sections.
Field nameTypeExplanationProcessIdIntProcess segment IDProcessNameStringName of process sectionTable 3
Table of data.
Field nameTypeExplanationDataIdIntdataIDDataNameStringData nameDataValueFloatData valueIsAlarmBoolTo alarm or not to alarmProcessIdIntProcess segment IDSampleTimeDatetimeData insertion timeThe alarm data part consists of two tables. The first is table of alarms, which displays alarm information, and the second is alarm settings table, and they are shown in Tables4 and 5, respectively.Table 4
Table of alarms.
Field nameTypeExplanationAlarmIdIntThe police IDAlarmDescStringThe police describedAlarmTimeDatetimeTime of fire alarmingIsDealBoolProcessed or notDealTimeDatetimeProcessing timeUserIdIntID of the login userTable 5
Table of alarm settings.
Field nameTypeExplanationDataNameStringData nameProcessIdIntProcess segment IDAlarmHighFloatAlarm upper limitAlarmLowFloatAlarm lower limitAlarmPRIIntPriorityThe table of users is shown in Table6.Table 6
Table of users.
Field nameTypeExplanationUserIdIntUserIDUserNameStringUser namePasswordVarchar (50)User passwordRoleTypeIntCharacter typesRoleNameStringRole name


## 5.3. Host Client

The user login module mainly checked the security of the users who entered the remote intelligent management system, so as to prevent the illegal users from misoperating the system or controlling the system illegally after logging in. After the login window was opened, only the legitimate user account could log in to the system. The legitimate user account was manually assigned by the administrator.The main interface after logging in is the real-time parameter display interface. By directly reading the PLCDB block, it can directly send data and detect key indicators of each process section, including liquid level, PH value, COD, SS, nitrogen and phosphorus content, influent water flow, temperature, whether the device is running, running status, etc.When the parameter exceeds the threshold or the device displays a fault, the C# program will execute to insert a data into the alarm table in the database, including the alarm date and time (accurate to second) and alarm information, and this data will be extracted by the program in the alarm management interface. The remarks field at the back of each data was manually operated by technicians. When the technicians debug and eliminate the fault, the processing button on the right of the list is manually clicked, and the fault status changes to processed. In this case, a piece of data is inserted into the UserId field of the alarm table in the database, namely, the login user name of the software platform. The value of UserId represents the fault handler, namely, the login user. The data was extracted and displayed in the handler column.The design and verification of the measurement model of dissolved oxygen in aeration tank were completed by testing and simulation on Matlab platform. For neural networks, which needed a lot of matrix calculation, Matlab modeling and simulation had twice the result with half the effort. At present, scholars at home and abroad in the field of neural network research also relied on Matlab simulation results for comparison. Therefore, the design and performance verification of the dissolved oxygen measurement model mentioned were all carried out in the Matlab environment. In practical application, the running results of Matlab could be called in Windows form written under VS platform through mixed programming and the predicted results could be displayed.


## 6. Conclusion

With population growth and water pollution becoming more and more serious, secondary treatment of sewage is an effective way to reduce water pressure and an important measure to control environmental pollution. Sewage problem is a major problem in China’s development; sewage treatment has risen to the national strategy. Design was based on improved artificial neural network; a new system of a set of automatic alarm intelligent monitoring and optimization for wastewater treatment equipment provides a new technical point of view, based on the advanced sewage treatment technology and sewage disposal characteristics, as well as the monitoring and optimization of demand, with the main ideology of physical information fusion and intelligent algorithm as the core. Combining information technology and communication technology to comprehensively monitor various parameters of the sewage plant, once the limit is exceeded, an alarm will be issued, so that the dissolved oxygen in the sewage treatment can be better controlled, so that the equipment of the plant runs smoothly and the effluent quality is better. The design work is summarized as follows:(1)
Using A2/O process, a new optimal control strategy for dissolved oxygen is designed for the key control of dissolved oxygen. Through a large number of experiments and combined with historical data, the intake index and dissolved oxygen value of aeration tank were obtained as samples under the condition of optimal outlet water. According to the samples, the neural network was trained to predict the optimal value of dissolved oxygen under different inlet water conditions. The improved BP neural network is improved by particle swarm optimization. Compared with the traditional BP neural network, the improved neural network has better characteristics.(2)
The sewage treatment in each process is based on the configuration sequence of the monitoring equipment, the design of the upper computer and the lower computer, the communication network between the lower computer and the sensor, and the design of the lower computer system is successfully realized through STEP7 PLC programming.(3)
C# in Visual Studio 2010 was used to develop the upper client platform, and the database used was SQL Server database. The platform realizes user login, real-time data display, overload and fault alarm, report query, and user management, and, through mixed programming, the dissolved oxygen prediction neural network written by Matlab is integrated in the upper computer platform. The parameter value of dissolved oxygen is set through the communication of upper and lower machine [24].



---

*Source: 6397478-2022-09-14.xml*