# The Project Is Based On Control Tutorials English Language Essay

**Published:** **Last Edited:**

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

The project is based on control tutorials for Matlab developed by members at the University of Michigan (UMICH) and Carnegie Mellon University (CMU). They are good sources which are designed to help us how to use Matlab for the analysis and design of automatic control systems. The material taught at the University of the West of England (UWE) by professor Zhu, Q. is a background for this research. This project is also covered by Modern control engineering book written by Ogata, K. (2002) and combined by other useful websites to provide a good survey.

Chapter 1 presents a brief introduction and an outline of the project. An inverted pendulum is described in detail from introduction to its importance in control system design field. This report also gives the math background for an inverted pendulum with main contents which are fixed pivot point, pendulum mounted on a cart and pendulum with oscillatory base (Wikipedia, 2008). This chapter also briefly introduce the state space representation of single-input and single-output (SISO) systems and multi-input and multi-output (MIMO) systems which are based on the lectures which taught by professor Zhu, Q. (2008-2009) in UWE.

Chapter 2 covers setup and analysis in dynamic model based on UMICH and CMU websites (1997). The design requirements of inverted pendulum system in this project are similar with the other inverted pendulum models, but different parameters. After analysing the model, the Simulink is used to build the dynamic model to test the responses. This section is also based on UMICH and CMU websites (1997) and a knowledge background based on the lectures of professor Zhu, Q. (2008-2009) to use Matlab program.

Chapter 3 gives initially design of inverted pendulum control by state space method. The state space representation this project is covered by Modern control engineering book written by Ogata, K. (2002). Then, a full order state feedback control is designed to balance the inverted pendulum. This section has included by the materials based on UMICH and CMU websites (1997-1998), Ogata, K. (2002) and the lectures taught by professor Zhu, Q. (2008-2009).

Chapter 4 proposes for the work in level-M. Adaptive nonlinear control scheme will be upgraded to stabilise the inverted pendulum. A novel control design technique called backstepping control will be used to make inverted pendulum rod upwards (Altinoz, O.T., 2007). This part is also covered by Adaptive control book which is written by Astrom, K.J. and Wittenmark, B. (1995).

Good sources are an essential basis to support this project. The project is also supported by other sources which are given detail in references. This project uses the similar way with other projects about inverted pendulum and combines with my own knowledge about control systems design to perform.

## CHAPTER 1: INTRODUCTION TO INVERTED PENDULUM AND STATE SPACE REPRESENTATION

## INTRODUCTION

The inverted pendulum has been researched by many authors in control system design field with various ways which are good references. In this project the inverted pendulum is setup and analysed with similar design requirements, but with different parameters. For PID, root locus, and frequency response method cannot be applied in the control of inverted pendulum. This is because these techniques can only be applied for single-input and single-output (SISO) systems, but the inverted pendulum is a multi-input and multi-output (MIMO) system. Thus, a design of control systems in state space is decided to use in this research. The aims of the project are to do a survey from introduction to application for the inverted pendulum system, and the state space representation of the SISO systems and the MISO systems are also briefly introduced. Then setup and analyse the inverted pendulum system in model, and also give detail the requirements need to be satisfied for the system. After that, the model is built by using Simulink (Block diagrams) on Matlab program to test and analyse the response. Finally, design of a full order state feedback controller is performed on calculation and on Matlab program to implement the design by running the simulation tests and the analysis on the results. This report also outlines the future work for the M-level in next year.

## WHAT IS INVERTED PENDULUM?

An inverted pendulum is a physical device which has a pendulum (or a bar) with its mass above a pivot point. The pivot point is mounted on a cart (or a carriage) that can move on a horizontal direction. Because of the combination of the pivot point and a cart in a system, an inverted pendulum may be also called a cart and pole. An inverted pendulum is different from a pendulum at stability. While a pendulum is always stable at bottom vertical position, an inverted pendulum naturally tends to fall down from the top vertical position, which is an unstable position. To balance an inverted pendulum or to stabilize a pendulum on the top vertical, one of two methods can be used by applying a torque at the pivot point or by moving the pivot point on a horizontal direction as a part of a feedback system.

