0% found this document useful (0 votes)
147 views21 pages

Self Tuning Problem Solution

The document describes solutions to problems involving system identification and controller design for an unknown continuous time system. 1) A PID controller was designed using relay feedback and pole placement methods and simulated for a step response. 2) System identification was performed on the unknown system using a least squares method with exponential forgetting. The coefficients were estimated continuously as the unknown system was simulated. 3) After some time, the gain of the unknown system was changed without resetting the identification, showing the estimates diverging from the true values.
Copyright
© Attribution Non-Commercial (BY-NC)
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)
147 views21 pages

Self Tuning Problem Solution

The document describes solutions to problems involving system identification and controller design for an unknown continuous time system. 1) A PID controller was designed using relay feedback and pole placement methods and simulated for a step response. 2) System identification was performed on the unknown system using a least squares method with exponential forgetting. The coefficients were estimated continuously as the unknown system was simulated. 3) After some time, the gain of the unknown system was changed without resetting the identification, showing the estimates diverging from the true values.
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 21

Self-tuning Regulators

- solution of the problems Henrik Rasmussen


Aalborg University, Dept. of Control Engineering
Fredrik Bajers Vej 7
DK 9220 Aalborg, Denmark
August 18, 2003

1 Solution of problem 1
Given the system
G(s) =

K0 esT0
1 + sT1

with K0 = 1, T0 = 0.5 and T1 = 2.

1.1

Simulate a step response for the system by using the step invariant method and a step time h = 0.1.

The discrete time system without delay is


G(z) =

K0 bz 1
1 + az 1

with a = eh/T1 and b = 1 + a


The discrete time system with delay is
G(z) =

K0 bz 6
1 + az 1

giving the simulation model


y(k) = ay(k 1) + K0 bu(k 6)

% file: problem1_1.m
% HR August 2003
clear
% system
K0=1; T0=0.5; T1=2;
% step time
h=0.1;
% discrete time system
a=-exp(-h/T1); b=1+a;
% simulation parameters
Tstop=20; Nstop=Tstop/h;
% initialize
y=zeros(1,Nstop);
U0=0;

u=zeros(1,Nstop); time=h*(1:Nstop);

for t=7:Nstop
% supervision
if (t==round(2/h)) U0=1; end
% system simulation
y(t) = -a*y(t-1)+K0*b*u(t-6);
% control
u(t) = U0;
end
plot(time,y,time,u)
xlabel(time [s]);
title(y & u)
grid
print -deps problem1_1.eps
pause
close

y&u
1

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

10
time [s]

12

14

16

18

20

Figure 1: Step response

1.2

Determine an approximation to the ultimate time of period Tu


and gain Ku using relay feedback.

Figure 2: Relay feedback experiment

% file: problem1_2.m
% HR August 2003
clear
% system
K0=1; T0=0.5; T1=2;
% step time
h=0.1;
% discrete time system
a=-exp(-h/T1); b=1+a;
% simulation parameters
Tstop=10; Nstop=Tstop/h;
% initialize
y=zeros(1,Nstop);
U0=0; Yr=0;

u=zeros(1,Nstop); time=h*(1:Nstop);

for t=7:Nstop
% supervision
if (t==round(2/h)) U0=1; end
% system simulation
y(t) = -a*y(t-1)+K0*b*u(t-6);
% relay control
if (y(t)>Yr) u(t)=-U0;

else
end

u(t)=U0;

end

plot(time,y,time,u)
xlabel(time [s]);
title(y & u)
grid
print -deps problem1_2.eps
pause
close

y&u
1

0.8

0.6

0.4

0.2

0.2

0.4

0.6

0.8

5
time [s]

Figure 3: From the relay experiment is obtained Ku =

1.3

4d
a

10

= 5.1 and Tu = 2

Use Tu of Ku obtained by relay feedback to compute the coeficients in a PID-regulator designed with km = 0.5 and m = 3

At the ultimate frequency u = 2/Tu we have Ku G(ju ) = 1 which gives the


