dynamic systems project (1)

24
TEXAS A&M UNIVERISTY KINGSVILLE DYNAMIC SYSTEMS I TOPIC "DESIGN AND IMPLEMENTATION OF CONTROL SYSTEM FOR INVERTED PENDULUM" BY CHARIT SHAH (K00341027) KSHITIJA JOSHI (K00369594)

Upload: kshitija-joshi

Post on 08-Feb-2017

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Dynamic systems project (1)

TEXAS A&M UNIVERISTY KINGSVILLE

DYNAMIC SYSTEMS I

TOPIC

"DESIGN AND IMPLEMENTATION OF CONTROL SYSTEM

FOR INVERTED PENDULUM"

BY

CHARIT SHAH (K00341027)

KSHITIJA JOSHI (K00369594)

Abstract

Page 2: Dynamic systems project (1)

In this paper an inverted pendulum system is presented using state feedback controller. Here by controlling the displacement of cart in range of -0.6 and 0.6, Angle of the inverted pendulum is maintained at 0.2 rad and less. This system has a settling time less has than 0.4 seconds. Full state feedback controller is developed by using pole placement, state feedback and observer and LQR methods. All mathematical operations are done clearly and simulations together with analysis are done on MATLAB software.

Introduction

The control of an inverted pendulum is good in testing and evaluating various control methods. It is interesting with the fact of that it is unstable without control because the pendulum will fall down in vertical down direction if the cart is not moved to balance it.

Here we can find A, B, C, D matrices from the given state space model.

Given data:

W = 7 Pendulum Angle less than 0.2 Settling time less than 0.4 seconds Cart position in between -0.6 and 0.6 Designs the poles of the observer to be at least 10(3+W) times the distance from the

imaginary axis as the closed loop poles were, repeat the design with 11(4+W) times.

Here we are considering parameters necessary for the modeling of the pendulum are ξ is the damping ratio, ωn is the natural frequency. There are simple equations can be used to determine these expressions. Damping ratio is given by,

Page 3: Dynamic systems project (1)

%O.S. = 11.45 degrees or 0.2 rad

Tsettling = 0.4 seconds

The Damping ratio can be found by below equation from overshoot

Wn = 22.069

ξ = 0.5664

Ts = 5τ

The transfer function of the pendulum is shown in the following equation,

T ( s)R (s )

= 1s2+2ξωn s+ωn

2

σ = ξ*Wn = 12.5

jWd = 18.17j

S1,2 = - 12.5 ± 18.17j

As shown above there are two poles can be find out from the above transfer function and two

other poles found by assumption to satisfy the given criteria. For the test purpose the different

values of S3 and S4 are chosen such that the system condition of the settling time are satisfied.

TEST 1

Page 4: Dynamic systems project (1)

In these test we will assume different values of poles which are multiple of S1, S2. And the 2

other poles are assumed to be placed far away so that our 4 th order system will behave as the

Second order system. Initially we will assume our poles to be 2 to 3 times that of the real part of

the S1 and S2 and will examine the time response of the state feedback control system.

By assuming the pole we will calculate the state feedback vector F1 and will compute its time

response and will check whether the system conditions are satisfied or not.

Desired Poles = [-37.5,-25,-12.5+18.17j,-12.5-18.17j]

F1 = 10^4*[-1.0296 -0.1215 0.4759 0.0503]

With the selection of the above sets of desired pole and F1 we are getting the step response as

shown in the figure. As we inspect for the settling time of the response it is 0.438 Sec in the cart

position response and 0.442 sec in the pendulum angle time response system. But as per our

design we need to have both the system to have settling time less than 0.4 Sec so now what we

will do is , we will try a different sets of desired poles in TEST 2 and will inspect whether we are

getting the system condition satisfied or not.

TEST 2

Page 5: Dynamic systems project (1)

In this test we will assume are poles to be placed 5 times and 10 times away from the 2nd order

poles, and then will calculate the F1.

Desired Poles = [-125, -62.5,-12.5+18.17j, -12.5-18.17j]

F1= 10^4 *[-8.5803 -0.6466 3.6991 0.2619]

Now with these above set of F1 and desired poles the time response of the system is calculated

and is plotted as shown in the figure.