There is another method to balance for the inverted pendulum by oscillating the support rapidly up and down. This way is performed without requiring any feedback or control mechanism. In terms of acceleration and amplitude, if the oscillation is strong enough then the inverted pendulum can stabilise from the bottom vertical to the top vertical. However, if the point moves harmonically, the motion equation of the pendulum will perform following the Mathieu equation.

Figure 1 and 2 shows two types of inverted pendulum on cart.

Figure 1: Schematic of inverted pendulum on a cart.

Figure 2: Double inverted pendulum mounted on a cart.

## IMPORTANCE IN APPLICATION

The inverted pendulum has been used in the most applications of dynamics and control theory. For testing control algorithms, it is applied very popular such as PID controllers, neural networks, fuzzy control, genetic algorithms, etc. In these applications, the inverted pendulum controller is running by allowing the motion of the cart to be controlled while keeping the pendulum upright, and balancing the cart-pendulum system on a see-saw.

This inverted pendulum is used in rocket and missile with role of balance or keeping direction, where it is a thrust at the bottom of a tall vehicle. For the similar problem, the inverted pendulum is applied to Segway which is the first two-wheeled, self-balancing, electric transportation device to help you move easily, efficiently, intelligently, and simply. The largest performance of the inverted pendulum application is on big lifting cranes on shipyards. With characteristic of the inverted pendulum, the cranes can move perfectly and stop quickly the huge shipping containers without swings and sways under the control of operator.

## MATH BACKGROUND OF INVERTED PENDULUM

## Fixed pivot point

## From vertical unstable equilibrium position, the equation of motion for an inverted pendulum is

## (This equation is similar to the equation of motion of pendulum, but it's different from the sign of the angular position)

## When moving to the right side, the equation of motion becomes

## The inverted pendulum will accelerate away from the vertical unstable equilibrium. The acceleration is inversely proportional to the length. It means an inverted pendulum with a tall pendulum will accelerate slowly than an inverted pendulum with a short pendulum.

## Pendulum mounted on a cart

## In figure 1 at appendix A, x (t) is the position of the cart.is the angle of the pendulum from the vertical direction.

## Applying Lagrange's equation to the equation of motion for a pendulum on a cart with the acting forces are gravity and an external force in the x direction:

## The Lagrangian L= T - V

## Where T is the kinetic energy

## V is the potential energy

## L can also be expressed as

## Where is the velocity of the cart

## is the velocity of the point mass m

## In terms of x and, and can be expressed as

## (1)

## (2)

## Then

## Put (1) and (2) into the Lagrangian L

## (3)

The equations of motion are

Put (3) into the above equations of motion, then obtain the equations of motion of the inverted pendulum

Both of equations are nonlinear, however, to balance the inverted pendulum or to keep the pendulum upright, these equations can be linear with

## Pendulum with oscillatory base

By the same way of the inverted pendulum on a cart, the motion equation of a pendulum with an oscillatory base can be obtained by using Lagrange's equations for the inverted pendulum on figure 3.

http://upload.wikimedia.org/wikipedia/en/thumb/8/80/Pendulum-osc.png/200px-Pendulum-osc.png

Figure 3: Schematic of inverted pendulum on an oscillatory base.

Here is the position of the point mass:

Similar to the inverted pendulum, the velocity can be derived

The Lagrangian for the pendulum with oscillatory base can be expressed as

The equation of motion can be written as

Substitute L in the equation of motion gives

Then

(4)

From this equation, if (y represents a simple harmonic motion), the equation (4) becomes

(5)

From the solution for the equation (5) shows that the pendulum can balance for fast oscillations.

