You are on page 1of 4

2011 Second International Conference on Digital Manufacturing & Automation

Double Inverted Pendulum Control Based on Three-loop PID and Improved BP Neural Network
Yingjun Sang1,2 Yuanyuan Fan1,3* Bin Liu1
1. Faculty of Electronic and Electrical Engineering, Huaiyin institute of technology, Huaian, jiangsu, 223003, China 2. Electrical Engineering School, Southeast University, nanjing, jiangsu, 210096, china 3.Changchun institute of optics, fine mechanics and physics, Chinese academy of sciences Changchun, jilin, 130033, china fyuanyuan123@163.com
AbstractTo deal with the defects of BP neural networks used in balance control of inverted pendulum, such as longer train time and converging in partial minimum, this article realizes the control of double inverted pendulum with improved BP algorithm of artificial neural networks(ANN), builds up a training model of test simulation and the BP network is 6-10-1 structure. Tansig function is used in hidden layer and Purelin function is used in output layer, LM is used in training algorithm. The training data is acquried by three-loop PID algorithm. The model is learned and trained with Matlab calculating software, and the simulink simulation experiment results prove that improved BP algorithm for inverted pendulum control has higher precision, better astringency and lower calculation. This algorithm has wide application on nonlinear control and robust control field in particular. Keywords-artificial neural networks; improved back propagation algorithm; double inverted pendulum; three-loop pid

parallel processing and self-learning ability, and etc.. In recent years, a variety of ANN models have been proposed for in-depth study, 80% to 90% of which, is BP network or its modified form, BP network is the core of the forward network, reflecting the most essential part of the network[2]. Standard BP network adopts gradient descent algorithm, based on the Widrow-Hoff rule, and composed by two parts, the information signal forward-propagation and the error signal backward-propagation. The flow chart of BP algorithm is shown as Fig.1. Weight Initialization Input samples and calculate the output Calculate Output Error Select stride Fix output layer weights Fix hidden layer weights Do any samples have not been studied?
Y

Finish E=0
N Y

E<Emax
N

I.

INTRODUCTION

Inverted pendulum system is time-varying, nonlinear and strongly coupled, multivariable and natural unstable system, in the control process, it can effectively reflect the key problems of control such as the stabilization, robustness, and tracking quality, and is the ideal test model for a variety of control theory. The control objective is the pendulum does not fall, the car stopped. BP artificial neural network algorithm, in the case of multi-variable input, has the advantages of high precision, fast control, simple calculation, good robustness, etc., so this method is suitable to meet the requirements of the inverted pendulum system [1]. In this article, a modified BP artificial neural network algorithm is proposed to control the linear double inverted pendulum, it reduces training time of neural networks, and achieves faster convergence, higher accuracy, better control effect. II. ARTIFICIAL NEURAL NETWORK ALGORITHM Artificial neural network (ANN) becomes to be more and more widely applied in information processing, pattern recognition, intelligent control, system modeling and other areas, due to the merits of information distribution storage,
*Corresponding author. E-mail addresses: sangyingj@163.com(Y.Sang), fyuanyuan123@163.com(Y.Fan).

Figure 1. The flow chart of BP algorithm

But the BP network are of its own limitations, such as a longer training time, converge to local minima, etc., which makes that BP algorithm is not capable of performing everywhere in the practical application[3]. A lot of improvements for BP algorithm have been done recent years, there are two main types of improvements: one is heuristic techniques, such as additional momentum, adaptive learning rate method; the other is digital optimization techniques, such as the conjugate gradient method, QuasiNewton method, Levenberg-Marquardt (LM) method[4]. LM algorithm has the fastest convergence higher accuracy and better effect compared with other algorithms [5] after the analysis of a large number of simulation experiments, so this article adopts LM algorithm to train network. LM optimization weight and threshold updating formula is as follow [6]:

X k +1 = X

( J T J + I ) 1 J T e

(1)

978-0-7695-4455-7/11 $26.00 2011 Crown Copyright DOI 10.1109/ICDMA.2011.118

456

