Inverted Pendulum Sample

4
Modelling and control of Inverted pendulum Jacob James Mechanical and Aerospace Engineering University of Florida Email: jacobjamesm@u.edu  Abstract —This paper models an inverted pendulum, designing a contr oll er for posit ion ing the cart at some pos iti on whi le kee pin g the pen dul um in a ver tic al pos iti on. The syste m is controlled with a single force input. I. I NTRODUCTION The inverted pen dul um is a cla ssi c con tr ol pro blem tha t can be us ed as the ba si s for the modeli ng of ma ny more comp lex pr oble ms like st abilizat ion of a rocket duri ng launch, balancing of robots, biped motion planning building bal anc ing in ear thq uakes, in des ign and sta bil iza tio n of per son al mobility units and many mor e applic ati ons. The inverted pendulum is a system that is inherently unstable, and cannot be balanced without the application of some external tor que . The cla ssi c pro ble m dea ls wit h the contro l of the input torque required to balance the inverted pendulum. H er e th e pr o bl e m of b al anci n g an in ve rt ed pe nd ul um on a carr iage is considered. The aim of this ex er ci se to maintain the pendulum balance while the cart moves to the required position. The se cond sect ion of this pa per descri bes the syst em, and derives the dynamic equations of motion for the system. The system here has two controllable outputs. The thir d se ct ion deri ve s the state spac e model for the inverted pen dul um, taking the pos ition of the car t and the angle of the pendulum as the output variables. The input here is the force applied on the cart, that has to both position the cart and maintain the stability of the inverted pendulum. The four th sect ion de al s wi th st abil it y anal ys is for the system that has been arrived at. The stability analysis of the sys tem with no fee dba ck app lie d sho ws tha t tha t sys tem is unstable as was already known. The f th sect ion de al s wi th de si gning a fe edba ck loop to position the cart at the required position while maintaining the stability of the system. The design focuses on achieving a suitably small settling time for the system II. THE CARRIAGE PENDULUM SYSTEM 1) Mec hani cal set- up of the carr iag e in vert ed pendu lum system: The sys tem con sis ts of a car ria ge con str ain ed to move along a straight line. Onto this carriage a pendulum is mounted that is constrained to move along the plane passing through the line of motion of the cart. The pendulum will tip over if its centre of gravity does not pass through the hinge point. Any motion of the cart will also cause the pendulum to tip over in the opposite direction. The aim of this control exercise is to move the cart into the required position without tripping over the pendulum. Here a single input to the system, the force on the cart has an impact on the coupled output, i.e. the motion of the cart in the x direction and the tipping of the pendulum along the direction of motion by an angle. 2) Equat ions of moti on : The equations of motion for the system are arrived at from the free body diagram. Considering the pendulum: Taking the torque about the centre of mass of the pendulum, I ¨ θ = V lsin(θ) Hlcos(θ) (1) Considering the forces acting on the pendulum, In the horizontal direction: m d 2 dt 2 (x + lsin(θ)) = H (2)

Transcript of Inverted Pendulum Sample

7/31/2019 Inverted Pendulum Sample

http://slidepdf.com/reader/full/inverted-pendulum-sample 1/4

Modelling and control of Inverted pendulum

Jacob JamesMechanical and Aerospace Engineering

University of Florida

Email: [email protected]

 Abstract—This paper models an inverted pendulum, designinga controller for positioning the cart at some position whilekeeping the pendulum in a vertical position. The system iscontrolled with a single force input.

I. INTRODUCTION

The inverted pendulum is a classic control problem that

can be used as the basis for the modeling of many more

complex problems like stabilization of a rocket during

launch, balancing of robots, biped motion planning building

balancing in earthquakes, in design and stabilization of 

personal mobility units and many more applications. Theinverted pendulum is a system that is inherently unstable, and

cannot be balanced without the application of some external

torque. The classic problem deals with the control of the

input torque required to balance the inverted pendulum.

Here the problem of balancing an inverted pendulum

on a carriage is considered. The aim of this exercise to

maintain the pendulum balance while the cart moves to the

required position.

The second section of this paper describes the system,

and derives the dynamic equations of motion for the system.

The system here has two controllable outputs.