In figure 4 when y is a slow oscillation, the pendulum has fallen on the ground after the angle exceeds 90 degrees in a short time.

Figure 4: Response of pendulum on a slow oscillation

In figure 5 shows when disturbed from the vertical position, the pendulum begins an oscillation around the angle. The pendulum keeps balancing with the small deviation from the vertical position.

Figure 5: Response of pendulum on a fast oscillation

## INTRODUCTION TO STATE SPACE REPRESENTATION

A state space representation is a mathematical model of a physical system in control engineering. It is a set of inputs, outputs and state variables which are related by the first order differential equations. In the state space representation, the variables which are inputs, outputs and states are expressed as vectors, the differential and algebraic equations are written in matrix form. It is known as the time domain approach and is the good way to model and analyse the multi-input and multi-output systems. With m inputs and n outputs, the information of a system can be encoded by m Ã- n Laplace transforms. The state space representation can be applied without limit to systems with linear components and zero initial conditionals. In the phrase "state space", it means the space whose axes are state variables and the state can be represented as a vector within the space.

A general state space representation of a linear time invariant system with m inputs, l outputs, and n state variables can be expressed as

Where,

Input vector

Output vector

State vector

Dynamic matrix An*n is used to describe the dynamics of the system and control the trajectory of the state vector x(t). (The motion of the tip of the state vector in state space is called the trajectory of the state vector).

Input matrix Bn*m shows how each control input affects the state variables of the systems.

Output matrix Cl*n is used to transform the state vector x(t) into the output vector y(t).

Transmission matrix Dl*m indicates the direct (feedforward) effect of control inputs to output vector y(t).

The combination of four matrices is called system matrices, and a system which made by these matrices is denoted by S(A,B,C,D)

Figure 6: A general block diagram of a system S(A,B,C,D).

From figure 6, the transfer function matrix can be written as

Where

## 2.5.1 SINGLE-INPUT AND SINGLE-OUTPUT (SISO) SYSTEMS

A general transfer function of SISO systems can be expressed as

Where d is a constant.

(a) Realisation using controllable canonical form (or controllable form in short)

State equation

Output equation

(b) Realisation using observable canonical form (or observable form in short)

State equation

Output equation

The controllable and observable form realisations are shown by block diagrams in figure 7 and 8.

Figure 7: Controllable form

Figure 8: Observable form

## 2.5.2 MULTI-INPUT AND MUTI-OUTPUT (MIMO) SYSTEMS

MIMO systems can be expanded easily from the SISO systems with state space equations. Change the input u(t) into a vector U(t) to represent multiple inputs, and also change the output y(t) into a vector Y(t) to represent multiple outputs. With the state space method of MIMO systems the outputs must be linearly dependant on the input vector and the state vector.

Assume that the system has two inputs, u1and u2, and two outputs, y1 and y2. In this system these inputs and outputs are related through the differential equations

Assign state variables and produce the first-order differential equations

x1 = y1

x4 = y2

x1' = y1' = x2

x2' = âˆ’ a1x2 âˆ’ a0(x1 + x4) + u1(t)

x4' = âˆ’ a2(x4 âˆ’ x1) + u2(t)

Then assemble the state equations of the MIMO system

The state space representation of MIMO systems is not unique. There are infinitely many ways of representation for MIMO systems.

## CHAPTER 2: SETUP AND ANALYSIS IN DYNAMIC MODEL

## SETUP AND DESIGN REQUIREMENTS

From figure 9 the cart is affected by an impulse force F. In the design assume that the inverted pendulum keeps balancing or it doesn't move more than a few degrees away from the upright position. So, the dynamic equations of motion for the inverted pendulum system need to be determined, and the angle between the pendulum and the vertical is about 0 ().

invpen

Figure 9: Design of inverted pendulum on a cart

The design requirements for the inverted pendulum system is given

Mass of the cart M = 1kg

Mass of the pendulum m = 0.25kg