G(ju ) = K1u
At u the PID-regulator has the gain H(ju ) = K(1 + ju Td + j1u Ti ) leading to the
following open loop gain:
H(ju )G(ju ) = km ej(+m )
Specification of km , m and Ti = 4Td then gives:

tan m + 1+tan2 m
K = km Ku cos m and Td =
2u
Regulator
Ziegler-Nichols
ultimate period
km = 0.5 and
m = 60 deg

1.4

Ti

Td

0.60Ku = 3.06

0.50Tu = 1.00

0.125Tu = 0.25

0.25Ku = 1.28

1.20Tu = 2.40

0.30Tu = 0.60

Simulate a step response for the system using the designed


PID-regulator

The discrete time controller is


u(t) = r1 u(t1)r2 u(t2))s0 y(t)s1 y(t1)s2 y(t2)+t0 yr (t)+t1 yr (t1)+t2 yr (t2)

with the coefficients given by


ad =

Td
Td +N h

bd = N ad
r1 = (1 + ad )
s0 = K(1 + bd ) s1 = K(1 + ad + 2bd bi )
t0 = Kb
t1 = K(b(1 + ad ) bi )

bi = Thi
r2 = ad
s2 = K(ad + bd bi ad )
t2 = Kad (b bi )

% file: problem1_3.m
% HR August 2003
clear
% system
K0=1; T0=0.5; T1=2;
% step time
h=0.1;
% discrete time system
a=-exp(-h/T1); b=1+a;
% simulation parameters
Tstop=20; Nstop=Tstop/h;
y =zeros(1,Nstop);
u =zeros(1,Nstop);
yr=zeros(1,Nstop);
time=h*(1:Nstop);

% parameters for control


% K=3.06; Ti=1.00; Td=0.25;
%Ziegler Nichols
K=1.28; Ti=2.40; Td=0.36;
Umax=5; Umin=-5; auto=0; Uman=0; Yr=0;
N = 10; bb = 0.3;
ad = Td/(Td+N*h); bd = N*ad; bi = h/Ti;
r1=-(1+ad);
r2=ad;
s0=K*(1+bd); s1=-K*(1+ad+2*bd-bi); s2=K*(ad+bd-bi*ad);
t0=K*bb;
t1=-K*(bb*(1+ad)-bi); t2=K*ad*(bb-bi);
for t=3:Nstop
% supervision
if (t==round(4/h)) auto=1; Yr=1; end
yr(t)=Yr;
% system simulation
y(t) = -a*y(t-1)+K0*b*u(t-1);
% control
u(t) =-r1*u(t-1)-r2*u(t-2)+t0*yr(t)+t1*yr(t-1)+t2*yr(t-2)...
-s0*y(t)-s1*y(t-1)-s2*y(t-2);
if (auto==0)
u(t)=Uman; end
if (u(t)>Umax) u(t)=Umax; end
if (u(t)<Umin) u(t)=Umin; end
end
plot(time,y,time,u,.)
xlabel(time [s]);
title(y & u (dot))
grid
print -deps problem1_3.eps
pause
close

y & u (dot)
1

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

10
time [s]

12

14

16

18

20

Figure 4: Step response for the regulator designed by using km = 0.5 and m = 60

1.5

Compare with a step response for a PID-regulator designed


with the Ziegler-Nichols ultimate periode method
y & u (dot)
1.6

1.4

1.2

0.8

0.6

0.4

0.2

10
time [s]

12

14

16

18

20

Figure 5: Step response for the regulator with Ziegler-Nichols parameters

2 Solution of problem 2
The following continuous time system
G(s) =

KesT0
1 + sT1

with parameters K = 1, T0 = 0.5 and T1 = 2 is assumed unknown.

2.1

Using the step invariant transformation method and the sampling time Ts = 0.5 gives the following second order discrete
time system
y(k) + a1 y(k 1) + a2 y(k 2) = b1 u(k 1) + b2 u(k 2)
with y(k) = ya (kTs ). Compute for this system the values for a1 ,
a2 , b1 ,b2