The third section derives the state space model for the

inverted pendulum, taking the position of the cart and the

angle of the pendulum as the output variables. The input here

is the force applied on the cart, that has to both position the

cart and maintain the stability of the inverted pendulum.

The fourth section deals with stability analysis for the

system that has been arrived at. The stability analysis of the

system with no feedback applied shows that that system is

unstable as was already known.

The fifth section deals with designing a feedback loop

to position the cart at the required position while maintaining

the stability of the system. The design focuses on achieving

a suitably small settling time for the system

I I . THE CARRIAGE PENDULUM SYSTEM

1) Mechanical set-up of the carriage inverted pendulum

system: The system consists of a carriage constrained to

move along a straight line. Onto this carriage a pendulum is

mounted that is constrained to move along the plane passing

through the line of motion of the cart. The pendulum will tip

over if its centre of gravity does not pass through the hinge

point. Any motion of the cart will also cause the pendulum

to tip over in the opposite direction. The aim of this control

exercise is to move the cart into the required position without

tripping over the pendulum. Here a single input to the system,

the force on the cart has an impact on the coupled output,

i.e. the motion of the cart in the x direction and the tipping

of the pendulum along the direction of motion by an angle.

2) Equations of motion : The equations of motion for the

system are arrived at from the free body diagram. Considering

the pendulum: Taking the torque about the centre of mass of 

the pendulum,

I θ = V lsin(θ) − Hlcos(θ) (1)

Considering the forces acting on the pendulum,

In the horizontal direction:

md2

dt2(x + lsin(θ)) = H  (2)

7/31/2019 Inverted Pendulum Sample

http://slidepdf.com/reader/full/inverted-pendulum-sample 2/4

In the vertical direction:

md2cos(θ)

dt2= V  −mg (3)

Considering the free body diagram of the cart, the horizontal

motion of the cart is given by:

M d2x

dt2

= u− H  (4)

Here H and V are the reaction forces along the horizontal

and vertical direction.

To linearise this model the motion of the pendulum is restricted

to a small angle on either side of the article. Under this

condition it can be assumed that the following relations hold

true:

sin(θ) = 0 (5)

cos(θ) = 1 (6)

These assumptions equation 1 through 3 become,

I θ = V lθ − Hl (7)

mx + mlθ = H  (8)

V  −mg = 0 (9)

From 4 and 6

(M  + m)x + mlθ = u (10)

And form 5 and 7:

I  + ml2θ + mlx = mglθ (11)

III. STATE

SPACE

MODEL

To model this system as a state space problem, the outputs

are identified as pendulum angle and cart position x. For

deriving a state space model let us assume the mass to be

concentrated at the top of the pendulum, and the pendulum

rod to be massless. In this case the I becomes 0.

The state variables can then be defined as x1, x2, x3, x4

x1x2x3x4

=

x

x

θ

θ

These relations together give the dynamic equations of motion of the cart pendulum system. The output matrix for

the system becomes

y =

x

θ

Then from the above definition of our state we get

x1 = x2 (12)

x3 = x4 (13)

TABLE IPARAMETERS FOR THE SYSTEM

Parameters Value

Cart Mass M 5kgPendulum Mass m 1 kg

Pendulum Length 2l 1 m

Fig. 1. System response to step input

From equation 5 & 6 and taking I to be zero as per our

assumption.

x2 =M  + m

Mlgxl −

1

Mlu (14)

x4 = −m

M gxl −

1

M u (15)

The state space model for the system becomes:

x = Ax + Bu (16)

which is:

x1x2x3x4

=

]

0 0 0M +m

Mlg 0 0 0

0 0 0 1−

m

M g 0 0 1

x1x2x3x4

+

0−

1

Ml

01

m

u

The output equation for the system becomes:

y =

x

θ

=

1 0 0 00 0 1 0

x1x2x3x4

IV. STABILITY ANALYSIS

 A. Parameters for the system

For carrying out further analysis the following parameters

are assumed and listed in Table 1.

 B. System Response

The response of the system without feedback for a step input

is then plotted.

Plotting the response of the system to an input force of 

.5 newton gives the following response. It is evident that the

7/31/2019 Inverted Pendulum Sample