Friction of the cart b = 0.1 N/m/sec

Length from the cart to the pendulum centre of mass L= 0.25m

Inertia of the pendulum I = 0.006 kg

Force acting on the cart F

Cart position coordinate x

The pendulum's angle

The PID, root locus, and frequency response methods can only be used to control the pendulum's position. They are useless in the control of the cart's position, because these techniques can only be applied for the single-input and single-output (SISO) systems. So, there is not any design standard deal with the cart's position. For these methods assume that the system begins at equilibrium, and affected by an impulse force F = 1N. The pendulum should go back to the upright position within 5 seconds, and doesn't move more than 0.05 radians away from the vertical.

Therefore, the inverted pendulum design requirements are

Rise time for the cart is less than 1 second.

Settling times for the cart and the pendulum are less than 5 seconds.

Overshoot of the pendulum is less than 20 degrees

Steady state error in the range 2%.

## ANALYSIS OF A SYSTEM MODEL

The system is shown in figure 2 at appendix A, the pin joint between the cart and pendulum which reduces freedom. This is the problem for modeling the system in Simulink. Both of cart and pendulum have one degree of freedom which respectively are the X and the. By applying Newton's equation for these two degrees of freedom:

To include the interaction forces N and P between the cart and the pendulum, the additional x and y dynamics of the pendulum are required to model.

Then represent the derivatives of and in terms of the derivatives of the, because,and are the same functions.

These equations then will be expressed for N and P.

## MODEL LINK OF INVERTED PENDULUM IN SIMULINK

Before model the system in Simulink, firstly need to summarise the main force equations in the previous section.

(1)

(2)

(3)

(4)

(5)

(6)

In this project the Matlab 7.6.0(R2008a) is used to implement and analyse for the inverted pendulum controller.

Type "simulink" in Matlab to start modelling the inverted pendulum design in Simulink

In the Simulink library browser, open a new model window by click File-New-Model or Ctr+N.

The model blocks in this design are in the Simulink, so click a sign "+" in a front of the Simulink to insert the blocks for the model.

Model the design following the main equations:

## Equation (1):

Insert two Integrator blocks from the commonly used blocks, and connect them in series.

Draw a line from the second Integrator block, and label it "x" by double clicking where you want to go.

Put the label "dx/dt" for the line between the two integrators, and draw a line leading the first integrator with the label "d^2(x)/dt^2" (It means d2x/dt2).

Insert a Gain block from the commonly used blocks to the left of the two integrator blocks, and connect it to the d2x/dt2 line. Then edit the value of the gain by double clicking on this block, change it to "1/M", and label it "Cart Mass".

Insert a Sum block from the Math operations (sum of elements) to the left of the cart mass with the label "Sum forces on cart", change its signs to "-+-". Connect this block to the cart mass.

Insert a Gain block above the cart mass with the value "b", the label "Damping" and flip this block left to right by right clicking Format-Flip Block or Ctr+I, and connect its input to the "dx/dt" line, its output to the top negative sign of the sum forces on cart input.

The model of the equation (1) is given in figure 10:

Figure 10: Model of equation (1).

## Equation (2):

Construct the second equation with the similar way as the previous equation, and change the label "x" into "theta". The Gain block should have the value "1/I" and the label "Sum Inertia". The Sum block should have the label "Sum Torques on Pendulum" and its signs "++".

Insert two Trigonometric function blocks from the Math operations and put them above the second theta integrator.

Edit an upper Math block with the value "cos" and the label "Vertical".

Keep the value "sin" for a lower Math block and label it "Horizontal".

Flip both of them left to right.

Connect the output of the second theta Integrator block to the inputs of the Sin block and the Cos block by drawing the lines between these blocks.

Insert a Gain block to the left of the Cos block, and then edit the value to "L" with the label "Pendulum length".

Flip this block left to right and connect its input to the output of the Cos block.