The discrete time system without delay is given by


y(k) + ay(k 1) = bu(k 1)
with a = eh/T1 and b = K0 (1 + a)
The discrete time system with delay is given by
y(k) + ay(k 1) = bu(k 2)
giving a1 = a, a2 = 0, b1 = 0 and b2 = b

2.2

Determine continuously the coefficients in the discrete time


system by using the least square method with exponential forgetting. u(k) are chosen to be a square wave signal

% problem 2_2.m
% HR August 2003
% system
T0=0.5; T1=2; K0=1; a=-exp(-h/T1); b=1+a;
% parameters for sysid
t0=20; G=zeros(4,1); R=zeros(4,4); theta=zeros(4,1);
% parameters for simulation
Tstop=40; h=0.5; Nstop=Tstop/h;
y
=zeros(1,Nstop);
u
=zeros(1,Nstop);
yr =zeros(1,Nstop);
plt =zeros(4,Nstop);
time=h*(1:Nstop);
for t=3:Nstop
% supervision
if (sin(2*pi/20*time(t))>0) Uman=1;
else
Uman=0; end
% system simulation
y(t) = -a*y(t-1)+b*u(t-2);
% control
u(t)=Uman;
% parameter update
my=1/t;
phi=[-y(t-1) -y(t-2) u(t-1) u(t-2)];
G=(1-my)*G+my*phi*y(t);

R=(1-my)*R+my*phi*phi;
if (abs(det(R))> 0.0) theta=R\G; end
plt(1,t)=theta(1);
plt(2,t)=theta(2);
plt(3,t)=theta(3);
plt(4,t)=theta(4);
end
plot(time,u,time,y)
title(u & y)
xlabel(time [s])
grid
print -deps problem2_2a.eps
pause
close
plot(time,plt(1,:),time,plt(2,:))
title(a1 & a2)
xlabel(time [s])
grid
print -deps problem2_2b.eps
pause
close
plot(time,plt(3,:),time,plt(4,:))
title(b1 & b2)
xlabel(time [s])
grid
print -deps problem2_2c.eps
pause
close

u&y
1

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

10

15

20
time [s]

25

30

Figure 6: Square wave response

35

40

a1 & a2
0.1

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

10

15

20
time [s]

25

30

35

40

35

40

Figure 7: Estimate of a1 and a2

b1 & b2
0.3

0.25

0.2

0.15

0.1

0.05

0.05

10

15

20
time [s]

25

30

Figure 8: Estimate of b1 and b2

2.3

After some time the gain in the simulated model is changed


with a factor 2 without weighting of data

% problem 2_3.m
% HR August 2003
% system
T0=0.5; T1=2; K0=1; a=-exp(-h/T1); b=1+a;
% parameters for sysid
t0=20; G=zeros(4,1); R=zeros(4,4); theta=zeros(4,1);
% parameters for simulation
Tstop=200; h=0.5; Nstop=Tstop/h;
y
=zeros(1,Nstop);
u
=zeros(1,Nstop);
yr =zeros(1,Nstop);
plt =zeros(4,Nstop);
time=h*(1:Nstop);
for t=3:Nstop
% supervision
if (t==round(100/h)) K0=2; end
if (sin(2*pi/20*time(t))>0) Uman=1;
else
Uman=0; end
% system simulation
y(t) = -a*y(t-1)+K0*b*u(t-2);
% control
u(t)=Uman;
% parameter update
my=1/t;
phi=[-y(t-1) -y(t-2) u(t-1) u(t-2)];
G=(1-my)*G+my*phi*y(t);
R=(1-my)*R+my*phi*phi;
if (abs(det(R))> 0.0) theta=R\G; end
plt(1,t)=theta(1);
plt(2,t)=theta(2);
plt(3,t)=theta(3);
plt(4,t)=theta(4);
end
plot(time,u,time,y)
title(u & y)
xlabel(time [s])
grid
print -deps problem2_3a.eps
pause
close
plot(time,plt(1,:),time,plt(2,:))
title(a1 & a2)
xlabel(time [s])
grid
print -deps problem2_3b.eps
pause
close
plot(time,plt(3,:),time,plt(4,:))
title(b1 & b2)
xlabel(time [s])
grid
print -deps problem2_3c.eps
pause
close