The step response of the system settling time is calculated and it comes out to be 0.382 & 0. 383

Sec for both the cart position and pendulum angle. And moreover it also satisfies the system

design constraints. So now we will develop a state feedback with an observer of the system.

Designing of the Observer Based Control for the state feedback

Page 6: Dynamic systems project (1)

So far, it was assumed that there is full or partial access to the state x (t) when the controllers in

above method are designed. But in reality, most often, all of this information is not available. To

address this issue, a replica of the dynamic system that provides an “estimate” of the system

states based on the measured output of the system should be developed – the so called

a state observer or state estimator. Here, a full order state observer will be developed assuming as

if all the states can’t be measured taking in to consideration that there might be lack of sensors.

Design Procedure

1. Checking whether the pair (A, C) is observable.

2. Developing estimate of x (t) that will be calledx (t ).

3. Selecting a suitable real constant vector L so that all eigenvalues of (A−LC) have negative

real parts.

4. Making sure that the estimator eigenvalues are faster than the desired eigenvalues of the state

feedback, because it will be used together to form a compensator.

To select L a common guideline is to make the estimator poles 4-10 times faster than the slowest

controller pole. Making the estimator poles too fast can be problematic if the measurement is

corrupted by noise or there are errors in the sensor measurement in general.

Controller poles from the above system are

Page 7: Dynamic systems project (1)

-125

-62.5

-12.5 + 18.17j

-12.5– 18.17j

The slowest poles have real parts at -12.5, so the estimator poles can be placed at (7+3) times

which is -125. Since the closed-loop estimator dynamics are determined by a matrix (A-LC) that

has a similar form to the matrix that determines the dynamics of the state-feedback system (A-

BF) Therefore the same commands, that were used to find the state feedback gain F, can be used

to find the estimator gain L.

Placing observer poles

>> desired_obs_poles = [-128 -127 -126 -125]

Where

By making an equivalent transformation to the above state space model, it can be represented as

the following equivalent state equation. And this equivalent state equation governs the whole

controller-estimator configuration.

Step Response of the observer

Page 8: Dynamic systems project (1)

For the desired observer poles placed atleast (3+W) times i.e 10 times away from the

imaginary Axis the step response is plotted

Now by placing the desired poles more away from the imaginary axis the response is plotted.

And the multiplying factor for these poles is now (4+W) i.e 11 times.

The overall design requirements are satisfied and the system has a relatively good performance.

But it can be seen that the response graph for the inverted pendulum lucks a slight smoothness.

Next we will design the Feedback by using the LQR and Optimal Control Theory.

Page 9: Dynamic systems project (1)

Optimal control Theory and LQR Based Control

This approach is to place the pole locations so that the closed-loop system optimizes the cost

function given by

Jqr=∫T 1

T 2

[X 'QX +U ' RU ]dt

Where:

X’QX is the state cost with weight Q.

U’RU is the control cost with weight R.

Therefore, LQR selects closed-loop poles that balance between state errors and control effort.

Design procedures for LQR:

Selecting design parameter matrices Q and R.

Easily, we are given the sets of different Q and R so we will implement that first and will

calculate the close loop feedback gain and based on it.

Later we will calculate the values by varying the value of R as mention in the paper.

For value of R = 1:

Page 10: Dynamic systems project (1)

Test Case A

>> Q = [1 0 0 0; 0 7 0 0; 0 0 1 0; 0 0 0 1];

>> R=1;

>> Fqr = lqr(A,B,Q,R);

>> Anew=A-B*Fqr;

>> system_qr=ss(Anew,B,C,D);

>> stepplot(system_qr);

Over here the above set of Q,R gives the step

response as shown in figure.

The settling time is 2.35 & 2.41 Sec.

Test Case B

>> Q = [1 0 0 0; 0 7 0 0; 0 0 10 0; 0 0 0 1]

>> R=1;

>> Fqr = lqr (A,B,Q,R)

>> Anew=A-B*Fqr;

>> system_qr=ss (Anew,B,C,D)

>> stepplot(system_qr);

Over here the above set of Q,R gives the step

response as shown in figure.

The settling time is 11 & 8.19 Sec.

Test Case C

>> Q = [10 0 0 0; 0 1 0 0; 0 0 7 0; 0 0 0 1]