By the same way, insert a Gain to the left of the Sin block. Edit the value to "L" with the label "Pendulum length 1". Then flip it left to right and connect its input to the output of the Sin block.

Draw long horizontal lines leading from the outputs of both of Pendulum length blocks. Put the label "Lcos(theta)" for the upper line and "Lsin(theta)" for the lower line.

Insert two Product blocks from the Math operations next to each other to the left and above the Sum Torques block. They are used to multiply for the forces N and P by their components.

Rotate these Product blocks 90 degrees by right clicking them and select Format, then select Rotate Block or Ctr+R.

Connect the left Product block to the lower input of the Sum Torques block and also connect the right Product block to the upper input of the Sum Torques block.

Connect the Lsin(theta) line to the right input of the right Product block.

Connect the Lcos(theta) line to the right input of the left Product block.

The model of the equation (2) is given in figure 11.

Figure 11: Model of equation (2).

## Equation (3) and (4):

Insert a Gain block to the under Sum forces on Cart block and edit its value to "m" and its label to "Pendulum mass". Flip this block left to right and connect its output to the N line. Then draw a short line leading from the input of this Gain block and label it "d^2(xp)/dt^2".

Copy the pendulum mass block and put under that block with a new label "Pendulum mass 1". Connect its input to the line P.

Insert a Sum block to the right of the pendulum mass 1 block with its signs "++". Flip this block left to right and connect its output to the input of the pendulum mass 1 block.

Draw a short line leading from the input of the Sum 2 block and label it "d^2(yp)/dt^2".

Insert a Constant block from commonly used blocks to the right of the new Sum block. Then change its value to "g" and its label to "Gravity". Connect its output to the Sum 2, and then obtain the model in figure 12.

Figure 12: Model of equation (1), (2), (3) and (4).

## Equation (5):

Insert a Sum block to the right of the pendulum mass block, and change its signs into "++-". Connect the upper plus sign input of this Sum block to the line d^2(x)/dt^2.

Also insert two Product blocks, one to the right of the Gravity block, then flip this block left to right and rotate it 90 degrees. Connect the output of this block to the minus sign input of the Sum 1 block. Connect one input of this Product block to the line Lcos(theta) and another input is connected to the line d^2(theta)/dt^2.

Another Product block is inserted to the above Cos block. Flip this block left to right and rotate it 90 degrees. Then connect its output to the middle plus sign input of the Sum 1 block. One input of this block is connected to the line Lsin(theta). After that, insert another Product block to the above line d(theta)/dt with two inputs of this Product block are connected to that line. This Product block is a model of (d(theta)/dt)^2 and connect its input to one input of the Product 2 block. Figure 13 shows the model after inserting equation 5.

Figure 13: Model of equation (1), (2), (3), (4) and (5).

## Equation (6):

Similar to the equation (5), insert a Sum block with its signs "--". Connect the output of this block to the upper plus sign input of the Sum 2 block. Also insert a Product block with one input connected to the output of the Product block which is to model for (d(theta)/dt)^2, another input connected to the line Lcos(theta). Then the output of this Product block is connected to one input of the new Sum block.

Insert a Product block with one input connected to the line Lsin(theta), and one input connected to the line (d^2(theta)/dt^2). Connect the output of this block to the input of the Sum block as figure 14.

Figure 14: Model of inverted pendulum.

Now, apply a unit impulse force input F and view the pendulum angle and cart position.

Insert a Pulse Generator block from the sources in Simulink library browser and connect it to the force F.

Insert two Scopes from the commonly used blocks in Simulink library browser. One scope is connected to the theta output, and another one is connected to the x output. Then, figure 15 is obtained:

Figure 15: Model of inverted pendulum connected to Pulse Generator block and two Scope blocks.

Double click on the Pulse Generator block to change its values:

Period (secs): 10 (A long time between a chain of impulses)

Pulse Width (% of Period): 0.01 (It means 0.01% x Period=0.01%x10=0.001 second).