Where J is the Jacobian matrix from the differential of error to weight value, e is the error vector, is a scalar. Dependent on the magnitude of , the method changes smooth between two extremes: the Newton method (when 0) and the well-known steepest descent method (when ). LM optimization method can make a shorter learning time, bring better effect in practical applications. However, for complex problems, this method requires a lot of memory. Toolbox in MATLAB is a good way to solve this problem. The training function of LM optimization trainlm.m in the MATLAB toolbox is used, the training parameters are: the number of training epochs, the training step show, the error function index goal, the training time time, the minimum gradient min-grad, the memory reducing coefficient mem-reduc, the initial value of , and increasing factor, reduction factor and the maximum value, etc. . III. MATHEMATICAL MODEL OF LINEAR DOUBLE
INVERTED PENDULUM

2
1

Figure 2. Physical model of linear double inverted pendulum

IV.

PID AND NEURAL NETWORK CONTROLLER DESIGN

The linear double inverted pendulum of Googol Technology Ltd. is chosen as control object for the experiment, the physical model is shown in Fig.2. To simplify the system, the air resistance and a variety of friction have been ignored in modeling, and think the pendulum as a rigid body. Mathematical model of double inverted pendulum can be obtained according to principles of dynamics and kinematics , and the linearization near the equilibrium position makes possible to obtain the system state equation. The state variable is x1, x2, x3, x4, x5, x6, xi(i=1,...,6) has the respective expression, x1 is car displacement, x2 is the lower pendulum angle, x3 is the higher pendulum angle, x4 is cart velocity, x5 is the lower pendulum angular velocity, x6 is the higher pendulum angular velocity.

x1 0 0 1 0 x 0 0 2 0 0 x3 0 0 0 0 = 0 0 x4 0 0 x 0 86.69 21.62 0 5 0 40.31 39.45 0 x6

0 x1 0 1 0 x 2 0 0 1 x 3 0 u + 0 0 x 4 1 6 . 64 0 x 0 5 0 0 0.088 x6 x1 x 2 x 1 1 0 0 0 0 0 0 x 3 y = x 2 = 0 1 0 0 0 0 + 0 u x 4 0 0 0 1 0 0 0 x 3 x5 x6
0

A. Training sample selection and the parameters setting BP neural network can only be used as a system controller with a lot of training. The number of training samples has great influence on the training results, the more the number of samples, the more accurate the results of network training, but the running time increases, the computational cost is also higher, so the reasonable choice of sample data is very important. In the actual simulation, we choose three PID control loop for the BP network as the learning teachers, when the number of training samples is 2000, the test results are more reasonable, and the sample data reflects the basic characteristics of the system, the simulation results can be expected. Integral control does not properly apply to inverted pendulum control [7], so we use PD control strategy, which adopts the PD-PD-PD three-loop control scheme. The three-loop control system structure is shown as Fig.3. Use pole placement method of State feedback control system to determine the 6 PID controller parameter value[8]. When the point P=[-25i -54i -86i], using MATLAB pole placement functions place, it can be obtained, K1=46.6543K2=79.4287K3=-158.921 K4= 25.2789K5=1.0506K6=-25.7195
positi on n e x' = Ax+Bu y = Cx+Du State-Space Gain1 K1 K2 Gain2 Gain3 K3 K4 Gain4 Gain5 K5 K6 Gain6 du/dt Derivative3 du/dt Derivative2 du/dt Derivative1 angl e1 angl e2 Scope

Figure 3. Control system structure diagram

457

B. BP network structure the parameters setting Before the BP network design, the network layer number, each layer neuron number, the initial values, and learning methods is to be considered usually, . Increasing the number of layers can further reduce errors, improve accuracy, but bring the complexity of the network, while increase the number of hidden layer neurons can also improve precision, and easier to observe and adjust the training effect. To make the error as small as possible, a reasonable initial weights and bias selection is needed because if too large it is, the training easily get into the saturated zone, and leading to a halt, the uniform distribution decimal, between (-1,1), are generally chosen as the initial weight value. As the network initialization, 0.5 * rands function is chosen to initialize the weight value of BP network, the initial weight value is selected between (-0.5,0.5), select 0.0001 as the training target error, a maximum of training times is 5000. According to performance comparison of several simulation experiments, select the single hidden layer neural network of 6-10-1, the three-layer BP network architecture is shown as Fig.4. Tansig and purelin function are chosen for hidden layer and output layer respectively, simulation results show that the variable learning rate training algorithm takes a long time for training and the system is divergent, so it can not effectively control the inverted pendulum, while using the LM training algorithm can get a better control effect. In the actual simulation process, BP network training objectives achieved through 41 times. The network training code is as follow, and the net=newff(minmax(PP),[10,1],{'tansig','purelin'},'trainlm'); net.trainParam.epochs=5000; net.trainParam.show = 20; net.trainParam.goal = 0.0001; net.iw{1,1}=0.5*rands(10,6); net.b{1}=0.5*rands(10,1); net.lw{2,1}=0.5*rands(1,10); net.b{2}=0.5*rands(1,1); [net,tr]=train(net,PP,TT); y=sim(net,PP);

