Sunteți pe pagina 1din 4

clc

clear all

close all

............//////......continous inverted pendulum System......//////.........

A=[0 1 0 0;20.58 0 0 0;0 0 0 1;-.4904 0 0 0];

B=[0;-1;0;.5];

c=[0 0 1 0];

..... sampling period......

T=.05;

.....continous to discontinous

[G,H]= c2d(A,B,T);

.....eigon vales of origional system.......

G;

eig(G)

..... desired eigon values.......

p=[.87, 0.3824 - 0.1695i, 0.3824 + 0.1695i,.9];

% .......... feedback gain methods.............. %%

% .......//////////..method #1....///////////..........%%

...... cofficients values from origional system eigon values ........

Gpoly=poly(G)

a4=Gpoly(5);

a3=Gpoly(4);

a2=Gpoly(3);

a1=Gpoly(2);

%.........Desired poles cofficients........

Z1=[p(1) 0 0 0;0 p(2) 0 0 ;0 0 p(3) 0;0 0 0 p(4)]

zpoly=poly(Z1)

b4=zpoly(5)

b3=zpoly(4)
b2=zpoly(3)

b1=zpoly(2)

...controllabilty check.....

S1=G*H;

S2=G*S1;

S3=G*S2;

M1=[H S1 S2 S3]

rank(M1)

W1=[a3 a2 a1 1;a2 a1 1 0;a1 1 0 0;1 0 0 0];

....transformation matrix....

T1=M1*W1;

I1=inv(T1);

...gain Km1 .....

Km1=[b4-a4,b3-a3,b2-a2,b1-a1]*I1

% ...///////..Method #2...;;Ackersman Formula;;...///////.........%%

.......some calculations from method 1.......

Q=polyvalm(poly(Z1),G)

I2=inv(M1)

.........gain Km2.............

Km2=[0 0 0 1]*I2*Q;

% ............../////////// Method #3 /////////////......%%

...................distinic desired eigon values method..................

I=eye(4);

......eigon vector #1 is E1

O1=[G-p(1)*I];

I3=inv(O1);

E1=I3*H;

......eigon vector #2 is E2

O2=[G-p(2)*I];
I4=inv(O2);

E2=I4*H;

......eigon vector #3 is E3

O3=[G-p(3)*I];

I5=inv(O3);

E3=I5*H;

......eigon vector #4 is E4

O4=[G-p(4)*I];

I6=inv(O4);

E4=I6*H;

....inverse of all four eigon vectors (I7)....

E=[E1 E2 E3 E4];

I7=inv(E);

...''''' Gain Km3 Value'''''''.....

Km3=[1 1 1 1]*I7;

Km3r=real([1 1 1 1]*I7)

% ////////////.....Method #4 ...//////////////....................%%

............. ....used for lower order.................

Km4=place(G,H,p)

Gscv=G-H*Km4;

eig(Gscv)

.....asympotatical stable with initial cond.....

G_int=[pi/4;0;0.7;0]; .....///assume initial conditoins////.....

for k=0:1:500;

X=(Gscv^k)*G_int;

x1(k+1)=X(1);

x2(k+1)=X(2);

x3(k+1)=X(3);

x4(k+1)=X(4);
end

k=0:1:500;

figure(1)

plot(k,x1)

figure(2)

plot(k,x3)

figure(3)

plot(k,x3)

figure(4)

plot(k,x4)

...........////...feedback observe gain martix calculation...../////.......

...........////.. using final value theorem......////.....

syms k0 z

C=[0 0 1 0];

Gtrans=(C*inv(z*eye(4)-Gscv)*H*k0);

Ytrans=Gtrans*10;

yfinal=double(vpa(subs(Ytrans,{z k0},{1 1})));

yfinal1=yfinal*(1/10);

k0=1/yfinal1;

.......////...steady state output ploting.///////.....

............control system with constant reference input.........

[num, den]=ss2tf(Gscv,H,C,0);

r0=10*ones(1,100);

yout=filter(k0*num,den,r0);

figure(5)

plot(yout)

S-ar putea să vă placă și