u&y
2

1.8

1.6

1.4

1.2

0.8

0.6

0.4

0.2

20

40

60

80

100
time [s]

120

140

160

180

200

180

200

Figure 9: Square wave response

a1 & a2
0.6

0.4

0.2

0.2

0.4

0.6

0.8

1.2

1.4

20

40

60

80

100
time [s]

120

140

160

Figure 10: Estimate of a1 and a2 without exponential forgetting

b1 & b2
0.3

0.25

0.2

0.15

0.1

0.05

0.05

20

40

60

80

100
time [s]

120

140

160

180

200

Figure 11: Estimate of b1 and b2 without exponential forgetting

10

2.4

After some time the gain in the simulated model is changed


with a factor 2 with exponential weighting of data

% problem 2_4.m
% HR August 2003
% system
T0=0.5; T1=2; K0=1; a=-exp(-h/T1); b=1+a;
% parameters for sysid
t0=20; G=zeros(4,1); R=zeros(4,4); theta=zeros(4,1);
% parameters for simulation
Tstop=200; h=0.5; Nstop=Tstop/h;
y
=zeros(1,Nstop);
u
=zeros(1,Nstop);
yr =zeros(1,Nstop);
plt =zeros(4,Nstop);
time=h*(1:Nstop);
for t=3:Nstop
% supervision
if (t==round(100/h)) K0=2; end
if (sin(2*pi/20*time(t))>0) Uman=1;
else
Uman=0; end
% system simulation
y(t) = -a*y(t-1)+K0*b*u(t-2);
% control
u(t)=Uman;
% parameter update
my=1/t;
if (my<1/t0) my=1/t0; end
phi=[-y(t-1) -y(t-2) u(t-1) u(t-2)];
G=(1-my)*G+my*phi*y(t);
R=(1-my)*R+my*phi*phi;
if (abs(det(R))> 0.0) theta=R\G; end
plt(1,t)=theta(1);
plt(2,t)=theta(2);
plt(3,t)=theta(3);
plt(4,t)=theta(4);
end
plot(time,u,time,y)
title(u & y)
xlabel(time [s])
grid
print -deps problem2_4a.eps
pause
close
plot(time,plt(1,:),time,plt(2,:))
title(a1 & a2)
xlabel(time [s])
grid
print -deps problem2_4b.eps
pause
close
plot(time,plt(3,:),time,plt(4,:))
title(b1 & b2)
xlabel(time [s])
grid
print -deps problem2_4c.eps
pause
close

11

u&y
2

1.8

1.6

1.4

1.2

0.8

0.6

0.4

0.2

20

40

60

80

100
time [s]

120

140

160

180

200

180

200

Figure 12: Square wave response

a1 & a2
0.6

0.4

0.2

0.2

0.4

0.6

0.8

1.2

1.4

20

40

60

80

100
time [s]

120

140

160

Figure 13: Estimate of a1 and a2 with exponential forgetting

b1 & b2
0.45

0.4

0.35

0.3

0.25

0.2

0.15

0.1

0.05

0.05

20

40

60

80

100
time [s]

120

140

160

180

200

Figure 14: Estimate of b1 and b2 with exponential forgetting

12

In the following the small signal model developed around (y0 , u0 ) = (1, 1) is simulated
as
y(k) y0 + a(y(k 1) y0 ) = b(u(k 2) u0 )
with (y(k), u(k)) = (y0 , u0 ) for k < 3

2.5 Introduce filtering of input and output so a1 ,a2 ,b1 , b2 may be


