Professional Documents
Culture Documents
ADAPTIVE CONTROL
HOMEWORK 5
Instructor:
Ming Shaung Ju
Student:
Student ID:
P96007019
Department:
Class:
Contents
Problem 1 ...................................................................................................................... 2
Problem 2 .................................................................................................................... 13
Problem 3 .................................................................................................................... 37
Page 1
Problem 1
Consider a process
0 + 1
()
=
2 + 1 + 2 ()
Where,
() =
0
()
=
2 + 1 + 2 ()
0 = 0.1761
1 = 1.3205
2 = 0.4966
() = () ()
(a) Design a controller in which the stable zero of process model is canceled.
Step 1:
Adaptive Control Theory HW5
Page 2
1
1
0.08118
1
= 0.6927
0 + = 0 = =
0.1172
0
0
0
|| =
1
<1
0
= + = +
0 0
1
+ = +
= 0
deg() = 2, deg() = 1
Choose 0 () = 1
Step 2:
() = + () = +
1
= + 0.6927
0
Page 3
+ 0 =
(2 + 1 + 2 ) + 0 (0 + 1 ) = ( 2 + 1 + 2 )
2 + (1 + 0 0 ) + 2 + 0 1 = 2 + 1 + 2
1 1
= 1.0691
0
2 2
1 =
= 1.4556
0
0 =
Step 3:
=
= 0
0 +
= 0 = 0
The controller:
0
0
0
0
= 0
=1
0
= 1.5026
0
() = () ()
() = + 0.6927
() = 1.0691 1.4556
() = 1.5026
() = () ()
Page 4
(b) Design a controller in which no zero of process model is canceled. Choose a proper
delay d0.
Step 1:
No zero of process model is canceled = + = 1 deg(+ ) = 0
= = 0 + 1
=
= (deg( ) = deg() = 1)
=
0 + 1
()
=
2 + 1 + 2 ()
1+1 +2
deg() = 2, deg() = 1
0 +1
= 0.8877
Page 5
1 = 0.6603 + 0.2463
2 = 0.6603 0.2463
|1 | = |2 | = 0.7047
0.7047 |0 | < 1
= + = 1 = = + 1 ( )
= 0 + 1
Step 2:
The Diophantine equation:
+ = + + + = 0 + + = 0
( 2 + 1 + 2 )( + 1 ) + (0 + 1 )(0 + 1 ) = ( + 0 )(2 + 1 + 2 )
3 + (1 + 1 + 0 0 ) 2 + (1 1 + 2 + 0 1 + 1 0 ) + (2 1 + 1 1 )
= 3 + (0 + 1 ) 2 + (2 + 1 0 ) + 2 0
1 + 1 + 0 0 = 0 + 1
1 1 + 2 + 0 1 + 1 0 = 2 + 1 0
2 1 + 1 1 = 2 0
1 + 0 0 = 0 1 + 1
1 1 + 1 0 + 0 1 = 2 + 2 + 1 0
2 1 + 1 1 = 2 0
Page 6
1 = 0.88020 + 0.0830
= 1.02220 + 0.3611
0
1 = 1.11690 0.6820
0.7047 |0 | < 1
Step 3:
The controller:
() = () ()
() = + 1
() = 0 + 1
Where
() = ( + 0 ) = + 0
1 = 0.88020 + 0.0830
= 1.0222 + 0.3611
0
0
1 = 1.11690 0.6820
0.7047 |0 | < 1
= 0.8877
() = () ()
( + 1 )() = ( + 0 ) () (0 + 1 )()
(1 + 1 1 )() = ( + 0 1 ) () (0 + 1 1 )()
() + 1 ( 1) = () + 0 ( 1) 0 () 1 ( 1)
Adaptive Control Theory HW5
Page 7
() = 1 ( 1) + () + 0 ( 1) 0 () 1 ( 1)
(c) Simulate above designs when command is a square wave of amplitude 1 and period
of 25 sampling periods. Test the effect of step disturbance on the tracking
performance. You may try step with different magnitude. (for simulating let a0 = 0.8)
1
Out1
Disturbance
Clock
MATLAB
Function
t0.z
b0.z+b1
z+r1
z2 +a1.z+a2
Command
T/R
B/A
s0.z+s1
z+r1
S/R
Page 8
Figure 3. Command & output, with stable zero cancellation, and step disturbance
Page 9
Figure 5. Command & output, with no zero cancellation, and step disturbance
(d) Compare the tracking performance, ringing of input and disturbance rejection of the
two designs. Discuss on the effect of time delay on the performance of the adaptive
controller. Plot y(t), uc(t) vs. t and u(t), e(t) vs. t.
Plot y(t), uc(t): we can see through Fig. 2 to Fig. 5. Two controllers have very same
performance (tracking and disturbance).
Discuss on the effect of time delay on the performance of the adaptive controller: we
should choose the time delay as small as possible. When the time delay is large that
means the output signal lags phase to the command signal. Hence, the performance of
the system is not good.
From Fig. 6 and Fig.8, the control input signal with stable zero cancellation design has a
severe oscillation (ringing) compare to that of no zero cancellation design
Page 10
Figure 7. Error between uc(t) and y(t), with stable zero cancellation design
Adaptive Control Theory HW5
Page 11
Figure 9. Error between uc(t) and y(t), with no zero cancellation design
Adaptive Control Theory HW5
Page 12
Problem 2
Consider a process
(a) Design an indirect STR in which the stable zero of process model is canceled.
Transfer function of the process:
() =
()
0 + 1
=
2 + 1 + 2 ()
Where,
() =
0
()
=
2 + 1 + 2 ()
0 = 0.1761
1 = 1.3205
2 = 0.4966
() = () ()
Adaptive Control Theory HW5
Page 13
Step 1: Estimate the coefficients of the polynomials A and B i.e. {a1, a2, b0, b1}, by
using the RLS:
() = 1 ( 1) 2 ( 2) + 0 ( 1) + 1 ( 2) = ( 1)
( 1) = [( 1) ( 2) ( 1) ( 2)]
= [1
1 ]
() = ( 1) + ()()
() = () ( 1)( 1)
() = ( () ( 1))( 1)/
With the stable zero of process model is canceled (this step for only define the degree of
the polynomials)
() = +
1
1
1
0 + = 0 =
0
0
0
|| =
1
< 1 |1 | < |0 |
0
= + = +
0 0
1
+ = +
= 0
Page 14
deg() = 2, deg() = 1
Choose 0 () = 1
1
= + 1
0
+ = + + + = 0 + + = 0
+ 0 =
(2 + 1 + 2 ) + 0 (0 + 1 ) = ( 2 + 1 + 2 )
2 + (1 + 0 0 ) + 2 + 0 1 = 2 + 1 + 2
2 2
1 =
0
=
= 0
+
Page 15
= 0 = 0
0
0
0
0
= 0
=1
0
= 0
0
() = + () = +
1
= + 1
0
() = () ()
() + 1 ( 1) = 0 () 0 () 1 ( 1)
() = 1 ( 1) + 0 () 0 () 1 ( 1)
(b) Design an indirect STR in which no zero of process model is canceled. Choose a
proper delay d0.
Step 1: Estimate the coefficients of the polynomials A and B i.e. {a1, a2, b0, b1}, by
using the RLS:
() = 1 ( 1) 2 ( 2) + 0 ( 1) + 1 ( 2) = ( 1)
( 1) = [( 1) ( 2) ( 1) ( 2)]
= [1
1 ]
() = ( 1) + ()()
() = () ( 1)( 1)
Adaptive Control Theory HW5
Page 16
() = ( () ( 1))( 1)/
=
= (deg( ) = deg() = 1)
=
0 + 1
()
=
2 + 1 + 2 ()
1+1 +2
deg() = 2, deg() = 1
0 +1
() = 0 2 + 1 + 2 = 0
1 = 0.6603 + 0.2463
2 = 0.6603 0.2463
|1 | = |2 | = 0.7047
Page 17
0.7047 |0 | < 1
= + = 1 = = + 1 ( )
= 0 + 1
+ = + + + = 0 + + = 0
( 2 + 1 + 2 )( + 1 ) + (0 + 1 )(0 + 1 ) = ( + 0 )(2 + 1 + 2 )
3 + (1 + 1 + 0 0 ) 2 + (1 1 + 2 + 0 1 + 1 0 ) + (2 1 + 1 1 )
= 3 + (0 + 1 ) 2 + (2 + 1 0 ) + 2 0
1 + 1 + 0 0 = 0 + 1
1 1 + 2 + 0 1 + 1 0 = 2 + 1 0
2 1 + 1 1 = 2 0
1 + 0 0 = 0 1 + 1
1 1 + 1 0 + 0 1 = 2 + 2 + 1 0
2 1 + 1 1 = 2 0
1
0
1
0.7047 |0 | < 1
Step 3:
() = 0 = ( + 0 ) (0.7047 |0 | < 1)
The controller:
() = () ()
Page 18
() = 0 + 1
() = ( + 0 ) = + 0
() = () ()
( + 1 )() = ( + 0 ) () (0 + 1 )()
(1 + 1 1 )() = ( + 0 1 ) () (0 + 1 1 )()
() + 1 ( 1) = () + 0 ( 1) 0 () 1 ( 1)
() = 1 ( 1) + () + 0 ( 1) 0 () 1 ( 1)
(c) Simulate above designs using following process parameters [a1, a2, b0, b1] = [1.3735, 0.7006, 0.1231, 0.07712] and initial guess of above parameter vector [0, 0,
0.01, 0.2]. The command is a square wave of amplitude 1 and period of 25 sampling
periods. You may test the effect of disturbance on the tracking performance. Either
stochastic or deterministic disturbance can be used.
c.1. Stable zero cancellation:
From the true model, we can find the true R, S and T.
1 1
= 0.4305
0
2 2
1 =
= 1.6572
0
0 =
Page 19
= 0
=1
0
= 0 = 1.4305
0
() = + () = +
1
= + 1 = + 0.6265
0
() = 1 ( 1) + 0 () 0 () 1 ( 1)
function [estmtd_theta,yhat,ue,e,re1,se0,se1,te0] =
adtvCtrolHw5_STR1(uc,u,y,lambda)
% number of coefficents
alpha = 100;
t = length(y);
j=1;
phi_1(:,j)=[0;u(1:t-1,j)];
phi_2(:,j)=[0;0;u(1:t-2,j)];
phi_3(:,j)=[0;-y(1:t-1,j)];
phi_4(:,j)=[0;0;-y(1:t-2,j)];
phi = [phi_1(:,j) phi_2(:,j) phi_3(:,j) phi_4(:,j)];
[M,N] = size(phi);
P = alpha*eye(N);
% estimated value
re1 = zeros(1,N);
Page 20
se0 = zeros(1,N);
se1 = zeros(1,N);
te0 = zeros(1,N);
% initial conditions for three polynomials
re1(1) = estmtd_theta(1,2)/estmtd_theta(1,1);
se0(1) = (am1 - estmtd_theta(1,3))/estmtd_theta(1,1);
se1(1) = (am2 - estmtd_theta(1,4))/estmtd_theta(1,1);
te0(1) = bm0/estmtd_theta(1,1);
e = zeros(1,t);
ue(1) = 0;
for i = 2:M-numOfCoeffs+1;
z = P*phi(i,:)';
K = z/(lambda + phi(i,:)*z);
yhat(i) = phi(i,:)*estmtd_theta(i-1,:).';
e(i) = y(i) - phi(i,:)*estmtd_theta(i-1,:).';
estmtd_theta(i,:) = estmtd_theta(i - 1,:) + e(i)*K.';
P = (P - K*z.')/lambda;
re1(i) = estmtd_theta(i,2)/estmtd_theta(i,1);
se0(i) = (am1 - estmtd_theta(i,3))/estmtd_theta(i,1);
se1(i) = (am2 - estmtd_theta(i,4))/estmtd_theta(i,1);
te0(i) = bm0/estmtd_theta(i,1);
ue(i) = - re1(i)*ue(i-1) + te0(i)*uc(i) - se0(i)*yhat(i) se1(i)*yhat(i-1);
end
end
Page 21
Page 22
Page 23
1 + 1 + 0 0 = 0 + 1
1 1 + 2 + 0 1 + 1 0 = 2 + 1 0
2 1 + 1 1 = 2 0
1 + 0 0 = 0 1 + 1
1 1 + 1 0 + 0 1 = 2 + 2 + 1 0
2 1 + 1 1 = 2 0
Controller:
() = 1 ( 1) + () + 0 ( 1) 0 () 1 ( 1)
function [estmtd_theta,yhat,ue,e,re1,se0,se1,te0] =
adtvCtrolHw5_STR2(uc,u,y,lambda)
numOfCoeffs = 4;
% number of coefficents
beta = 0.8795;
a0 = 0.8;
am1 = -1.3205; am2 = 0.4966;
t = length(y);
j=1;
phi_1(:,j)=[0;u(1:t-1,j)];
phi_2(:,j)=[0;0;u(1:t-2,j)];
phi_3(:,j)=[0;-y(1:t-1,j)];
phi_4(:,j)=[0;0;-y(1:t-2,j)];
Page 24
[M,N] = size(phi);
alpha = 100;
P = alpha*eye(N);
% estimated value
re1 = zeros(1,N);
se0 = zeros(1,N);
se1 = zeros(1,N);
te0 = zeros(1,N);
te1 = zeros(1,N);
% initial conditions for three polynomials
re1(1) = estmtd_theta(1,2)/estmtd_theta(1,1) - ((estmtd_theta(1,2) a0*estmtd_theta(1,1))*(am2*estmtd_theta(1,1)^2 am1*estmtd_theta(1,1)*estmtd_theta(1,2) + estmtd_theta(1,2)^2))/...
(estmtd_theta(1,1)*(estmtd_theta(1,4)*estmtd_theta(1,1)^2 estmtd_theta(1,3)*estmtd_theta(1,1)*estmtd_theta(1,2) +
estmtd_theta(1,2)^2));
se0(1) = (estmtd_theta(1,1)*(a0*estmtd_theta(1,4) estmtd_theta(1,3)*estmtd_theta(1,4) - a0*am2 + estmtd_theta(1,4)*am1)
- estmtd_theta(1,2)*...
(estmtd_theta(1,4) - am2 + a0*estmtd_theta(1,3) - a0*am1 +
estmtd_theta(1,3)*am1 estmtd_theta(1,3)^2))/(estmtd_theta(1,4)*estmtd_theta(1,1)^2 estmtd_theta(1,3)*estmtd_theta(1,1)*estmtd_theta(1,2) +
estmtd_theta(1,2)^2);
se1(1) = (estmtd_theta(1,1)*(estmtd_theta(1,4)*am2 estmtd_theta(1,4)^2 - a0*estmtd_theta(1,3)*am2 +
a0*estmtd_theta(1,4)*am1)...
- estmtd_theta(1,2)*(a0*estmtd_theta(1,4) estmtd_theta(1,3)*estmtd_theta(1,4) - a0*am2 +
Page 25
estmtd_theta(1,4)*am1))/(estmtd_theta(1,4)*estmtd_theta(1,1)^2 estmtd_theta(1,3)*estmtd_theta(1,1)*estmtd_theta(1,2) +
estmtd_theta(1,2)^2);
te0(1) = beta;
te1(1) = beta*a0;
e = zeros(1,t);
ue(1) = 0;
for i = 2:M-numOfCoeffs+1;
z = P*phi(i,:)';
K = z/(lambda + phi(i,:)*z);
yhat(i) = phi(i,:)*estmtd_theta(i-1,:).';
e(i) = y(i) - phi(i,:)*estmtd_theta(i-1,:).';
estmtd_theta(i,:) = estmtd_theta(i - 1,:) + e(i)*K.';
P = (P - K*z.')/lambda;
Page 26
te0(i) = beta;
te1(i) = beta*a0;
ue(i) = - re1(i)*ue(i-1) + te0(i)*uc(i)+ te1(i)*uc(t-1) se0(i)*yhat(i) - se1(i)*yhat(i-1);
end
end
Page 27
Page 28
Figure 17. Error between process output and estimated output with step disturbance
(d) Plot y and uc vs. t, u vs. t and estimated process parameters vs. t. Compare the
tracking performance, ringing of input and disturbance rejection of the two designs.
Discuss on the effect of time delay on the performance of the adaptive controller.
d.1. Stable zero cancellation:
Page 29
Page 30
Page 31
Figure 22. u (control input is computed from controller law) vs time with step
disturbance
Adaptive Control Theory HW5
Page 32
Page 33
Page 34
Figure 28. u (control input is computed from controller law) vs time with step
disturbance
Adaptive Control Theory HW5
Page 35
Page 36
Problem 3
Solution:
I will take only one case in P2: the stable zero of the process model is canceled
Matlab code:
clear all; close all; clc;
w = 1; % frequency
% variations
delta_a1 = 0.13735;
delta_a2 = 0.07006;
delta_b0 = 0.01231;
delta_b1 = 0.007712;
Page 37
% Rq = q + r1
r1 = b1./b0;
% S(q) = s0*q + s1
s0 = (am1 - a1)./b0;
s1 = (am2 - a2)./b0;
% T(q) = t0*q
t0 = bm0./b0;
% call function
lambda = 1;
[estmtd_theta,yhat,ue,e,re1,se0,se1,te0]...
= adtvCtrolHw5_STR1(uc',u',y',lambda);
Page 38
figure(1);
plot(t(1:198),y(1:198),t(1:198),yhat(1:198));
xlabel('Time, sec');
ylabel('Output');
legend('Process output', 'Estimated output');
figure(2);
plot(e); grid on;
xlabel('Time, sec');
ylabel('Error');
figure(3);
plot(t(1:198),uc(1:198),'--',t(1:198),yhat(1:198));
xlabel('Time, sec');
ylabel('uc(t) & y-estimated(t)');
legend('uc(t)', 'y-estimated(t)');
figure(4);
plot(ue);
xlabel('Time, sec');
ylabel('Control input signal');
figure(5);
plot(t(1:198),estmtd_theta(:,1),t(1:198),b0(1:198),'--',...
t(1:198),estmtd_theta(:,2),t(1:198),b1(1:198),'--',...
t(1:198),estmtd_theta(:,3),t(1:198),a1(1:198),'--',...
t(1:198),estmtd_theta(:,4),t(1:198),a2(1:198),'--');
grid on;
xlabel('Time, sec');
ylabel('Process parameters');
legend('b0-estimated','b0','b1-estimated','b1','a1estimated','a1',...
'a2-estimated','a2');
Page 39
Figure 31. Error between process and estimated output (delta = 10% of true value, w =
1 rad/sec)
Adaptive Control Theory HW5
Page 40
Figure 32. Command signal and estimated output (delta = 10% of true value, w = 1
rad/sec)
Figure 33. Control input signal (delta = 10% of true value, w = 1 rad/sec)
Page 41
Figure 34. True and estimated parameters (delta = 10% of true value, w = 1 rad/sec)
Page 42
Figure 36. Error between process and estimated output (delta = 15% of true value, w =
2 rad/sec)
Figure 37. Command signal and estimated output (delta = 15% of true value, w = 2
rad/sec)
Page 43
Figure 38. Control input signal (delta = 15% of true value, w = 2 rad/sec)
Figure 39. True and estimated parameters (delta = 15% of true value, w = 2 rad/sec)
Adaptive Control Theory HW5
Page 44
Figure 40. Output (delta = 10% of true value, w = 1 rad/sec, lambda = 0.98)
Figure 41. Error between process and estimated output (delta = 10% of true value, w =
1 rad/sec, lambda = 0.98)
Page 45
Figure 42. Command signal and estimated output (delta = 10% of true value, w = 1
rad/sec, lamda)
Figure 43. Control input signal (delta = 10% of true value, w = 1 rad/sec, lambda = 1)
Page 46
Figure 44. True and estimated parameters (delta = 10% of true value, w = 1 rad/sec,
lambda = 0.98)
From all of figures above, we can see, it is very similar between weighted and unweighted design in this case. Because, the process parameters change as a sine function.
When frequency and variation increase the performance of the system is not good, even
maybe not stable.
Page 47