Amplitude: 1000 (It means1000 x 0.001= 1, an approximate unit impulse).

This is shown in figure 16:

Figure 16: Dialog box of Pulse Generator block.

Before running the inverted pendulum design in Simulink, it is necessary to set the physical constants. Enter the following commands at a command window:

M = 1

m = 0.25

b = 0.1

I = 0.006

g = 9.8

L = 0.25

Now, set an appropriate simulation time to view the response.

Select parameters from the simulation menu.

Change the stop time value to 2 seconds.

Open both scopes and choose the auto scale button to get the responses of the theta and the x.

Amplitude

Time(sec)

Figure 17: Response of x with Stop Time value 2s.

Amplitudee

Time(sec)

Figure 18: Response of theta with Stop Time value 2s.

In figure 17 and 18, the pendulum swings all the way around due to the force F, and the cart moves along with a jerky motion due to the pendulum. This shows that the inverted pendulum is an unstable system.

## CHAPTER 3: DESIGN OF INVERTED PENDULUM CONTROLLER IN STATE SPACE

## STATE SPACE REPRESENTATION

Base on figure 2 at appendix A, perform some calculation to obtain the equations of state space representation for the inverted pendulum system:

Summing the forces in the free body diagram of the cart in the horizontal direction:

(1)

Summing the forces in the free body diagram of the pendulum in the horizontal direction:

(2)

From (1) and (2),

(3)

Summing the forces perpendicular to the system:

(4)

Summing the moments around the centre of the pendulum: (5)

From (4),

(6)

From (4) and (6),

Then, obtain two equations of motion:

Matlab can only work with linear systems, so these equations should be linearized about = Pi. Assume that = Pi + ø, where ø represents a small angle from the vertical upward direction.

Thus,

cos() = -1

sin() = - ø

After linearization the two equations of motion become:

(8)

From (7),

(9)

Substitute (9) in (8),

(10)

From (8),

(11)

Substitute (11) in (7),

(12)

Define state variables x1, x2, x3 and x4 by

Consider and x as the outputs of the system, then

From the definition of the state variables and equations (10) and (12),

In terms of vector-matrix equations, gives the state space equations of the inverted pendulum system.

Substitute M=1, m=0.25, b=0.1, I=0.006, g=9.8, L=0.25 in the above state space equations, obtains the equations

Use Matlab to check the results of state space representation. This section is shown at program No.1 in appendix B. The results on a command window are the same on calculation.

## DESIGN OF A FULL ORDER STATE FEEDBACK

After obtaining the state space equations, to design a full order state feedback the following design steps need to do:

Design step 1: Check for controllability and observability of the system. They play an important role in the design of control systems in state space to make sure that the system is completely controllable and observable to use the following steps for finding a state feedback matrix and a state observer matrix.

Design step 2: Design a state feedback controller to estimate the state variables for feedback. Find the state feedback matrix by the quadratic optimal control method. An advantage of this method over the pole placement method is that the former provides a systematic way of computing the state feedback control gain matrix. Moreover, the inverted pendulum system is a MIMO system which is not easy to choose a desired closed loop poles for the state feedback if using the pole placement method. The schematic of this control system is shown in figure 19.

Figure 19: Schematic of inverted pendulum control system with state feedback

Design step 3: Adding the reference input to eliminate a steady state error. In the step 2, by multiplying the gain vector K, and then subtract this result from the reference. This uses to measure all states. To remove this error, need to scale the reference input to make it equal to K*x steady state. In this project, the reference input is one of four values in the matrix K. The scheme of the control system after adding a reference is shown in figure 20.

Figure 20: Schematic of inverted pendulum control system after adding a reference.

Design step 4: Design a state observer controller to estimate unavailable state variables for feedback. Find a state observer matrix by using the desired closed loop observer poles which are faster 10 times than the desired closed loop poles state feedback poles. In this step, use Matlab program to get the desired closed loop state feedback poles from the state feedback matrix K. Then, the desired closed loop observer poles are 10 times the desired closed loop state feedback poles. The schematic of the control system now is shown in figure 21.

