Sie sind auf Seite 1von 21

LAB 5 : INVERTED PENDULUM USING STATE-SPACE METHOD 1.0 OBJECTIVE i. ii. iii. iv.

To determine the discrete state-space for inverted pendulum. To check the controllability and observability in inverted pendulum system. To determine control design via pole placement with adding reference input of full-state feedback system. To learn a technique for estimating the states of a plant using observer design. 2.0 MATLAB PROGRAM. Procedures M-file code M=0.5; m=0.2; b=0.1; 1 i=0.006; g=9.8; l=0.3; p=i*(M+m)+M*m*1^2; %denominator for the A and B matrices A=[0 0 B=[ 0; 0; 1 0 0 0 m*g*l*(M+m)/p 0; 0; 1; 0];

0 -(i+m*l^2)*b/p (m^2*g*l^2)/p 0 -(m*l*b)/p -(i+m*l^2)/p;

m*l/p]; C=[1 0 D=[0; 0]; Ts=1/100; pend=ss(A,B,C,D); pend_d=c2d(pend,Ts,'zoh') F=[1.0000 0.0100 0.0001 0.0000; 0 0.9982 0.0267 0.0001; 0 0.0000 1.0016 0.0100; 0 -0.0045 0.3119 1.0016]; 4 G=[0.0001 0.0182; 0.0002; 0.0454]; 0 0 0; 0 1 0];

H=[1 0 J=[0; 0];

0 0 0; 0 1 0];

Ts=1/100; pend_d=ss(F,G,H,J,Ts);

co=ctrb(pend_d); ob=obsv(pend_d); Controllability=rank(co) Observability=rank(ob)

T=0:0.01:5; U=0.2*ones(size(T)); F=[1.0000 0.0100 0.0001 0.0000; 0 0.9982 0.0267 0.0001; 0 0.0000 1.0016 0.0100; 6 0 -0.0045 0.3119 1.0016]; G=[0.0001 0.0182; 0.0002; 0.0454]; H=[1 0 J=[0; 0]; x=1; y=1; 0 0 0; 0 1 0];

Q=[x 0 0 0 R=1;

0 0 0; 0 0 0; 0 y 0; 0 0 0];

K=dlqr(F,G,Q,R) Ts=1/100; sys_cl=ss(F-G*K,G,H,J,Ts); [Y,T,X]=lsim(sys_cl,U); stairs(T,Y) legend('Cart (x)','Pendulum (phi)')

Procedures M-file code T=0:0.01:5; U=0.2*ones(size(T)); 10 F=[1.0000 0.0100 0.0001 0.0000; 0 0.9982 0.0267 0.0001; 0 0.0000 1.0016 0.0100; 0 -0.0045 0.3119 1.0016]; G=[0.0001 0.0182; 0.0002; 0.0454];

H=[1 0 J=[0; 0];

0 0 0; 0 1 0];

x=5000; %weighting factor for the cart position y=100; Q=[x 0 0 0 R = 1; K = dlqr(F,G,Q,R) Nbar = -61.55; Ts = 1/100; sys_cl = ss(F-G*K,G*Nbar,H,J,Ts); [Y,T,X]=lsim(sys_cl,U); stairs(T,Y) legend('Cart (x)','Pendulum (phi)') %weighting factor for the pendulum angle 0 0 0; 0 0 0; 0 y 0; 0 0 0];

Procedures M-file code F=[1.0000 0.0100 0.0001 0.0000; 0 0.9982 0.0267 0.0001; 0 0.0000 1.0016 0.0100; 0 -0.0045 0.3119 1.0016];

12

G=[0.0001 0.0182; 0.0002; 0.0454];

H=[1 0 J=[0; 0];

0 0 0; 0 1 0];

x=5000; %weighting factor for the cart position y=100; %weighting factor for the pendulum angle

Q=[x 0 0 0 R=1;

0 0 0; 0 0 0; 0 y 0; 0 0 0];

K=dlqr(F,G,Q,R); poles=eig(F-G*K)

Procedures M-file code

F=[1.0000 0.0100 0.0001 0.0000; 0 0.9982 0.0267 0.0001; 0 0.0000 1.0016 0.0100; 14 H=[1 0 0 -0.0045 0.3119 1.0016]; 0 0 0; 0 1 0];

P=[-0.3 -0.31 -0.32 -0.33]; L=place(F',H',P)'

T=0:0.01:5; U=0.2*ones(size(T));

F=[1.0000 0.0100 0.0001 0.0000; 0 0.9982 0.0267 0.0001; 0 0.0000 1.0016 0.0100; 0 -0.0045 0.3119 1.0016]; G=[0.0001 0.0182; 0.0002; 0.0454]; H=[1 16 0 J=[0; 0]; x=5000; y=100; Q=[x 0 0 0 R=1; K=dlqr(F,G,Q,R) Nbar=-61.55; L=[2.6310 -0.0105; 0 0 0; 0 0 0; 0 y 0; 0 0 0]; 0 0 0; 0 1 0];

172.8146 -0.0129 -2.2954

-1.3468; 2.6304; 173.2787];