PID algorithm are shown as Fig.6, where the yellow line is improved BP algorithm simulation curve, the red line is the three-loop PID algorithm simulation curve. The simulation results show that improved BP algorithm has high precision, fast speed, good robustness, compared to the three-loop PID control, and the inverted pendulum car can achieve stable state just 2.5s under the improved BP algorithm, and the overshoot very small, which meet the requirements of the system.

Figure 5. BP network training error curve

i i i

i i i

Figure 6. Simulation curve comparison chart of the car displacement, the lower pendulum, the higher pendulum, and the control force under two algorithms

Figure 4. Three-layer BP network architecture

VI.

CONCLUSION

V.

BP NETWORK TRAINING RESULTS

The BP network training error curve is shown as Fig.5, we can see that training effect get better as the training times increase and achieve the black goal curve at 41 times. The simulation curve of the car displacement, the lower pendulum angle, the higher pendulum angle, and the control force under improved BP algorithm and under three-loop

In this paper, an improved BP artificial neural network is applied to the inverted pendulum balance control, on the basis of BP artificial neural network algorithm analysis, the simulation experiment of linear double inverted pendulum control under improved BP algorithm has been carried out. Simulation results show that the improved BP algorithm has good convergence, small computation, especially has a good prospect in the fields of nonlinear and robust control. BP neural network theoretically can

458

approximate any nonlinear function, so it is particularly suitable for the serious non-linear, multivariable inverted pendulum system control. ACKNOWLEDGMENT This work is a Project Supported by Huaiyin Institute of Technology Science Research Foundation (HGC0906). REFERENCES
[1] Yu Xiu-fen, Duan Hai-bin, Gong Hua-jun, Research for Inverted Pendulum Control Based on BP Algorithm of ANN, Measurement & Control Technique, Vol.22, No.3, 2003, pp. 41-44. (in Chinese) Zhang Zhi-hua, Zhu Zhang-sen, Li Ru-bing, Some Adaptive Modified Learning Algorithms of Neural Network and their Applications, Earth ScienceJournal of China University of Geosciences, Vol.23, No.2, 1998, pp. 179-182. (in Chinese) Yuan Zeng ren, Artificial neural network and its applications, Tsinghua University Press, 1999.131273. (in Chinese)

[4]

[5]

[6]

[7]

[2]

[8]

Su Gao li, Deng Fang ping, On the Improving Backpropagation Algorithms of the Neural Networks Based on MATLAB Language:A Review, Bulletin of Science and Technology, Vol.19, No.2, 2003, pp. 130-135. (in Chinese) Chen Liu Hao, Studying and Summarizing of BP Neural Network, Computer Knowledge and Technology, Vol.6, No.36, 2010, pp. 10364-10365. (in Chinese) Hagan, M.T ,Menhaj, M.B, Training feedforward networks with the Marquardt algorithm, IEEE Transactions on Neural Networks , Vol.5, No.6, 1994, pp. 989-993, doi:10.1109/72.329697 Yang Ping, Xu Chun Mei, etc., PID Controller of Inversed Pendulum Real-time Control System, Control & Automation, Vol.22, No.7-1, 2006, pp. 83-85. (in Chinese) Yang Ping, Xu Chun Mei, He Mao Kang, Yang Si Lin, Wang Qian, PID Real-time Control for A Linear Double Inversed Pendulum System, Journal of Shanghai University of Electric Power, Vol.24, No.3, 2008, pp. 236-247. (in Chinese)

[3]

459

You might also like