Figure 21: Schematic of control system with a full order state feedback.

Next, perform 4 design steps which have just presented above. Most of these steps need to use Matlab to compute. Because there are matrixes (4Ã-4), they are quite difficult to manipulate.

## DESIGN STEP 1:

## Controllability

A criterion to check the state controllability:

## Observability

A criterion to check the observability:

## Add to the last M-file these commands:

co=ctrb(A,B) %Compute the controllability matrix.

Controllability = rank (co) %provides an estimate of the number of linearly

%independent rows or columns of a matrix co.

ob = obsv (A,C) %Compute the observability matrix.

Observability = rank (ob) % provides an estimate of the number of linearly

%independent rows or columns of a matrix ob.

## On the command window, the results are:

co =

0 2.7027 -0.2527 89.5050

2.7027 -0.2527 89.5050 -9.5791

0 0.9351 -0.0874 4.4822

0.9351 -0.0874 4.4822 -0.8375

Controllability =

4

ob =

1.0000 0 0 0

0 0 1.0000 0

0 1.0000 0 0

0 0 0 1.0000

33.1081 0 0 -0.2703

1.6554 0 0 -0.0935

-0.4474 33.1081 0 0.0253

-0.1548 1.6554 0 0.0087

Observability =

4

Hence, the system is completely state controllable and observable.

## DESIGN STEP 2:

Using the reduced-matrix Riccati equation to find P:

Where Q is a positive-definite or a real symmetric matrix:

In Q matrix, the element in the 1,1 position will be used to weight the pendulum's angle and the element in the 3,3 position will be used to weight the cart's position.

R is a positive-definite or real symmetric matrix: R= [1]

The optimal feedback gain matrix K is obtained as

With the state feedback control, the state equation now is:

Hence,

## Add these commands to the M-file and run it:

x=1;

y=1;

Q=[x 0 0 0;

0 0 0 0;

0 0 y 0;

0 0 0 0];

R = 1;

K = lqr(A,B,Q,R) %Compute optimal state feedback gain matrix.

Ac = [(A-B*K)]; %New value of matrix A in state feedback controller

Bc = [B];

Cc = [C];

Dc = [D];

T=0:0.01:5;

U=0.2*ones(size(T)); %Apply step input 0.2 to the cart.

[Y,X]=lsim(Ac,Bc,Cc,Dc,U,T); % plots the time response of the system to the

% input signal described by U and T

plot(T,Y)

legend('Pendulum','Cart')

## The results of K and a response plot in figure 22 on the command window are:

K =

30.5845 5.4007 -1.0000 -2.0369

Amplitudee

Time(sec)

Figure 22: Step response with an optimal state feedback control

This plot is not satisfactory. The overshoots for both of pendulum and cart are fine. However, their settling times need to improve and the rise time of the cart should be down. This is because the cart is not near the desired location, so the cart has moved to other direction. Now, change the value of x=100 to and y=5000 to get a new value of K and to see the different response in figure 23.

The new value of K is:

K =

118.9952 21.9437 -70.7107 -39.3482

Amplitudee

Time(sec)

Figure 23: Step response with an optimal state feedback control after changing x=100 and y=5000.

In figure 23, the settling times of cart and pendulum are under 2 seconds. The response of the pendulum is fine, but need to improve the cart response.

## DESIGN STEP 3:

From the design step 3,

Put each value of K into Bcn=kdesired*B in the M-file, and then run it to get the chosen k for the reference input. After testing 4 times, the reference input should be KI= kdesired =-70.7107.

## Add these commands to the M-file:

Bcn=[-70.7107*B];

[Y,X]=lsim(Ac,Bcn,Cc,Dc,U,T);

## Then obtain the new response of the system in figure 24:

