Inverted Pendulum with State Feedback

12
Inverted Pendulum System with State Feedback EE511 Linear Systems Analysis Extra Credit Project Prepared by: Sylvano Doddick and Ahmed Almuwallad California State University of Long Beach, College of Engineering Los Angeles, December 12, 2010.

Transcript of Inverted Pendulum with State Feedback

Page 1: Inverted Pendulum with State Feedback

Inverted Pendulum System

with State Feedback

EE511 Linear Systems Analysis

Extra Credit Project

Prepared by:

Sylvano Doddick and Ahmed Almuwallad

California State University of Long Beach, College of Engineering

Los Angeles, December 12, 2010.

Page 2: Inverted Pendulum with State Feedback

1

Table of Contents

Introduction .......................................................................................................................................... 2

Discussion............................................................................................................................................... 2

Inverted Pendulum Problem ....................................................................................................... 2

Type I servo system ..................................................................................................................... 5

Step Response Analysis .............................................................................................................. 7

Conclusion............................................................................................................................................... 9

Credits ...................................................................................................................................................... 9

References............................................................................................................................................... 9

Appendices............................................................................................................................................. 10

Appendix 1 - Detailed Calculations of and characteristic

equation ............................................................................................................................................. 10

Appendix 2 - Matlab Program for generating step-response graphs .......... 11

Page 3: Inverted Pendulum with State Feedback

2

Introduction

The inverted pendulum is a common and classical control problem that

involves many basic elements of control theory. This Project

investigates the stabilization of the inverted pendulum system through

linear state feedback theory and was implemented by using Matlab

software. It contains the system dynamic and the used control method.

There are three main objectives of this report: to illustrate, in

general terms, the inverted pendulum problem; to summarize and explain

the state feedback control method of controlling inverted pendulum;

and to demonstrate the use of Matlab in systems design. Among several

topics from the control theory field covered by this Project, the most

important are state feedback controller design and step response

analysis. The inverted pendulum stability is demonstrated by using

state feedback method which requires poles assignment and pole

placement. Step response analysis plays an important role in

determining systems' stability as it shows how the system would behave

as the time changes.

Discussion

As a general model of inverted pendulum system with state feedback

tends to be rather complex, in this Project our goal was not to derive

detailed analytical expressions for a general case; rather, we showed

how particular instances of the model can be solved by applying

equations derived in Chi-Tsong Chen's Linear System Theory and Design

and Ogata's Modern Control Engineering. In addition, we modified

Matlab program from Ogata (850-55) and used it to calculate particular

values for and corresponding step response diagrams.

Inverted Pendulum Problem

The basic model of inverted pendulum is given in the Chi-Tsong Chen's

Linear System Theory and Design (Example 2.8). In the inverted

pendulum from that example (Figure 1), the problem is to maintain the

pendulum in the vertical position as much as possible and control the

position of the cart. Since the inverted pendulum system mounted on a

cart does not have an integrator, it can be defined as type 0 system.

To control the position of the cart, type I servo system needs to be

built by inserting an integrator in the feedforward path between the

error comparator and the plant (Ogata 850-55). The block diagram of an

inverted pendulum control system with inserted integrator is shown in

Figure 2 (page 5).

Page 4: Inverted Pendulum with State Feedback

3

Figure 1 - Inverted pendulum control system (Source: Ogata 850)

Following example 2.8 from Chi-Tsong Chen's Linear System Theory and

Design, we let H and V be the horizontal and vertical forces exerted

by the cart on the pendulum as shown.

The application of Newton's law to the linear movement yields

The application of Newton's law to the rotational movement of the

pendulum around the hinge yields

Under the assumption that pendulum angle and the angular velocity

are small, is approximated by and is approximated by 1. It

follows that

which imply

Page 5: Inverted Pendulum with State Feedback

4

(1)

(2)

By applying Laplace transform to and ,

input-output and state-space descriptions are calculated as

From these equations, the transfer function from to and the

transfer function from to are given by

From equation (2), the system transfer function can be obtained as

Therefore, the inverted pendulum has one pole on the positive real

axis and one on the negative real axis,

, as the system is

open-loop unstable.

The state variables are defined as

Using selected state variables and equations (1) and (2), the basic

state-space equation which describes the system when pendulum angle

and the angular velocity are very small is obtained as:

.

Page 6: Inverted Pendulum with State Feedback

5

Type I servo system

Block diagram of type 1 servo system that can control the position of

the cart is shown in Figure 2. The integrator is inserted in the

feedforward path between the error comparator and the plant.

Figure 2 - Type 1 servo system (Source: Ogata 851)

Next, using equations (1) and (2), Figure 2, and denoting the cart

position as as the output of the system, following equations of the

system can be obtained:

, ,

,

,

where

,

, .

For the type 1 servo system, the state error equation is given as:

Page 7: Inverted Pendulum with State Feedback

6

where

,

, and

is the state feedback gain matrix,

,

where is the desired feedback gain matrix and is

the integral gain constant.

By defining the desired feedback gain matrix, , and equating

with desired characteristic equation, we obtain (see Appendix 1

for detailed calculations):

and characteristic equation for the system:

Controllability of the system can be determined by examining the rank

of matrix :

Using Matlab, the rank of matrix is found to be 5, therefore, the

system defined by equation is completely controllable, and

arbitrary pole placement is possible. Ogata suggests that, based on

the experience in the root-locus design, dominant pair of closed-loop

poles can be chosen while placing other poles so that they are far to

the left of the dominant closed-loop poles. One set of closed-loop

poles can then be chosen as:

, .

Page 8: Inverted Pendulum with State Feedback

7