Fce=[F-G*K

G*K;

zeros(size(F)) (F-L*H)]; Gce=[G*Nbar; zeros(size(G))]; Hce=[H zeros(size(H))]; Jce=[0;0]; Ts=1/100; sys_cl=ss(Fce,Gce,Hce,Jce,Ts); [Y,T,X]=lsim(sys_cl,U); stairs(T,Y) legend('Cart (x)','Pendulum (phi)')

3.0

RESULTS

Procedures

Results a= x1 x1 x2 x3 1 0 0 0 x2 0.009991 0.9982 -2.272e-005 -0.004544 u1 x1 -9.085e-005 x2 x3 x4 c= y1 y2 d= y1 y2 -0.01816 0.0002275 0.04552 x1 x2 x3 x4 1 0 0 0 u1 0 0 0 1 0 0 x3 0.02672 1.002 0.3119 x4 0.0001336 0.01001 1.002 0.0001336 4.453e-007

x4 b=

Sampling time: 0.01 Discrete-time model.

10

Controllability = 4 Observability = 4

Procedures Results

11

x=1, y=1 K = -0.9384 -1.5565 18.1110


K= -0.9384 -1.5565 18.1110

3.3499
3.3499

0 .1 Cr ( ) at x Pn u mp i) e d lu ( h Tr=0.48s at 0.014873kg Ts= 4.8s at -0.00025719kg

05 .0

0 Tr=0.27s at 0.00341673kg - .0 05

- .1 0

- .1 05 Ts= 4.94s at -0.21923kg - .2 0

- .2 05

0 .5

1 .5

2 .5

3 .5

4 .5

Figure 1: Step response for weighing factor x=1 and y=1.

Procedures

Results

12

K= -61.9836 -33.3719 95.4404 18.8911

x 10

-3

10

Tr=0.17s at 0.002613kg 2

Cart (x) Pendulum (phi)

1 Ts= 2.01s at -5.4651e-006kg 0 Tr=0.14s at 0.00093131kg -1

-2 Ts= 1.52s at -0.0032227kg -3

-4

0.5

1.5

2.5

3.5

4.5

Figure 2: Step response for weighing factor x=5000 and y=100.

poles = 12 0.9156 + 0.0729i 0.9156 - 0.0729i 0.9535 + 0.0079i 0.9535 - 0.0079i

Procedures

Results

13

14

L= 2.6310 -0.0129 -2.2954 -0.0105 2.6304 173.2787 172.8146 -1.3468

K = -61.9836 -33.3719 95.4404 18.8911

16

0.2 0.15 0.1 0.05 0 -0.05 -0.1 -0.15 -0.2


Tr= 0.58s at 0.067686kg Tr=1.28s at 0.19758kg

Cart (x) Pendulum (phi)

Ts= 4.16s at -6.149e-10kg

0.5

1.5

2.5

3.5

4.5

Figure 3: Overall system response including observer.

4.0

OBSERVATION

14

Procedures

Observation The c2d command is used in procedure 1 to convert continuous to

discrete state-space equation with sampling time, Ts=0.01. The output displayed in a, b, c, and d matrices in form discrete time model.

The output shown that the controllability and observability is 4.

In figure 1 and 2, the curve in green represents the pendulum's angle, in radians, and the curve in blue represents the cart's position in meters. With including commands Nbar equals -61.55, the step response will be as shown in figure 3 with same gain, K in procedure 3.

The poles location for the system without the observer as shown in result (procedure 5).

To find L matrix, used place commands in matlab and the output shown as result in procedure 6.

Figure 4 shown as same as figure 3. The curve in green represents 7 the pendulum's angle, in radians, and the curve in blue represents the cart's position in meters with the gain, K also the same value.

15

5.0

ANALYSIS In order to convert the continuous state-space equations to discrete state-space is

by using c2dm commands in the Matlab. To use this c2dm commands, we need to specify six arguments: four state-space matrices (A, B, C, and D), sampling time (Ts in sec/sample), and the 'method'. The sampling time should be smaller than 1/(30*BW) sec, where BW is the closed-loop bandwidth frequency. The method we will use is the zeroorder hold ('zoh') same as lab before. The next step is to check the controllability and the observability of the system. For the system to be completely state controllable, the controllability matrix must have the rank of n. The rank of the matrix is the number of independent rows (or columns). In the same token, for the system to be completely state observable, the observability matrix must also have the rank of n. Since our controllability matrix and observability matrix are '4x4', the rank of both matrices must be 4. The function rank can give you the rank of each matrix. From result in procedure 2, this proves that our discrete system is both completely state controllable and completely state observable. In figure 1, the pendulum's and cart's overshoot appear fine, but their settling times need improvement and the cart's rise time needs to be decreased. Also the cart has, in fact, moved in the opposite direction. For x=1, y=1 the settling time, Ts is greater than 5 seconds and rise time for cart is over than 1 second. When increase the weighting factors (x=5000, y=100), with settling time, Ts is about 2 seconds for pendulum(phi) and less than 2 seconds for cart (x). For carts rise time, TR is less than 1 second. The plot in figure 2, all design requirements are satisfied except the steady-state error of the cart position (x). To obtain the desired output, the reference input is scaled so that the output equals to the reference. This can be easily done by introducing a feedforwarding scaling factor called Nbar. This function will find the scale factor for a full-state feedback system to eliminate the steady-state error. Unfortunately, in this lab, the user-defined function rscale cannot use to find Nbar. But certainly it can find from trial and errors. After several trials, the Nbar equals to -61.55 provided the satisfactory response. From the plot

16

in figure 3, notice that the steady-state error of the cart's position have been eliminated and the designed of system satisfied all design requirements. The above response satisfies all design requirements; however, it was found assuming all states are measurable. This assumption may not be valid for all systems. The technique is developed for estimating the states of a plant from the information that is available concerning the plant. The system that estimates the states of another system is called an observer. Thus, in this section a full-order state observer is designed to estimate those states that are not measurable. To design the observer, first, find the L matrix. To find the L matrix, the poles needed to find the system without the observer (the poles of F-G*K). The observer poles are placed to make the observer works a lot faster than the system without the observer. The Matlab function place is used to find the L matrix. From figure 4, as noticed, this response is about the same as before, and all of the design requirements have been satisfied. Table 1: Summarized of the settling time and rise time for all tasks. Without observer poles time Rise Time, Tr Settling time, Ts 6.0 COMMENT In this lab, first step is same as before that to convert the continuous to discrete state-space equation. For inverted pendulum, we used matlab function called c2d to convert that equation. Then we need to check either the system is completely state controllable or completely state observable. From result in procedure 2, this proves that our discrete system is both completely state controllable and completely state observable. From figure 1, we can see the pendulum's and cart's overshoot appear fine, but their settling times need improvement and the cart's rise time needs to be decreased when we X=1 y=1 Cart Pend 0.27s 0.48s 4.94s 4.8s Weighing factor X=5000 y=100 Cart Pend 0.14s 0.17s 1.52s 2.01s With observer poles X=5000 y=100 Cart pend 0.58s 1.28s 4.16s

17

use x=1 and y=1. Since we increase x=5000 and y=100, the step response shown as figure 2 but the steady-state error of the cart position (x) are not satisfied. We use Nbar equals to -61.55 provided the satisfactory response. From the plot in figure 3, notice that the steady-state error of the cart's position have been eliminated and the designed of system satisfied all design requirements. And lastly to confirm that the system is satisfied all design requirement, the technique is developed for estimating the states of a plant from the information that is available concerning the plant is called an observer. With using place function to find L matrix, from figure 4, this response is about the same as before, and all of the design requirements have been satisfied.

7.0

CONCLUSION After this lab, conclusion that can make is the discrete state-space equation for

inverted pendulum is a= x1 x1 x2 x3 1 0 0 x2 0.009991 0.9982 -2.272e-005 x3 0.02672 1.002 x4 0.0001336 0.01001 0.0001336 4.453e-007

18

x4 b=

-0.004544 u1

0.3119

1.002

x1 -9.085e-005 x2 x3 x4 c= y1 y2 d= y1 y2 -0.01816 0.0002275 0.04552 x1 x2 x3 x4 1 0 0 0 u1 0 0 0 1 0 0

with sampling time is 0.01. The discrete system for inverted pendulum is both completely state controllable and completely state observable. From figure 1(x=1 and y=1), the step response shows that the design is not satisfied all design requirements. When increase x=5000 and y=100 the plot in figure 2 are shown but only steady-state error for carts position (x) are not satisfied. By using Nbar commands, the steady-state error of the cart's position have been eliminated and the designed of system satisfied all design requirements as shown in figure 3. The place command is used to find L matrix in order to design observer. From figure 4, this response is about the same as before, and all of the design requirements have been satisfied.

19

8.0

REFERANCES 1. 2. 3. Lab sheet 2, BER 4113 Digital Control, Digital Dc Motor Speed Control With Pid Control Amran Mohd Zaid , July 2007 Electronic and circuit analysis using MATLAB (Second Edition) , John Okyeke Attia. MATLAB Programming David C. Kuncicky, Prentice Hall, 2005.

20

21

Das könnte Ihnen auch gefallen