
The Control of an Inverted Pendulum AAE 364L This experiment is devoted to the inverted pendulum. Clearly, the inverted pendulum will fall without any control. We will design a controller to balance the pendulum upright. Figure 1: The inverted pendulum. This experiment consists of a cart with mass Mc on a one dimensional track with a pendulum attached to the cart. The pendulum starts in the upward position. The cart is driven by a force from a servo motor. The position of the cart is denoted by xc(t), and the Voltage to the servo motor is denoted by v(t). The angle between the pendulum and its vertical or upright position is denoted by α; see Figure 1. The nonlinear equations of motion 1 are given by 2 2 2 2 2 (Mc + Mp)Ip + McMplp + Mp lp sin(α) x¨c + Ip + Mplp Beqx˙ c 2 3 2 2 2 2 = −MplpBp cos(α)˙α − Mp lp + IpMplp sin(α)˙α + Ip + Mplp Fc + Mp lpg cos(α)sin(α); 2 2 2 2 (Mc + Mp)Ip + McMplp + Mp lp sin(α) α¨ +(Mc + Mp) Bpα˙ 2 2 2 = (Mc + Mp) Mpglp sin(α) − Mplp cos(α)Beqx˙ c − Mp lp sin(α)cos(α)˙α + Mplp cos(α)Fc; ηgKgηmKt (vrmp − KgKmx˙ c) Fc = 2 . (0.1) Rmrmp Here Fc is the force on the cart. The notation and values are given in the table in the Appendix. These values are given also given in the MATLAB file “setup lab ip01 2 sip.m” posted on the Web page for the course. So you do not have to calculate any of these values for the Lab. The linearized equations of motion about α = 0 are determined by 2 2 2 2 Mp lpgα − (Ip + Mplp)Beqx˙ c − MplpBpα˙ +(Ip + Mplp)Fc x¨c = 2 (Mc + Mp)Ip + McMplp (Mc + Mp)Mpglpα − (Mc + Mp)Bpα˙ − MplpBeqx˙ c + MplpFc α¨ = 2 (Mc + Mp)Ip + McMplp ηgKgηmKt (vrmp − KgKmx˙ c) Fc = 2 . (0.2) Rmrmp Now let us convert the linear equations to a state space model of the form x˙ = Ax + Bv. Here A is a 4 × 4 matrix, B is a column vector of length 4 and the input v is the voltage to the motor. To convert the system in (0.2) to state space we will use the following state variables: x1 xc x α x = 2 = . (0.3) x3 x˙ c x4 α˙ By consulting the values in the table in the Appendix, we computed A and B, that is, 00 1 0 0 00 0 1 0 A = and B = . (0.4) 0 1.5216 −11.6513 −0.0049 1.5304 0 26.1093 −26.8458 −0.0841 3.5261 It is emphasized that this A and B in (0.4) is computed for the IP02 cart with the 0.37 kg weight attached and the long pendulum. The matrices A and B will change if we take off the weight or switch to the medium pendulum. The matrices A and B in (0.4) are contained 2 in the MATLAB setup file “setup lab ip01 2 sip.m” posted on the course Web page. So you do not have to retype A and B in MATLAB. Because the inverted pendulum is unstable and the state equationx ˙ = Ax + Bv is the linear approximation for the inverted pendulum, the matrix A is unstable. In fact, the eigenvalues for A are given by eig(A)= {0, 4.8231, −12.0133, −4.5452}. (0.5) As expected, A is unstable. Let us compute the transfer function from the voltage v to the output xc. Since x1 = xc, the corresponding output matrix C is given by C = 1000 . (0.6) By using ss2tf in MATLAB, we see that the transfer function from the voltage v to the position xc of the cart is given by X (s) 1.53s2 +0.1114s − 34.59 c = C(sI − A)−1B = . (0.7) V (s) s4 + 11.74s3 − 25.26s2 − 263.4s Notice that this is a fourth order system. Because the denominator contains terms with Xc(s) negative coefficients, it follows that the transfer function V (s) is unstable. In fact, the Xc(s) Xc(s) poles of V (s) are the eigenvalues of A. In other words, the poles of V (s) are given by Xc(s) eig(A)= {0, 4.8231, −12.0133, −4.5452}. Therefore V (s) is unstable. Now let us compute the transfer function from the voltage v to the angle α. Since x2 = α, the corresponding output matrix C is given by C = 0100 . (0.8) By using ss2tf in MATLAB, we see that the transfer function from the voltage v to the angle α is determined by α(s) 3.526s = C(sI − A)−1B = . (0.9) V (s) s3 + 11.74s2 − 25.26s − 263.4 Finally, it is noted that this is an unstable third order system. The displacement of the end of the pendulum along the track is given by xe = xc + Lp sin(α) where Lp is the length of the pendulum; see Figure 1. (Notice that lp is the distance to the center of mass of the pendulum and Lp is the distance to the end of the pendulum.) For small angles xe ≈ xc + Lpα. Since x1 = xc, x2 = α and Lp =0.6413 m, the output matrix C corresponding to xe is given by C = 1 0.6413 0 0 . (0.10) By using ss2tf in MATLAB we see that the transfer function from the voltage v to the end of the pendulum xe is determined by X (s) 3.792s2 +0.1114s − 34.59 e = C(sI − A)−1B = . (0.11) V (s) s4 + 11.74s3 − 25.26s2 − 263.4s Finally, it is noted that this is an unstable fourth order system. 3 1 The linear quadratic regulator You can use pole placement to design a feedback controller for the inverted pendulum. One disadvantage of the pole placement procedure is that placing the poles at a desired location can lead to large gains. In this section, we will present the linear quadratic regulator (LQR) problem, and show how one can use the LQR for control design. It turns out that in many instances, the LQR method is superior to the pole placement method. Finally, you can choose either pole placement or LQR for your control design of the inverted pendulum. In fact, you can use any control method that you want as long as it works. However, we believe you will discover that the LQR method will work very nicely for the inverted pendulum. Now let us present the linear quadratic regulator (LQR) method. The proof behind the LQR is given in A&AE 564. Here we will just use MATLAB to design a LQR controller. To set up the LQR problem, consider a controllable state space system of the form x˙ = Ax + Bv. (1.1) Here A is a n × n matrix and B is a column vector of length n and the state x1 x2 x = . . x n is a vector of length n. Let R> 0 and Q be a diagonal matrix of the form q1 0 ··· 0 0 q2 ··· 0 Q = . , (1.2) . .. 0 0 ··· q n where qj ≥ 0 for all j. Now consider the optimization problem ∞ ∞ n ∗ 2 2 2 min x Qx + Rv dt = min qjxj + Rv dt Z0 Z0 j=1 ! X subjecttox ˙ = Ax + Bv. (1.3) (The conjugate transpose of a vector z is denoted by z∗.) The control engineer chooses the n weights {qj}1 and R> 0. It is emphasized that the weight R must be strictly positive. The optimal control v or solution to this optimization problem is unique and given by v = −Kx where K is a state gain matrix, that is, K is a row matrix of length n. The MATLAB command to compute K is given by K = lqr(A, B, Q, R). (1.4) In this case, the closed loop system corresponding to the optimal control v = −Kx is given by x˙ =(A − BK)x. 4 Finally, it is noted that A − BK is stable. n The state weights {qj}1 are chosen to emphasize the response of certain states, while the control weight R is chosen to select how much control effort v is used to solve the optimization problem in (1.3). For example, if q1 and q3 are large, then the weights q1 and q3 are placing a large penalty on the states x1 and x3, that is, if x1 or x3 is large, then the large weights q1 and q3 will amplify the effect of x1 or x3 in the optimization problem. Since the optimization ∞ n 2 2 problem is trying to minimize 0 j=0 qjxj + Rv dt, the optimal control v must force the states x and x to be small. So if q and q are large, then the control designer is trying 1 3 R P 1 3 to make the states x1 and x3 small and places less emphasis on how the other states respond. n If the control weight R is large relative to {qj}1 , then the weight R is placing a large penalty on the control effort v, that is, if the control v is large, then the large weight n R relative to {qj}1 will amplify the effect of the control v in the optimization problem. ∞ n 2 2 Since the optimization problem is trying to minimize 0 j=0 qjxj + Rv dt, the optimal control v must be small in order to solve the optimization problem in (1.3).
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages14 Page
-
File Size-