http://slidepdf.com/reader/full/inverted-pendulum-sample 3/4

system is unstable and the pendulum gets knocked over.

The poles of the system are found to be

λ = 0, 1, 6.766,−6.766

The two poles 1 & 6.7661 lie on the right half of the complex

plain, and 0 lies on the imaginary axis. The system is hence

unstable. A feedback loop is necessary to obtain the required

positioning of the system.V. CONTROLLER DESIGN

 A. Controllability Check 

Before beginning the controller design the controllability of 

the system is checked. The C matrix is found to be

C =

0 −6.6667 0 −305.2−6.6667 0 −305.2 0

0 2 2 28.162 2 28.16 28.16

(17)

The C is found to be full rank. Hence the system is

controllable.

 B. Controlled Design

The pole placement for the system is done using the matlab

command lqr. Matlab uses the function

J (u) =

∞ 0

(xT Qx + uT Ru + 2xT N u)dt (18)

Where Q & R are weighting parameters. Minimizing J  aims

at minimizing control energy and minimum state deviation.

The Q is a diagonal matrix which weights each element of 

the state. The system response can be tuned by changing the

weighting value for each parameter, a higher value indicating

a larger significance and more control energy dedicated to

the control of the particular state. Larger values of  R relative

the Q a larger energy being spend to keep the deviations of 

the state to a minimum.

Here the only parameters that need to be weighted are the

x and θ. The weighting matrix thus is taken to be

Q =

q1 0 0 00 0 0 00 0 q2 00 0 0 0

(19)

where q1 is the weighting for the position and x and q2 isthe weighting parameter for θ. The weighting for x and θ is

taken to be zero. R is assigned a value of 1. Trying different

weighting conditions for the position x and the pendulum

angle θ it is observed that a higher weighting value for q1& q2 results in a better response for the system. The response

for

q1 = 1500

and

q2 = 100

was found to be satisfactory.

Using the lqr command the gain matrix is found to be

k =−103.414 −12.7174 −10 −24.7867

The position plot for step input to the system with feedback 

shows that there is a steady state error in the angle θ and thecart never reaches the desired position x but instead moves

back. This can be corrected by scaling the input. The scaled

input response is as shown. The poles of the system with

feedback is found to be λ = −16.1207+14.634ı,−16.1207−14.6340ı,−0.984+0.6414ı,−0.984−0.6414ı This controller

satisfies all the requirements placed at the commencement of 

the design.

V I . OBSERVER DESIGN

The controller design was carried out assuming availability

of all the states. This is not the case with most cases. To

obtain the states for the use in the controller an observer

needs to be designed. The system first needs to be checkedfor observability.

O =

1 0 0 00 0 1 00 1 0 00 0 0 1

45.78 0 0 0−3.924 0 0 1

0 45.78 0 0−3.924 −3.924 0 1

The O matrix is full rank and thus observable.

The pole placement should ensure a quicker convergence on

the states by the observer than that shown by the controller.This ensures that the system performance is only affected by

the controller response time and not the observer response.

Pole position at a location 5-8 times further away form the

 jω than the controller poles axis should ensure a sufficiently

quick response. The observer thus needs to have its poles at

λ = −80,−80,−4,−4.

The quickest way to design the observer will be to use

the MatLab command place to place the poles. The place

command cannot be used with repeated poles and hence the

7/31/2019 Inverted Pendulum Sample

http://slidepdf.com/reader/full/inverted-pendulum-sample 4/4

poles can be taken to be λ = −80,−81,−4,−5.

The observer for the system then is:

˙x = Ax + bu + l [y − cx]

]

x(0) = x0

l =−2.0695 −6.2454

45.0151 0.3476−6.404 2.0695−4.1531 −0.7366

 A. Response under observer design

The response of the system using the observed states for

feedback is plotted.

VII. CONCLUSION

The system designed here gives a model for the control of 

a simplified inverted pendulum. A real system will have many

more issues that needs to be dealt with such as the forces like

friction that have not been considered here. It will also need

to take into consideration noise. This serves design serves asthe starting point for a more robust design for applications

ranging from the balancing of robots to controlling of rockets

while launch.

ACKNOWLEDGMENT

REFERENCES

[1]