Design of Stability Algorithm for Single-stage Inverted Pendulum Control System

Publisher:美梦小狮子Latest update time:2012-03-14 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The inverted pendulum is an abstract model of many control problems in daily life with the center of gravity at the top and the fulcrum at the bottom. It is a naturally unstable body. It can effectively reflect many abstract and critical problems in the control process, such as the nonlinearity, controllability, and robustness of the system. The control of the inverted pendulum system is to make the trolley and the pendulum reach the expected equilibrium position as quickly as possible, and also to prevent them from having too strong oscillation amplitude, speed, and angular velocity. When the inverted pendulum system reaches the expected position, the system can overcome a certain range of disturbances and maintain balance. As a control device, it has the characteristics of intuitive image, simple structure, and easy simulation and realization of various different control methods. As a controlled object, it is a high-order, nonlinear, multivariable, strongly coupled, unstable and fast system. Only by taking effective methods can its stability effect be clear. Therefore, the study of the inverted pendulum has also become a long-lasting research topic in control theory.

1 Mathematical model of the primary inverted pendulum system

For the inverted pendulum system, if air resistance and various frictions are ignored, the linear first-order inverted pendulum system can be abstracted into a trolley moving along a smooth guide rail and a uniform pendulum connected by a bearing, as shown in Figure 1. Among them, the mass of the trolley is M=1.32 kg, the mass of the pendulum is m=0.07 kg, the distance from the center of mass of the pendulum to the center of rotation is l=0.2 m, the angle between the pendulum and the vertical downward direction is θ, and the sliding friction coefficient of the trolley is fc=0.1.

First-stage inverted pendulum system

There are two general methods to establish the mathematical model of the inverted pendulum control system: using the analytical method of Newtonian mechanics and the Lagrange equation modeling in analytical mechanics. This paper adopts the Lagrange equation modeling.

The Lagrange equation of the first-order inverted pendulum system should be:

formula

Where: L is the Lagrangian operator; V is the kinetic energy of the system; G is the potential energy of the system.

formula

Where: D is the system dissipated energy; fi is the external force of the system on the i-th generalized coordinate.

The total kinetic energy of the primary inverted pendulum system is:

formula

The primary inverted pendulum system has four state variables, namely

formula

formula

, write the system state equation according to formula (7), and perform linearization at the equilibrium point to obtain the state space model of the system as follows:

formula

2 Inverted Pendulum Performance Analysis

The controllability of the system is the premise of controller design, so the controllability analysis of the system is carried out before design. According to the controllability matrix T0=[B, AB, A2B, A3B], using the rank command in Matlab, it can be obtained that rank(T0)=4. It can be seen that the system is completely controllable, so the controller of the system can be designed to make the system stable.

3 Design of LQR controller

3.1 LQR controller principle

The control object of the linear quadratic regulator is a linear system, which must be in the form of a state space, namely:

formula

, Y=Cx+Du. By determining the matrix K of the optimal control quantity U*=R-1BTPX=-KX, the performance index

formula

The value of is extremely small. Among them, the weighted matrices Q and R are used to balance the weights of state variables and input variables; P is the solution of the Riccati equation. At this time, solve the Riccati algebraic equation:

formula

The P value and the optimal feedback gain matrix K value can be obtained:

formula

The schematic diagram of LQR for a single-stage pendulum is shown in Figure 2.

Schematic diagram of LQR for single-stage pendulum
3.2 Selection of weight matrices Q and R

When selecting Q and R, the following aspects are mainly considered:

(1) Q is a positive definite or semi-positive definite matrix, and R is a positive definite matrix.

(2) The elements on the diagonal of the Q matrix correspond one-to-one to the state variables. The larger the value, the more significant the impact of the state variable on the system.

(3) The weighting matrix R should not be too small, otherwise it will lead to an increase in the control amount. If the control amount is too large, it will exceed the capacity of the system actuator. The R matrix should not be too large, otherwise the control effect will be too small and affect the control performance.

Considering the above, we take Q=diag([100, 100, 100, 100]), R=1, and use the LQR function provided by Matlab to get the controller gain matrix:

K=[-10.000 0 -24.140 8 250.036 0 158.553 3]

3.3 Using genetic algorithm to optimize Q matrix

Genetic algorithm is a random search algorithm based on the principle of natural selection and natural genetic mechanism in the biological world. It simulates the life evolution mechanism in the biological world and is used in artificial systems to achieve the optimization of specific goals.

The specific steps of using genetic algorithm to optimize the weighted matrix Q are as follows:

(1) Select an encoding strategy to convert parameters into chromosome structure space.

(2) Determine the decoding method.

(3) Determine the type and mathematical description form of the optimization objective function, and take the objective function J in LQR optimal control, J = trace(P).

(4) Design genetic operators.

(5) Determine the genetic strategy. Set the population size to 80, the maximum number of iterations to 200, the crossover probability to 0.9, the mutation probability to 0.01, and generate the initial population randomly.

(6) Calculate the fitness value of the individuals or chromosomes in the population after decoding. In this design, the fitness value is taken as the inverse of the objective function value, that is, f=1/J.

(7) Perform the genetic algorithm search process, that is, use the random sampling method to select individuals, generate new individuals through crossover and mutation, and then calculate the objective function value J' of the new individuals.

(8) Determine whether the group performance meets the indicator or whether the number of iterations has been completed. If not, repeat step (7).

The above algorithm can be used to determine the value of the element to be optimized in the weighted matrix Q that minimizes the objective function value, thereby determining the vector K of the feedback control law.

4 Simulation Results and Analysis

When Q=diag([100, 100, 100, 100]) and R=1, the obtained first-order inverted pendulum simulation waveform is shown in Figure 3. As can be seen from the figure, the car reaches equilibrium after 5.2 s, and the pendulum angle reaches equilibrium after 6.5 s. After optimizing the Q array, the system response overshoot is reduced, the response speed is accelerated, the adjustment time is reduced, and the static and dynamic characteristics of the system are improved, as shown in Figure 4.

Simulation waveform

5 Conclusion

This paper uses the Lagrange equation to establish a mathematical model of the linear first-order inverted pendulum control system, analyzes the performance of the system on this basis, and uses the LQR controller to control it. The results show that the LQR controller has a good control effect on the system.

Reference address:Design of Stability Algorithm for Single-stage Inverted Pendulum Control System

Previous article:Application of ESP904 in ROV control system
Next article:Design of DMA controller adapting to various timings

Latest Analog Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号