0% found this document useful (0 votes)
38 views

'Cart (X) ' 'Pendulum (Phi) ' 'Time (Sec) '

This document describes the simulation of an inverted pendulum system using state space models and linear quadratic regulator (LQR) control. It contains the system matrices F, G, Q, and R used in a dlqr controller design. It then simulates the closed loop system response using dlsim and plots the cart position and pendulum angle over time. It also plots the cart position vs pendulum angle phase plane. Finally, it describes designing a reduced order observer to estimate the pendulum angle and cart velocity for controller feedback.

Uploaded by

vayalo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

'Cart (X) ' 'Pendulum (Phi) ' 'Time (Sec) '

This document describes the simulation of an inverted pendulum system using state space models and linear quadratic regulator (LQR) control. It contains the system matrices F, G, Q, and R used in a dlqr controller design. It then simulates the closed loop system response using dlsim and plots the cart position and pendulum angle over time. It also plots the cart position vs pendulum angle phase plane. Finally, it describes designing a reduced order observer to estimate the pendulum angle and cart velocity for controller feedback.

Uploaded by

vayalo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

0 0 0 0;

0 0 y 0;
0 0 0 0];
R = 1;
K = dlqr(F,G,Q,R)

Nbar = -60;

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];

[Y,X] = dlsim (Fce,Gce,Hce,Jce,U);


stairs (T,Y)
legend ('cart (x)','pendulum (phi)')
xlabel('Time(sec)');
figure ()
plot(Y(:,1),Y(:,2))
legend ('X','?')
xlabel('X');ylabel('?');

0.25
cart (x)
pendulum (phi)
0.2

0.15

0.1

0.05

-0.05

-0.1
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time(sec)
0.25
X

0.2

0.15

0.1

0.05

-0.05

-0.1
-0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25
X

5. Design a reduce order observer that provided the derivates of theta


and x to the controller, then check if able to balance pendulum

We have matrix A[ 0 1.0000 0 0


0 0 -3.9200 0
0 0 0 1.0000
0 0 45.7333 0]

With eigen values 0, 0, 6.7626, -6.7626


Then we choose a (3x3) Matrix with eigen values -1, -2, -3
Then F = [-1 0 0; 0 -2 0; 0 0 -3]
Then we have l=[1;1;1]
We check that controllable by using Matlab commands:
co=ctrb(F,l)
rank(co)
Rank of co is 3 then controllable
We use Lyap in order to find T matrix:
T=LYAP(-F,a,l*c)
T=
-1.0000 1.0000 -0.0876 0.0876
-0.5000 0.2500 -0.0470 0.0235
-0.3333 0.1111 -0.0356 0.0119

Then the (n-1) dimentional state equation


Z=F z + Tb u + ly
e= z –Tx
We use the following Matlab code in order to plot system:
clear all;
M=0.5; %Mass cart
m=0.2; %Mass bob
g=9.8; %Gravity
l=0.3; %length pendul

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];

F = [-1 0 0; 0 -2 0;0 0 -3];

l=[1;1;1]

T =[-1.0000 1.0000 -0.0876 0.0876;


-0.5000 0.2500 -0.0470 0.0235;
-0.3333 0.1111 -0.0356 0.0119]

tb=T*b;
T=0:0.1:5
c2=[1 0 0];
[Y,T]=step(F,tb,c2,0);

legend('Cart (x)','Pendulum (phi)')


plot(T(:,1),T(:,2))
legend ('X','T')
xlabel('X');ylabel('T');

Output of the program:

You might also like