Amplitudee

Time(sec)

Figure 24: Step response with an optimal state feedback and a reference input.

In figure 24, the pendulum and the cart satisfy the design requirements:

Pendulum' positive overshoot is about 6-7% and negative overshoot is about 13-14%.

Their rise times are less than 1 second.

Their settling times are less than 2 seconds

Steady state error is fine.

## DESIGN STEP 4:

With the state observer, the state equation becomes:

Thus,

A matrix A becomes

## Add these texts to the M-file:

P =eig(Ac); %To get the desired closed loop poles of the state feedback.

Pe=10*P; % To obtain the desired closed loop poles of the state observer.

Ke = place(A',C',Pe)' %To find a state observer matrix.

Ace = [A-B*K B*K;

zeros(size(A)) (A-Ke*C)];%zero(size(A))is the same size as A and all %zeros.

Bce = [Bcn;zeros(size(B))];

Cce = [Cc zeros(size(Cc))];

Dce = [0;0];

T = 0:0.01:5;

U = 0.2*ones(size(T));

[Y,X] = lsim(Ace,Bce,Cce,Dce,U,T);

plot(T,Y)

legend('Pendulum','Cart')

## Run the M-file, and then get a new response in figure 25.

Amplitudee

Time(sec)

Figure 25: Step response with a full order state feedback

The responses are the same in figure 24 and 25. The design of a full order state feedback for inverted pendulum system is completed. However, if change the values of x and y, then the new results can be obtained. For example, x=100 and y=500000, the new response is shown in figure 26:

Time(sec)

Amplitudee

Figure 26: Step response of a full order state feedback with x=100 and y=500000.

The response in figure 26 is quite good with the small overshoot of the pendulum. However, in practice the control engineers try to keep x and y small as possible to reduce the control effort. Higher x and y is more control effort is needed, but small tracking error.

Note: The program of a full order state feedback is at program No.2 in appendix B.

## CHAPTER 4: PROPOSALS FOR THE WORK IN LEVEL-M

Next year a nonlinear design technique called backstepping that will be upgraded for designing the inverted pendulum. The key idea of backstepping is to derive an error equation and to construct a control law and a parameter adjustment law such that the state of the error equation goes to zero. The adaptive backstepping controller for inverted pendulum will be designed by using the general motion control model. Based on Lyapunov design approach backstepping is a novel nonlinear control technique, used when higher derivatives of parameter estimation appear. In the project the mathematical model of the inverted pendulum will be converted into the motion control model for easy parameter adaption. This will be performed by taking functions of unknown parameters and dynamics of the system. By using this method, the inverted pendulum will be simulated without any information about not only parameters but also measurable dynamics. Then, these results will be compared with adaptive backstepping.

This project will also present a survey on nonlinear adaptive control. Especially, it will focus on surveying on adaptive backstepping to help readers and applicant easily to follow the design procedure. Finally, the project will compare and analyse the adaptive backstepping and the state space design based results by running Matlab simulations.

## CONCLUSIONS

The main aims of this project are to do a survey for the inverted pendulum and to investigate and design a full order state feedback controller. This project gave a survey from introduction to application for the inverted pendulum system, and also introduced the state space representation of the SISO systems and the MISO systems. The inverted pendulum was setup and analysed in math background and simulation with the design requirements. The design of a full order state feedback controller were completed is the most successful achievement in this project. The inverted pendulum system balanced with similar rise time and settling time as the previous projects, however the negative overshoot of the pendulum reduced 2% when compared with the results on UMICH and CMU websites.

This project has also proposed for the work in level-M to expand the development of controlling of inverted pendulum system by introducing a design of an adaptive backstepping scheme.

This project has shown the importance of modelling and controlling of inverted pendulum systems in applications. In conclusions, the automatic control has played a vital role in the advance of engineering and science, so most of mechatronical engineers and scientists should now have a good understanding of this field.