continuously estimated without knowledge of (y0 , u0 )
% problem 2_5.m
% HR August 2003
clear
% system
T0=0.5; T1=2; K0=1; h=0.5; a=-exp(-h/T1); b=1+a; u0=1; y0=1;
% parameters for sysid
t0=20; G=zeros(4,1); R=zeros(4,4); theta=zeros(4,1);
% parameters for simulation
Tstop=60; Nstop=Tstop/h;
y
=zeros(1,Nstop);
u
=zeros(1,Nstop);
yf =zeros(1,Nstop);
uf =zeros(1,Nstop);
plt =zeros(4,Nstop);
time=h*(1:Nstop);
u(1)=u0; u(2)=u0;
y(1)=y0; y(2)=y0;
for t=3:Nstop
% supervision
if (sin(2*pi/20*time(t))>0) Uman=1;
else
Uman=0; end
% system simulation
y(t) = y0-a*(y(t-1)-y0)+K0*b*(u(t-2)-u0);
% control
u(t)=Uman;
% parameter update
my=1/t;
if (my<1/t0) my=1/t0; end
yf(t)=y(t)-y(t-1);
uf(t)=u(t)-u(t-1);
phi=[-yf(t-1) -yf(t-2) uf(t-1) uf(t-2)];
G=(1-my)*G+my*phi*yf(t);
R=(1-my)*R+my*phi*phi;
if (abs(det(R))> 0.0) theta=R\G; end
plt(1,t)=theta(1);
plt(2,t)=theta(2);
plt(3,t)=theta(3);
plt(4,t)=theta(4);
end
plot(time,u,time,y)
title(u & y)
xlabel(time [s])
grid
print -deps problem2_5a.eps
pause
close
plot(time,plt(1,:),time,plt(2,:))
title(a1 & a2)
xlabel(time [s])
grid
print -deps problem2_5b.eps
pause
close

13

plot(time,plt(3,:),time,plt(4,:))
title(b1 & b2)
xlabel(time [s])
grid
print -deps problem2_5c.eps
pause
close

u&y
1

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

10

20

30
time [s]

40

50

60

Figure 15: Square wave response

a1 & a2
0.1

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

10

20

30
time [s]

40

50

60

Figure 16: Estimate of a1 and a2 with filtered input and output

b1 & b2
0.3

0.25

0.2

0.15

0.1

0.05

0.05

10

20

30
time [s]

40

50

60

Figure 17: Estimate of b1 and b2 with filtered input and output

14

3 Solution of problem 3
In problem 2.3 a recursive least square method without forgetting in the first 20 samples
and there after forgetting with a window equal to 20. This algorithm is now extended
with a pole placement controller with integral action going from manual to auto at time
equal to 20 sec. The reference signal yr (t) is a square wave signal equal to the input in
exercise 2.3
The specified closed loop polynomium is:
P (q 1 ) = Am (q 1 )Ao (q 1 ) = (1 + am1 q 1 + am2 q 2 )(1 + ao1 q 1 + ao2 q 2 )
where
am1
am2
ao1
ao2

= 2e0 Ts cos(0 Ts
=
e20 Ts
=
2eTs /o
=
e2Ts /o

1 2)

and = 3/2, 0 = T2u and o = Tu /2 may be calculated from Tu determined by a


relay experiment in exercise 1.