State feedback gain matrix can be produced in the Matlab using

acker(A,b,p) function (Matlab Program 1) that is utilizing Ackermann's

formula (Ogata 860) to calculate a gain vector such that state

feedback places the closed-loop at the locations p. Matlab

Program 1 can be used to calculate the state feedback gain matrix .

Matlab Program 1 - Calculating

A = [0 1 0 0;0 0 -m*g/M 0;0 0 0 1;0 0 (M+m)*g/(M*l) 0]; B = [0;1/M;0;-1/(M*l)]; C = [1 0 0 0];

Ahat = [A zeros(4,1); -C 0]; Bhat = [B;0]; J = [-1+j*sqrt(3) -1-j*sqrt(3) -5 -5 -5]; Khat = acker(Ahat,Bhat,J);

Assuming mass of the cart is M = 50kg, mass at the end of the pendulum

m = 2kg, the length of the pendulum l = 4m, and gravity g = 9.81m/s2,

the Matlab program yields

.

The step response in the cart position can now be obtained by solving

the following equation:

and the output of the system is , or

.

Step Response Analysis

Complete Matlab program that was used to obtain the step-response

curves of the system can be seen in Appendix 2 and the resulting

graphs are included in the Figure 3. Curves depicted in the Figure 3

represent output state variables x1 and x2 ( displacement and

displacement velocity) versus time, while state variables x3 and x4

represent pendulum angle and angular velocity , respectively,

versus time; x5 is the output of the integrator versus time.

Page 9: Inverted Pendulum with State Feedback

8

Figure 3 - State variables versus time

Various additional variables, such as overshoot and settling time, can

be calculated using obtained state matrix and Matlab. For example,

peak time of the output displacement (state variable x1) is

calculated using Matlab Program 2 as 2.14s with maximum overshoot of

0.4115 or 41.15%.

Matlab Program 2- Calculate peak time,

maximum overshoot, and settling time

[ymax,tp] = max(x1); peak_time = (tp-1)*0.02; max_overshoot = ymax-1;

s = length(x5); while (x5(s)>1.09) && (x5(s)<1.11); s = s-1; end; settling_time = (s-1)*0.02;

Using the same program, we can calculate the settling time to be

approximately 4.32s as output of the integrator (state variable

x5) approaches 1.1. This result is obtained observing that state

variables will be zero as time approaches infinity. Then,

or

This fact can be used together with

Page 10: Inverted Pendulum with State Feedback

9

;

it then follows that

,

and

Thus, for , we have

.

Conclusion

The calculations from state response analysis part demonstrated that a

cart with inverted pendulum could be controlled if proper state

feedback is implemented and taken into account. In the calculations,

however, the speed and dumping were not quite satisfactory, therefore,

the desired characteristic equation should be modified and new matrix

should be determined to obtain better stability values. Presented

Matlab code could be used to run various simulations until the

satisfactory result is obtained.

Credits

The basic model for the inverted pendulum problem of this Project can

be found in Chen's Linear System Theory and Design (Example 2.8). The

Scanned images of inverted pendulum control system (Figure 1) and

inverted-pendulum type I control system (Figure 2) were obtained from

Ogata's Modern Control Engineering (Ogata 850, Figures 12-8 and 12-9).

In addition to the scanned images, Matlab codes used for calculating

and corresponding step response are obtained by appropriate

modification of Matlab Programs 12-6 and 12-7 (Ogata 853-4).

References

Ogata, Katsuhiko. Modern Control Engineering. Fourth Edition. Upper

Saddle River: Prentice-Hall, Inc., 2002. 850-55. Print.

Chen, Chi-Tsong. Linear System Theory and Design. Third Edition. New

York: Oxford University Press, 1999. 22-23. Print.

Page 11: Inverted Pendulum with State Feedback

10

Appendices

Appendix 1 - Detailed Calculations of and

characteristic equation

Page 12: Inverted Pendulum with State Feedback

11

Appendix 2 - Matlab Program for generating step-response graphs

M = 50; %mass of the cart (kg)

m = 2; %mass at the end of the pendulum

l = 4; %length of the pendulum

g = 9.81; %gravity

A = [0 1 0 0;0 0 -m*g/M 0;0 0 0 1;0 0 (M+m)*g/(M*l) 0];

B = [0;1/M;0;-1/(M*l)];

C = [1 0 0 0];

D = [0];

P = [A B;-C 0];

Ahat = [A zeros(4,1); -C 0];

Bhat = [B;0];

J = [-1+j*sqrt(3) -1-j*sqrt(3) -5 -5 -5];

Khat = acker(Ahat,Bhat,J);

K = [Khat(1,1:4)];

Kl = [-Khat(1,5)];

AA = [A-B*K B*Kl;-C 0];

BB = [0;0;0;0;1];

CC = [C 0];

DD = [0];

t = 0:0.02:6;

[y,x,t] = step(AA,BB,CC,DD,1,t);

x1 = [1 0 0 0 0]*x';

x2 = [0 1 0 0 0]*x';

x3 = [0 0 1 0 0]*x';

x4 = [0 0 0 1 0]*x';

x5 = [0 0 0 0 1]*x';

figure;

subplot(3,2,1);

plot(t,x1);

grid;

title('Response to Initial Condition');

ylabel('state variable x1');

subplot(3,2,2);

plot(t,x2);

grid;

ylabel('state variable x2');

subplot(3,2,3);

plot(t,x3);

grid;

ylabel('state variable x3');

subplot(3,2,4);

plot(t,x4);

grid;

ylabel('state variable x4');

subplot(3,2,5);

plot(t,x5);

grid;

ylabel('state variable x5');