Share this

PID Controller Based on BP Neural Network and Simulation

2026-04-06 04:48:19 · · #1

1. Introduction
The PID (proportional-integral-derivative) controller has been the earliest practical controller for more than 50 years. It has been widely used in industrial process control and motion control because of its advantages such as simple algorithm, good robustness, high reliability and good intuitiveness [1]. The quality of conventional PID control depends not only on the accuracy of the control system model, but also on the relationship between the three parameters, which is not necessarily a simple linear combination. Actual industrial processes and motion processes often have uncertainties such as time-varying, variable parameters, and variable structure, as well as strong nonlinearity. It is difficult to establish an accurate mathematical model. In addition, conventional PID has disadvantages such as difficulty in online adjustment, mutual influence between parameters, and long parameter tuning time, making it difficult to achieve ideal control effect.
With the development of control theory, combining the widely used PID controller with intelligent control theory [2] has become a new direction in intelligent control research. Neural network algorithms have the ability to approximate any nonlinear expression, strong self-learning ability and generalization ability, and have great potential in solving highly nonlinear and uncertain systems. By applying neural networks, the best linear combination can be sought from the complex combination of the three parameters of PID, so that the neural network and PID are essentially combined. This makes the controller have better adaptability, realizes automatic real-time adjustment of parameters, adapts to changes in the process, and improves the robustness and reliability of the system.
2. Backpropagation (BP) neural network
2.1 Structure and Design of BP Neural Network [3]
A backpropagation (BP) neural network is a type of neural network with three or more layers, including an input layer, hidden layers, and an output layer. Layers are fully connected, but neurons within each layer are not connected. When a pair of training samples is provided to the network, the activation values ​​of neurons propagate from the input layer through each intermediate layer to the output layer, where each neuron receives the network's input response. Next, following the direction of reducing the error between the target output and the actual output, the connection weights are adjusted layer by layer from the output layer through each intermediate layer, finally returning to the input layer. This algorithm is called the BP algorithm. As this inverse error propagation and correction continues, the accuracy of the network's response to the input pattern continuously increases.
(1) Design of input/output layer
The design of the input layer can be determined based on the problem to be solved and the data representation. If the input signal is an analog waveform, the dimension of the input unit can be determined based on the number of sampling points of the waveform, or a single unit can be used as the input sample, which is a time series of samples. The dimension of the output layer can be determined according to the user's requirements. If the BP network is used as a classifier, and there are m class patterns, then the number of neurons in the output layer is m or...
(2) Design of hidden layers
The number of hidden layer units is directly related to the requirements of the problem and the number of input/output units. Too many hidden units can lead to excessively long learning times, suboptimal error, poor fault tolerance, and inability to recognize previously unseen samples. Therefore, there must exist an optimal number of hidden units, which is usually selected using the following three formulas:
1), where k is the number of samples and n is the number of input units.
2), where m is the number of output neurons, n is the number of input units, and a is a constant between [1, 10].
3), where n is the number of input units.
2.2 Typical Neural Network Structure A typical three-layer neural network structure is shown in the figure below:

Figure 1. BP neural network structure diagram


Where: , , ..., are the inputs of the BP network; , , ..., are the outputs of the BP network, corresponding to the three parameters of the PID controller; is the connection weight from the input layer to the hidden layer; is the connection weight from the hidden layer to the output layer. Through the self-learning of the neural network and the adjustment of the weighting coefficients, the output of the neural network corresponds to the PID controller parameters under a certain optimal control law.
The relationship between the parameters in Figure 1[4] is as follows:
Input layer:

Hidden layer:
Output layer:
The performance metric is set as follows: The weights of the network are then adjusted using the gradient descent method to minimize them. The adjustment method is as follows:
Hidden layer:
Output layer:
3. Neural Network PID Controller and Control Algorithm

1. The structure of the BP neural network PID controller is shown in the figure below:

Figure 2. Neural network controller structure diagram

As shown in the diagram, the controller consists of two parts: a conventional PID controller and a neural network. The conventional PID controller directly performs closed-loop control on the controlled object, and its control parameters Kp, Ki, and Kd are adjusted online. The neural network adjusts the parameters of the PID controller based on the system's operating state to achieve optimal performance, ensuring that the output of the output layer neurons corresponds to the three adjustable parameters of the PID controller. Through self-learning and adjustment of the weighting coefficients, the neural network output corresponds to the PID controller parameters under a specific optimal control law.
2. Control Algorithm The control algorithm of neural network PID[5] is as follows:
(1). Determine the structure of the neural network, that is, determine the number of input nodes and the number of hidden layer nodes, and give the initial values ​​of the weighting coefficients of each layer, and select the learning rate and inertia coefficient, and let k = 1;
(2). Sample r(k) and y(k), and calculate the error at the current time, error(k) = r(k) - y(k);
(3). Calculate the input and output of each neural network. The output of the output layer is the three control parameters Kp, Ki, and Kd of the PID controller.
(4) Calculate the output of the PID controller;
(5) Perform neural network learning, adjust the weighting coefficients online, and achieve adaptive adjustment of PID control parameters;
(6). Let k = k + 1, and return to step (1).
4. Simulation Examples
4.1 Controlled Object Let the approximate mathematical model of the controlled object be: , and the selected input signal be a time-varying signal:
The neural network uses a 4-5-3 structure, a learning rate of 0.55, an inertia coefficient of 0.04, and initial values ​​for the weighting coefficients are random numbers in the interval [-0.5, 0.5]. The sampling frequency is 1000Hz.
The Matlab simulation results are shown in Figure 3:

Figure 3-1 Input-output curves

Figure 3-2 Error Curve

4.2 Simulation Result Analysis
As can be seen from the simulation curves, the neural network PID has a small steady-state error, which solves the problems of overshoot and jitter of conventional PID. It has high control accuracy, achieves almost identical tracking of control signals, and has good speed and adaptability.
5. Conclusion
The neural network PID controller combines the essence of two algorithms. Leveraging the self-learning and self-organizing capabilities of neural networks, it enables online adjustment of PID parameters, resulting in good controller adaptability. This algorithm does not require a precise mathematical model of the controlled object, expanding its application scope and providing excellent control performance. Furthermore, with a properly chosen neural network structure, the algorithm exhibits strong generalization ability. Based on these advantages, the neural network PID controller has excellent prospects for development and application.


References
[1] Wen Liang, Fu Xingwu. Research and simulation of neural network PID in temperature control system[J]. Microcomputer Information, 2004(7):3-4.
[2] Yi Jikai. Intelligent Control Technology [M]. Beijing: Beijing University of Technology Press, 1999: 95-138
[3] Neural Network Theory and MATLAB 7 Implementation [M]. Beijing: Electronic Industry Press, 2005.
[4] Wu Wei, Yan Mengyun, Wei Hangxin. PID control based on neural network and its simulation, Modern Electronics Technology, 2009
[5] Liu Jinkun. Advanced PID Control and Its MATLAB Simulation [M]. Beijing: Electronic Industry Press, 2003.

Read next

CATDOLL 139CM Sasha Silicone Doll

Height: 139 Silicone Weight: 25kg Shoulder Width: 33cm Bust/Waist/Hip: 61/56/69cm Oral Depth: N/A Vaginal Depth: 3-15cm...

Articles 2026-02-22