3.1 Do the described simulations and plot the input u(t) and output
y(t) for = 0.1, = 0.5 and = 2
% problem 3_1.m
% HR August 2003
clear
% system
T0=0.5; T1=2; K0=1; h=0.5; a=-exp(-h/T1); b=1+a;
% parameters for sysid
t0=20; G=zeros(4,1); R=zeros(4,4); theta=zeros(4,1);
% parameters for controller
auto=0;
s0=0; s1=0; s2=0; r1=0; r2=0; t0m=0;
Umin=-10; Umax=10;
% parameters for controller design
update_reg=0;
a1_=0; a2_=0; b1_=0; b2_=0;
alpha=0.5; Tu=2;
d=sqrt(3); w0=alpha*2*pi/Tu; thau0=Tu/2;
am1=-2*exp(-0.5*d*w0*h)*cos(w0*h*sqrt(1-d*d/4));
am2=exp(-d*w0*h);
ao1=-2*exp(-h/thau0);
ao2=exp(-2*h/thau0);
P=conv([1 am1 am2],[1 ao1 ao2]);
p1=P(2); p2=P(3); p3=P(4); p4=P(5);
% parameters for simulation
Tstop=120; Nstop=Tstop/h;
y
=zeros(1,Nstop);
u
=zeros(1,Nstop);
yf =zeros(1,Nstop);
uf =zeros(1,Nstop);
plt =zeros(4,Nstop);
time=h*(1:Nstop);
for t=3:Nstop
% supervision
if (t==round(50/h)) K0=2; end
if (sin(2*pi/20*time(t))>0) Uman=1; yr(t)=1;
else
Uman=0; yr(t)=0; end
if (t==round(20/h)) update_reg=1; auto=1; end
% system simulation
y(t) = -a*y(t-1)+K0*b*u(t-2);

15

% control
if (auto==1)
u(t)=-r1*u(t-1)-r2*u(t-2)-s0*y(t)-s1*y(t-1)-s2*y(t-2)+...
t0m*(yr(t)+ao1*yr(t-1)+ao2*yr(t-2));
else u(t)=Uman; end
if (u(t)<Umin) u(t)=Umin; end
if (u(t)>Umax) u(t)=Umax; end
if (update_reg==1)
a1_=theta(1); a2_=theta(2); b1_=theta(3); b2_=theta(4);
C=[b1_ 0
0
1
0 ;
b2_ b1_ 0
a1_ 1 ;
0
b2_ b1_ a2_ a1_;
0
0
b2_ 0
a2_;
0
0
0
1
1 ];
D=[p1-a1_;
p2-a2_;
p3;
p4;
-1];
X=C\D;
s0=X(1); s1=X(2); s2=X(3); r1=X(4); r2=X(5);
t0m=(s0+s1+s2)/(1+ao1+ao2);
end
% parameter update
my=1/t;
if (my<1/t0) my=1/t0; end
phi=[-y(t-1) -y(t-2) u(t-1) u(t-2)];
G=(1-my)*G+my*phi*y(t);
R=(1-my)*R+my*phi*phi;
if (abs(det(R))> 0.0) theta=R\G; end
plt(1,t)=theta(1);
plt(2,t)=theta(2);
plt(3,t)=theta(3);
plt(4,t)=theta(4);
end
plot(time,u,time,y)
title(u & y)
xlabel(time [s])
grid
print -deps problem3_1a.eps
pause
close
plot(time,plt(1,:),time,plt(2,:))
title(a1 & a2)
xlabel(time [s])
grid
print -deps problem3_1b.eps
pause
close
plot(time,plt(3,:),time,plt(4,:))
title(b1 & b2)
xlabel(time [s])
grid
print -deps problem3_1c.eps
pause
close

16

u&y
2

1.5

0.5

0.5

1.5

20

40

60
time [s]

80

100

120

Figure 18: Square wave response

a1 & a2
0.4

0.2

0.2

0.4

0.6

0.8

1.2

1.4

20

40

60
time [s]

80

100

120

Figure 19: Estimate of a1 and a2

b1 & b2
0.6

0.5

0.4

0.3

0.2

0.1

0.1

20

40

60
time [s]

80

100

Figure 20: Estimate of b1 and b2

17

120

