









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










x
x
dt
d
.
.
dt
d
p
M
c
2
.
2
.
2
.
2
c p p
p
p
r
p
M
c
2
2
p
2
p
sin
x x
p
cos
y
p
r
m
m g
m
m g
2
2 2
E
M M LR r
K K
M M R r
K K
v
x
M M LR r
K K
M M L
M M g
M M R r
K K
M M
M g
v
x
c p m
m g
c p m
m g
c p m
m g
c p
c p
c p m
m g
c p
p
( 4 )
6
( 4 )
4
0
0
0
( 4 )
6
( 4 )
6 ( )
0
0
( 4 )
4
( 4 )
3
0
0 0 0 1
0 0 1 0
2
2 2
2
2 2
v
x
v
x
( , , , ) ( 0 , 0 , 0 , 0 )
x v
1 2 3 4
E K x K K v K
1
4
.
x Ax Bu t
u Kx
c
.
c
4 3 2 1
.
x u t
a a a a
x
3 4
2
2
3
1
4
sI A s as as as a
1 2 3 4
a , a , a , a
3 4
2
2
3
1
4
1 2 3 4
( s p )( s p )( s p )( s p ) s bs bs bs b
4 4 3 3 2 2 1 1
x
b b b b
x A BK x
4 3 2 1
.
3 4 1 2 3 4
2
2
3
1
4
sI A BK s bs bs bs b s p s p s p s p
4 3 2 1
a a a a
1
0
0
0
B T B
3 4
2
2
3
1
1 * 4
sI A T ( sI A ) T sI A s as as as a
1 2 3 4
a , a , a , a
1
4 4 3 3 2 2 1 1
4 4 3 3 2 2 1 1
1 * *
sI A BK T ( sI A BK ) T sI A B b a b a b a b a
4 3 2 1
0 0 0 1
0 0 1 0
0 1 0 0
b b b b
sI A BK
3 4 1 2 3 4
2
2
3
1
4
sI A BK s bs bs bs b s p s p s p s p
k
t
1 2 3 4
1 2 3 4
t , t , t , t
1 44
2 1 34
3 2 24
4 3 14
4
At a t
At t a t
At t a t
At t a t
t B
1 2 3 4
a , a , a , a
%Enter the A,B,C,D matrices of the inverted pendulum system:
A = [0 0 1 0; 0 0 0 1; 0 -1.7811 -8.8553 0; 0 28.5026 21.7754 0]
A =
0 0 1.0000 0
0 0 0 1.
0 -1.7811 -8.8553 0
0 28.5026 21.7754 0
B = [0 0 1.9814 -4.8724]'
B =
0
0
-4.
C = [0 1 0 0]
C =
0 1 0 0
D = 0
D =
0
%Compute the coefficients a1,a2,a3,a4 of the open-loop characteristic
%equation:
poly(A)
ans =
1.0000 8.8553 -28.5026 -213.6149 0
a1 = ans(2)
a1 =
a2 = ans(3)
a2 =
-28.
a3 = ans(4)
a3 =
-213.
a4 = ans(5)
a4 =
0
%Compute the columns t4,t3,t2,t1 of the T matrix transformation:
t4 = B
t4 =
0
0
-4.
t3 = At4+a1t
t3 =
-4.
-0.
t2 = At3+a2t
t2 =
-0.
-47.
-0.
t1=At2+a3t
t1 =
-47.
-0.
-0.
T = [t1 t2 t3 t4]
T =
-47.7968 0.0000 1.9814 0
-0.0000 -0.0008 -4.8724 0
0.0000 -47.7968 0.0000 1.
-0.0000 -0.0000 -0.0008 -4.
400
%Compute the closed-loop system matrix Ac = A - BK:
Ac = A-B[b4-a4 b3-a3 b2-a2 b1-a1]inv(T)
Ac =
0 0 1.0000 0
0 0 0 1.
16.5819 114.9614 18.2382 16.
-40.7759 -258.5754 -44.8493 -40.
%Check the eigenvalues of the closed-loop system matrix and their
%damping:
eig(Ac)
ans =
-10.0000 +10.0000i
-10.0000 -10.0000i
-1.0000 + 1.0000i
-1.0000 - 1.0000i
damp(Ac)
Eigenvalue Damping Freq. (rad/s)
-1.00e+000 + 1.00e+000i 7.07e-001 1.41e+
-1.00e+000 - 1.00e+000i 7.07e-001 1.41e+
-1.00e+001 + 1.00e+001i 7.07e-001 1.41e+
-1.00e+001 - 1.00e+001i 7.07e-001 1.41e+
%Run a linear simulation to verify the system meets the specifications:
x0 = [0 10*pi/180 0 0]'
x0 =
0
0
0
t = [0:0.05:10];
size(t)
ans =
1 201
u = zeros(size(t));
[y,x] = lsim(Ac,B,C,D,u,t,x0);
%Plot the pendulum angle and cart position:
plot(t,x(:,1),'.',t,y,'-'),grid
xlabel('Time (sec)')
ylabel('\theta(t) (rad), x(t) (m)')
title('Pendulum Angle and Cart Position for \theta(0) = 10 deg')
legend('Cart Position x(t)','Pendulum Angle \theta(t)')
print -deps dpout
%Plot the DC motor voltage:
u = -[b4-a4 b3-a3 b2-a2 b1-a1]inv(T)x';
plot(t,u,'-'),grid
xlabel('Time (sec)')
ylabel('DC Motor Voltage u(t) (V)')
title('DC Motor Voltage for \theta(0) = 10 (deg)')
print -deps dpout