>> R=1;

>> Fqr = lqr (A,B,Q,R)

>> Anew=A-B*Fqr;

Page 11: Dynamic systems project (1)

>> system_qr=ss (Anew,B,C,D)

>> stepplot(system_qr);

Over here the above set of Q,R gives the step response as shown in figure.

The settling time is 2.15 & 3.21 Sec.

For value of R = 10:

Test Case A

>> Q = [1 0 0 0; 0 7 0 0; 0 0 1 0; 0 0 0 1];

>> R=10;

>> Fqr = lqr(A,B,Q,R);

>> Anew=A-B*Fqr;

>> system_qr=ss(Anew,B,C,D);

>> stepplot(system_qr);

Over here the above set of Q,R gives the step

response as shown in figure.

The settling time is 11.3 & 10.3 Sec.

Test Case B

>> Q = [1 0 0 0; 0 7 0 0; 0 0 10 0; 0 0 0 1]

>> R=10;

>> Fqr = lqr (A,B,Q,R)

>> Anew=A-B*Fqr;

>> system_qr=ss (Anew,B,C,D)

Page 12: Dynamic systems project (1)

>> stepplot(system_qr);

Over here the above set of Q,R gives the step response as shown in figure.

The settling time is 11.3 & 10.4 Sec.

Test Case C

>> Q = [10 0 0 0; 0 1 0 0; 0 0 7 0; 0 0 0 1]

>> R=10;

>> Fqr = lqr (A,B,Q,R)

>> Anew=A-B*Fqr;

>> system_qr=ss (Anew,B,C,D)

>> stepplot(system_qr);

Over here the above set of Q,R gives the

step response as shown in figure.

The settling time is 5.25 & 4.85 Sec.

For value of R = 0.1:

Test case A

>> Q = [1 0 0 0; 0 7 0 0; 0 0 1 0; 0 0 0 1];

>> R=0.1;

>> Fqr = lqr(A,B,Q,R);

>> Anew=A-B*Fqr;

Page 13: Dynamic systems project (1)

>> system_qr=ss(Anew,B,C,D);

>> stepplot(system_qr);

Over here the above set of Q,R gives the step response as shown in figure.

The settling time is 10.8 & 7.3 Sec.

Test Case B

>> Q = [1 0 0 0; 0 7 0 0; 0 0 10 0; 0 0 0 1]

>> R=0.1;

>> Fqr = lqr (A,B,Q,R)

>> Anew=A-B*Fqr;

>> system_qr=ss (Anew,B,C,D)

>> stepplot(system_qr);

Over here the above set of Q,R gives the step

response as shown in figure.

The settling time is 10.8 & 7.37 Sec.

Test Case C

>> Q = [10 0 0 0; 0 1 0 0; 0 0 7 0; 0 0 0 1]

>> R=0.1;

>> Fqr = lqr (A,B,Q,R)

>> Anew=A-B*Fqr;

>> system_qr=ss (Anew,B,C,D)

>> stepplot(system_qr);

Page 14: Dynamic systems project (1)

Over here the above set of Q,R gives the step response as shown in figure.

The settling time is 1.82 & 2.61 Sec.

Page 15: Dynamic systems project (1)

Conclusion:

The steady state response and also the step response for the given 4 th order inverted pendulum

system was calculated and plotted in MATLAB for different set of values Q & R.

Also the state feedback for the above system is designed in order to achieve desired constraints.

Page 16: Dynamic systems project (1)

APPENDIX

MATLAB CODE:

>> A=[0 1 0 0;0 -0.18 2.67 0;0 0 0 1;0 -0.45 31.18 0];>> B=[0;1.81;0;4.55];>> C=[1 0 0 0;0 0 1 0];>> D=[0;0];>> %checking the stability and controllablity and observablity%>> system=ss(A,B,C,D);>> Cm=ctrb(system);>> rank_Cm=rank(Cm)

rank_Cm =

     4

>> %Full rank so controllable%>> Om=obsv(system)

Om =

    1.0000         0         0         0         0         0    1.0000         0         0    1.0000         0         0         0         0         0    1.0000         0   -0.1800    2.6700         0         0   -0.4500   31.1800         0         0    0.0324   -0.4806    2.6700         0    0.0810   -1.2015   31.1800

>> rank_Om=rank(Om)

rank_Om =

     4

>> %Full rank so observable%>> %design of state feedback by pole placement%>> desired_poles1=[-80+129.24j -80-129.24j -7.999+12.924j -desired_poles1=[-80+129.24j -80-129.24j -7.999+12.924j -7.999-12.924j];];>> desired_poles1=[-37.5 -25 -12.5+18.17j -12.5-18.17j];>> F1=place(A,B,desired_poles1)

Page 17: Dynamic systems project (1)

F1 =

  1.0e+004 *

   -1.0296   -0.1215    0.4759    0.0503

>> Anew=A-B*F1;>> system_1=ss(Anew,B,C,D);>> stepplot(system_1)>> stepplot(system_1)>> desired_poles10=[-125 -62.5 -12.5+18.17j -12.5-18.17j];>> F1=place(A,B,desired_poles10)

F1 =

  1.0e+004 *

   -8.5803   -0.6466    3.6991    0.2619

>> Anew=A-B*F1;>> system_1=ss(Anew,B,C,D);>> stepplot(system_1)>> %design of observer atleast 10 times Away as W=7%>> desired_obs_poles=[-128 -127 -126 -125];>> L=place(A',C',desired_obs_poles)';>> Ao=[A (-B*F1);L*C (A-(L*C)-(B*F1))];>> Bo=[B;B];>> Co=[C zeros(size(C))];>> Do=D;>> system_obs=ss(Ao,Bo,Co,Do);>> stepplot(system_obs)>> stepplot(system_obs)>> stepplot(system_obs)>> stepplot(system_obs)>> %design of observer atleast 7 times Away%>> L=place(A',C',desired_obs_poles)'

L =

  1.0e+004 *

    0.0253   -0.0001    1.5918   -0.0131   -0.0001    0.0253   -0.0220    1.6071

Page 18: Dynamic systems project (1)

>> %design of observer atleast 11 times Away%>> desired_obs_poles=[-142 -141 -140 -139 -138];>> L=place(A',C',desired_obs_poles)' >> L=place(A',C',desired_obs_poles)'; >> desired_obs_poles=[-141 -140 -139 -138];>> L=place(A',C',desired_obs_poles)';>> Ao=[A (-B*F1);L*C (A-(L*C)-(B*F1))];>> Bo=[B;B];>> Co=[C zeros(size(C))];>> Do=D;>> system_obs=ss(Ao,Bo,Co,Do);>> stepplot(system_obs)>> >> stepplot(system_obs)Q= [10 0 0 0;0 1 0 0;0 0 7 0;0 0 0 1];>> R=10;>> Fqr=lqr(A,B,Q,R);??? Undefined function or variable 'A'. >> A=[0 1 0 0;0 -0.18 2.67 0;0 0 0 1;0 -0.45 31.18 0];B=[0;1.81;0;4.55];C=[1 0 0 0;0 0 1 0];D[0;0];??? D[0;0]; |Error: Unbalanced or unexpected parenthesis or bracket. >> D=[0;0];>> Fqr=lqr(A,B,Q,R);>> Aqr=A-B*Fqr;>> system_qr=ss(Aqr,B,C,D);>> stepplot(system_qr)>> Q= [1 0 0 0;0 7 0 0;0 0 1 0;0 0 0 1];>> R=0.1;>> Fqr=lqr(A,B,Q,R);>> Aqr=A-B*Fqr;>> system_qr=ss(Aqr,B,C,D);>> stepplot(system_qr)>> Q= [1 0 0 0;0 7 0 0;0 0 10 0;0 0 0 1];>> R=0.1;>> Fqr=lqr(A,B,Q,R);>> Aqr=A-B*Fqr;>> system_qr=ss(Aqr,B,C,D);>> stepplot(system_qr)

Page 19: Dynamic systems project (1)

>> Q= [10 0 0 0;0 1 0 0;0 0 7 0;0 0 0 1];>> R=0.1;>> Fqr=lqr(A,B,Q,R);>> Aqr=A-B*Fqr;>> system_qr=ss(Aqr,B,C,D);>> stepplot(system_qr)