4 Solution of problem 4
4.1 Obtain by simulation the results in example 5.2 (Adaptiv Control)
% file: problem4_1.m
% HR August 2003
clear
% system b/(s+a)
a=1; b=0.5;
% reference system bm/(s+am)
am=2; bm=2;
% simulation
Tstop=100; h=0.01; Nstop=Tstop/h;
a1 =-exp(-h*a); b1=b/a*(1+a1);
am1=-exp(-h*am); bm1=bm/am*(1+am1);
% adaptation
gamma=5;
% initialize
y
=zeros(1,Nstop); yr =zeros(1,Nstop); ym =zeros(1,Nstop);
u
=zeros(1,Nstop); x1 =zeros(1,Nstop); x2 =zeros(1,Nstop);
theta =zeros(2,Nstop); time=h*(1:Nstop);
for t=2:Nstop
if (sin(2*pi/20*t*h)>0) yr(t)=+1;
else
yr(t)=-1; end
y(t) =-a1 *y(t-1) +b1*u(t-1);
u(t) =theta(1,t-1)*yr(t)-theta(2,t-1)*y(t);
ym(t)=-am1*ym(t-1)+bm1*yr(t-1);
x1(t)=-am1*x1(t-1)+(1+am1)*yr(t);
x2(t)=-am1*x2(t-1)+(1+am1)*y(t);
theta(1,t)=theta(1,t-1)-h*gamma*x1(t)*(y(t)-ym(t));
theta(2,t)=theta(2,t-1)+h*gamma*x2(t)*(y(t)-ym(t));
end
plot(time,y,time,ym)
xlabel(time [s]);
title(y & ym)
grid
print -deps problem4_1a.eps
pause
close
plot(time,theta)
title(theta)
xlabel(time [s]);
grid
print -deps problem4_1b.eps
pause
close

18

y & ym
1.5

0.5

0.5

1.5

10

20

30

40

50
time [s]

60

70

80

90

100

Figure 21: Square wave response


theta
4

3.5

2.5

1.5

0.5

0.5

10

20

30

40

50
time [s]

60

70

80

90

100

Figure 22: Estimate of parameters

4.2 Show the effect of variation of both for the MIT rule and the
modified MIT rule
1
e
=
e
e T e
+ ( ) ( )
where > 0 to avoid division with zero
% file: problem4_2.m
% HR August 2003
clear
% system b/(s+a)
a=1; b=0.5;
% reference system bm/(s+am)
am=2; bm=2;
% simulation
Tstop=100; h=0.01; Nstop=Tstop/h;
a1 =-exp(-h*a); b1=b/a*(1+a1);
am1=-exp(-h*am); bm1=bm/am*(1+am1);
% adaptation
gamma=5; alpha=0.0001;
% initialize
y
=zeros(1,Nstop); yr =zeros(1,Nstop); ym =zeros(1,Nstop);
u
=zeros(1,Nstop); x1 =zeros(1,Nstop); x2 =zeros(1,Nstop);
theta =zeros(2,Nstop); time=h*(1:Nstop);
for t=2:Nstop
if (sin(2*pi/20*t*h)>0) yr(t)=+1;
else
yr(t)=-1; end
y(t) =-a1 *y(t-1) +b1*u(t-1);
u(t) =theta(1,t-1)*yr(t)-theta(2,t-1)*y(t);
ym(t)=-am1*ym(t-1)+bm1*yr(t-1);

19

x1(t)=-am1*x1(t-1)+(1+am1)*yr(t);
x2(t)=-am1*x2(t-1)+(1+am1)*y(t);
v=1/(alpha+x1(t)*x1(t)+x2(t)*x2(t));
theta(1,t)=theta(1,t-1)-h*gamma*v*x1(t)*(y(t)-ym(t));
theta(2,t)=theta(2,t-1)+h*gamma*v*x2(t)*(y(t)-ym(t));
end
plot(time,y,time,ym)
xlabel(time [s]);
title(y & ym)
grid
print -deps problem4_2a.eps
pause
close
plot(time,theta)
title(theta)
xlabel(time [s]);
grid
print -deps problem4_2b.eps
pause
close

y & ym
1.5

0.5

0.5

1.5

10

20

30

40

50
time [s]

60

70

80

90

100

Figure 23: Square wave response

theta
4.5

3.5

2.5

1.5

0.5

0.5

10

20

30

40

50
time [s]

60

70

80

90

100

Figure 24: Estimate of parameters

20

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy