Identification: 2.1 Identification of Transfer Functions 2.1.1 Review of Transfer Function
Identification: 2.1 Identification of Transfer Functions 2.1.1 Review of Transfer Function
2. Identification
2.1 Identification of Transfer Functions 2.1.1 Review of Transfer Function What is Transfer Function? Transfer function is a type of the mathematical models of dynamic systems.
y (t ) : the output of the dynamic system being studied x (t ) : the input of the dynamic system
System Model: mathematical description of the dynamic relationship between the input and output of the system. For example, a differential equation can be considered as a mathematical model from the system point of view. Differential equation:
d ( n ) y (t ) d ( n 1) y (t ) + a + ... + a 0 y (t ) n 1 dt n dt n 1 d ( m ) x(t ) d ( m 1) x(t ) = bm + b + ... + b0 x (t ) m 1 dt m dt m 1 Transfer Function b s m + bm 1 s m 1 + ... + b0 H (s) = m n a n s + a n 1 s n 1 + ... + a0 (Can you convert between the differential equation and transfer function) How to use Transfer function: (1) If a given input signal x (t ) is applied to a system described by transfer function H ( s ) , the output generated by this input through the system can be obtained by three steps: find the Laplace transform of the input signal X ( s ) = L( x(t )) ; Calculate the Laplace transform of the output signal Y ( s ) = H ( s ) X ( s ) ; calculate the output using inverse Laplace transform y (t ) = L1 (Y ( s )) . (2) H ( s ) contains all the dynamic characteristics of the dynamic system being studied: stability (poles location in the s-plan), static gain, system response speed. can be used for control system design. an
delay, when a change in the input occurs, its effect on the output will not take place (seconds) later
2-1
Time constant: 2 second Static gain: 5 Delay: 0.5 second How to examine its step response (Use Simulink): establish system connection, modify element parameters, specify the output data and sampling period in Scope, plot the output data in MatLab.
10
2.5 e 0.5 s ? (1) Build the s + 0.5 5 e 0.5 s . Can you see simulink model; (2) Simulate The same as H ( s ) = 2 s +1
2-2
5s + 5 e 0.5 s 6 s + 5s + 1
10
12
14
16
18
20
2-3
EE 499: Control System Design 2.1.3 From Step Response to Transfer Function Can we use a first order plus delay model to approximate the above system?
5s+5 6s2+5s+1 Step Transfer Fcn Transport Delay Sum Transport Delay1 Scope1
Can we approximate a sequence of a step response measurements using a first-order plus delay model?
6
-1 0 2 4 6 8 10 12 14 16 18 20
First: What is your estimation of the delay? Approximately 5 second. Second: Can you build a simulink model (first order plus 5 second delay)? Third: Can you plot the measurements and the simulation results together? Fourth: Can you examine their difference and determine how to change the parameters to make them closer?
2-4
-1 0 2 4 6 8 10 12 14 16 18 20
What is the problem? A little faster than the measurement! Lets increase the time constant.
-1 0 2 4 6 8 10 12 14 16 18 20
EE 499: Control System Design 2.1.4 Step Response Experiment Design for Non-linear Systems The non-linearity is introduced in this case by the MatLab Fcn which is output=sin(input). Question: Should we still apply a step and use the step response to identify the model?
1 0
1 2
1 4
1 6
1 8
2 0
4.2 s e 3s +1
2-6
1.5
0.5
0 0 2 4 6 8 10 12 14 16 18 20
4 .8 s e 3s +1
2-7
2.5
1.5
0.5
0 0 2 4 6 8 10 12 14 16 18 20
The linear approximation is different when the magnitude of the step input is different. It is correct because of the non-linearity! Which one is what we need? How to design the experiment? Operating Point: Assume that the desired output is 4.2. Experiment or experience should tell us approximately what input will generate this output. In this example, it is 1. Control: If no uncertainties and/or disturbances, u=1 should approximately generates 4.2 output. If uncertainties and/or disturbances exist, the input should vary about u=1. How to Design Step Response Experiment? Assume the amplitude of the variation will be approximately in the range 0.25 . We would like to consider the approximation in an input range from 0.75 to 1.25 to linearize the system. Hence, we should first apply u=0.8 and after the response reaches the steady-state value and then change the input to 1.25. The increase in the output can be considered a step response caused by a 0.5 step. An linear approximation can thus be obtained. Designed Experiment: Step: 0.8 applied at t=0. Step 1: 0.4 added at t=20
2-8
2-9
EE 499: Control System Design The 0.5 Step Response to be approximated by a linear model is
1.4
1.2
0.8
0.6
0.4
0.2
0 0 2 4 6 8 10 12 14 16 18 20
2.48 s e 3s +1
1.2
0.8
0.6
0.4
0.2
10
12
14
16
18
20
Project One: A system is described by d ( 2) y (t ) dy (t ) dx(t ) 6 +5 + y (t ) = (5 + 5 x(t )) sin(u (t )) . 2 dt dt dt Simulate its step response and obtain a linear approximation of the system suitable for u = (0.75, 1.25) . 2-10
EE 499: Control System Design 2.2 Identification of Difference Equations: 2.2.1 Review of Difference Equation Discrete-time system: instant k corresponds to time t = kT where T is the sampling period y ( k ) : output at t = kT u ( k ) : input at t = kT Difference equation:
y ( k ) a1 y ( k 1) ... a p y ( k p ) = b1u ( k 1) +... + bq u ( k q ) y ( k ) = a1 y (k 1) + ... + a p y (k p ) + b1u (k 1) +... + bq u ( k q )
or
b1 z 1 + b2 z 2 + ... + bq z q a1 z 1 + a 2 z 2 + ... + a p z p
Order of the system: p and q Model Parameters: a i (i =1,.2,..., p ) and b j ( j =1,.2,..., q ) T Parameter Vector: = (a1 , a 2 ,..., a p , b1 , b2 ,..., bq ) How to use the Impulse Transfer function or Difference Equation: (3) Predict the future outputs (4) System Characteristics: stability, static gain, system response speed, frequency response can be used for controls system design. 2.2.2 Parameter Estimation and Structure Identification Problems Given: data pair sequence (u (1), y (1)), (u (2), y ( 2)),..., (u ( N ), y ( N )) Parameter Estimation: assume a pair of p and q , i.e. assume a model structure; find a which can give the best prediction as evaluated by a given criterion such as the minimization of the sum of the squared prediction errors. Structure Identification: determine the best pair of p and q . Typically, the structure can not be identified without estimating the parameters. Parameter Estimation and Structure Identification Procedure: (1) Assume an initial pair of orders; (2) Estimate the parameters associated with the model structure (orders); (3) Use an order determination criterion to judge the sufficiency of the orders (model structures). (For example, after the parameters associated with the model structure are estimated, we can calculate the prediction errors for (k ) = y(k ) different time instant k: e( k ) = y ( k ) y u ( k q ) where the hat 1 y ( k 1) +... +a p y (k p ) +b1u ( k 1) +... +b a q indicates an estimate. If the model is adequate, the prediction error sequence should be white noise.) If the model is adequate, stop and use the order pair and the estimated parameters. Otherwise, increase the orders and go (2) again to estimate the parameters. Order Determination Criteria: Many One Order Determination Criterion (Residual Analysis): determine the correlation functions of the prediction error sequence. Assume 2-11
based on the estimated parameters. Calculate the correlation functions of the residual (prediction error) sequence
N 0 1 e(k )e(k + 0) N L 0 k = L +1 r (0) = N 1 e 2 (k ) N L k = L +1 N 1 1 e(k )e(k + 1) N L 1 k =L +1 r (1) = N 1 e 2 (k ) N L k =L +1
. Or
N j 1 e ( k )e ( k + j ) N L j k = L +1 r ( j) = ( j = 1,2,., , , ) N 1 2 e (k ) N L k = L +1
may accept the model. Example: clear; L=5;N=1000;for k=1:1000;e(k)=rand-0.5;end; % generate a white noise sequence from 1 to 1000 r(0+1)=1;for j=1:10;r(j+1)=0;for k=L+1:Nj;r(j+1)=r(j+1)+e(k)*e(k+j);end; r(j+1)=r(j+1)/(N-L-j);end % calculate the correlation function r ( j ) as r(j+1) to avoid zero index for j=1 to 10 for k=1:11;lag(k)=k-1;end;plot(lag, r) % plot r ( j ) ~ j
2-12
1.2
0.8
0.6
0.4
0.2
-0.2 0 1 2 3 4 5 6 7 8 9 10
2.2.3 Least Squares Method for Parameter Estimation Given: (1) data pair sequence (u (1), y (1)), (u (2), y ( 2)),..., (u ( N ), y ( N )) (2) the order pair p and q Observation Equation:
(Can you construct the observation vector ( k ) for any given model structure?) is the used as the estimate of the parameter vector, Prediction Equation: assume then
a1 ... a p y(k ) = ( y(k 1),..., y(k p), u(k 1),..., u(k q)) = (k ) b1 ... b q
2-13
1 a ... a p (k ) = ( y(k 1),..., y(k p), u(k 1),..., u(k q)) = (k ) y b1 ... bq
Observation Equations: What is the first observation equation we can have? The minimal k, denoted as k 0 , we are going to use to write the first observation equation should make k p 1 and k q 1 . Define L = max( p, q ) . It can be seen that k 0 = L + 1 . For example, if ( p = 2, q = 3) , then L = 3 and k 0 = 4 . Hence, we will have the following observation equations
y ( 4) =( 4) y (5) =(5) ....... y ( N ) =( N )
Matrix Observation Equation (Matrix Expression of the Observation Equations): The observation equations give the following matrix equation:
y(4) (4) y(5) (5) Denote Y = . . . , = . . . . Then the matrix equation can be written as y( N ) ( N )
Prediction Equations and Matrix Expression of Prediction Equations
( 4) = y ( 4) (5) = y (5)
Y =
....... ( N ) = y ( N )
= Y
) T (Y Y ) ( k )) 2 = (Y Y e 2 (k ) = ( y(k ) y
k =L +1
: J ( ) = min J ( ) LS LS p+q
R
Or
) J (
=0
= LS
) J (
= LS
=0 ,
= (T ) 1 T Y LS
Summary: (1) Given: (u (1), y (1)), (u (2), y ( 2)),..., (u ( N ), y ( N )) ; Model structure including p and q
(2) L = max( p, q ) (3) Form ( L +1),..., ( N ) and Y = ( y ( L +1), y ( L + 2),..., y ( N )) T (4) Form = (T ) 1 T Y (5) LS Example: Given model: y ( k ) = 0.95 y ( k 1) +1.5u ( k 1) + ( k ) where ( k ) is white noise (zero mean, even distribution between 0.5 to 0.5) for k=1:110;uu(k)=5*rand;yy(k)=0;end;
2-15
EE 499: Control System Design for k=11:110;yy(k)=0.95*yy(k-1)+1.5*uu(k-1)+(rand-0.5);end; %p=1,q=1,a1=0.95,b1=1.5 for k=1:100;y(k)=yy(k+10);u(k)=uu(k+10);end; % pair {u(1),y(1)},...,{u(100),y(100)};N=100 L=1; %Step 2 in Summary N=100;for k=L+1:N;UpperPhi(k-L,:)=[y(k-1) u(k-1)];UpperY(k-L)=y(k);end; UpperY=UpperY'; % Step 3 and 4 ThetaHatLS=(UpperPhi'*UpperPhi)^(-1)*UpperPhi'*UpperY; % Step 5 ThetaHatLS ThetaHatLS = 0.9494 1.4931 (An accurate Estimate!) UpperYHat=UpperPhi*ThetaHatLS; % Predicted Y plot([UpperYHat UpperY]); % Comparison between Y and Yhat
90 80 70 60 50 40 30 20 10 0 10 20 30 40 50 60 70 80 90 100
2.2.4 Examples for Formation of Regression Equation Critical Step in Least Squares Estimation: form the observation equation (regression equation) in terms of y (k ) = (k ) based on the given model structure
2-16
EE 499: Control System Design Can you form the regression equations and the least squares estimates for the following systems? y (k ) a1 y (k 1) a 2 y ( k 2) = b1u (k 3) + b2 u (k 4)
y ( k ) = b1u ( k 1) + bq u ( k q )
2.2.5 Experiment Design Example: Given model: y ( k ) = 0.95 y ( k 1) +1.5u ( k 1) + ( k ) where (k ) is white noise (zero mean, even distribution between 0.5 to 0.5) In 2.2.3, a white noise (even distribution between 0 to 5) sequence was applied as the input. What about a sin sequence is applied? for k=1:110;uu(k)=sin(k*2*3.1415926/100);yy(k)=0;end; for k=11:110;yy(k)=0.95*yy(k-1)+1.5*uu(k-1)+(rand-0.5);end; %p=1,q=1,a1=0.95,b1=1.5 for k=1:100;y(k)=yy(k+10);u(k)=uu(k+10);end; % pair {u(1),y(1)},..., {u(100),y(100)};N=100 L=1; %Step 2 in Summary N=100;for k=L+1:N;UpperPhi(k-L,:)=[y(k-1) u(k-1)];UpperY(kL)=y(k);end;UpperY=UpperY';% Step 3 and 4 ThetaHatLS=(UpperPhi'*UpperPhi)^(-1)*UpperPhi'*UpperY; % Step 5 ThetaHatLS ThetaHatLS = 0.9494 1.5360 UpperYHat=UpperPhi*ThetaHatLS; % Predicted Y plot([UpperYHat UpperY]); % Comparison between Y and YHat
2-17
10
20
30
40
50
60
70
80
90
100
Then the white noise input: clear for k=1:110;uu(k)=5*(rand-0.5);yy(k)=0;end; for k=11:110;yy(k)=0.95*yy(k-1)+1.5*uu(k-1)-0.5*uu(k-2)+0.2*uu(k-3)+(rand-0.5);end; %p=1,q=3 for k=1:100;y(k)=yy(k+10);u(k)=uu(k+10);end; % pair {u(1),y(1)},..., {u(100),y(100)};N=100 L=3; %Step 2 in Summary N=100;for k=L+1:N;UpperPhi(k-L,:)=[y(k-1) u(k-1) u(k-2) u(k-3)];UpperY(kL)=y(k);end;UpperY=UpperY';% Step 3 and 4 ThetaHatLS=(UpperPhi'*UpperPhi)^(-1)*UpperPhi'*UpperY; % Step 5 ThetaHatLS UpperYHat=UpperPhi*ThetaHatLS; % Predicted Yplot([UpperYHat UpperY]); % Comparison between Y and YHAt plot([UpperYHat UpperY]); % Comparison between Y and YHat J=(UpperYHat-UpperY)'*(UpperYHat-UpperY) ThetaHatLS = 0.9447 1.4658 -0.5061 0.1786
2-18
-5
-10
-15
-20
10
20
30
40
50
60
70
80
90
100
If the sin sequence is used: clear for k=1:110;uu(k)=sin(k*2*3.1415926/100);yy(k)=0;end; for k=11:110;yy(k)=0.95*yy(k-1)+1.5*uu(k-1)-0.5*uu(k-2)+0.2*uu(k-3)+(rand-0.5);end; %p=1,q=3 for k=1:100;y(k)=yy(k+10);u(k)=uu(k+10);end; % pair {u(1),y(1)},..., {u(100),y(100)};N=100 L=3; %Step 2 in Summary N=100;for k=L+1:N;UpperPhi(k-L,:)=[y(k-1) u(k-1) u(k-2) u(k-3)];UpperY(kL)=y(k);end;UpperY=UpperY';% Step 3 and 4 ThetaHatLS=(UpperPhi'*UpperPhi)^(-1)*UpperPhi'*UpperY; % Step 5 ThetaHatLS UpperYHat=UpperPhi*ThetaHatLS; % Predicted Yplot([UpperYHat UpperY]); % Comparison between Y and YHAt plot([UpperYHat UpperY]); % Comparison between Y and YHat J=(UpperYHat-UpperY)'*(UpperYHat-UpperY) Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 7.829732e-019. ThetaHatLS = 0.8587 -2.6191 -10.9222 2-19
10
20
30
40
50
60
70
80
90
100
Very Inaccurate!!! What is the problem? Input Signal: insufficient excitation A Method to Design Input (1) Determine an input which can approximately generate the desired value of the output Y0 . Denote this input as U 0 . (U 0 , Y0 ) defines the operating point. U 0 can be determined from the process knowledge or preliminary experiments. (2) Determine the acceptable deviation of the input from U 0 . That is, determine U to U 0+ U without affecting U so that the input can vary from U 0 the operation of the process. (3) Generate a white noise sequence even distributed in (-1,1) using 2*(rand-0.5) in MatLab. Denote this sequence by (1), ( 2),.... (4) Generate a sequence u (k ) = U 0 + U (k ) . Assume that the input will be changed each T second. If the noise and the disturbance are not large, you may use a small T , i.e., you can change the input fast. Otherwise, T should not be too small. Project Two: Given system
y (k ) = 0.8 y ( k 1) + u (k 3) 0.5u (k 4) + 0.2u (k 5) + (k ) where ( k ) is white noise (zero mean, even distribution between 0.5 to 0.5). Assume
that the desired output is 10 and the allowed output range is (5, 15). (1) Simulate the step response of the system. (2) Design an input sequence for Least Squares estimation experiment and simulate the output of the system produced by this input sequence.
2-20
EE 499: Control System Design (3) Find the least squares estimates of the parameters. Graphically demonstrate the accuracy of the estimation through prediction.
responses close.
2-21
2-22
EE 499: Control System Design How to Obtain Discrete-Time Impulse Response h(1), h( 2),..., h( n) from Transfer Function G ( s ) 1. Find the inverse Laplace transform of G ( s ) . It will be the systems continuoustime impulse response h(t ) .
h(t ) = L1 (G ( s ))
For example: G ( s) =
1 h(t ) = e t s +1
h( k ) =
( k 1)T
h()d =
h( kT ) + h( kT T ) T 2
3. How to select T : approximately 1/5 to of the dominant time constant For example: G ( s) =
1 time constant=1 second sampling period 0.2 to 0.5 s +1
n ? Let
for k=1:10;h(k)=0.5*(exp(-0.5*k)+exp(-0.5*(k-1)));end;h' ans = 0.8033 0.4872 0.2955 0.1792 0.1087 0.0659 0.0400 0.0243 0.0147 0.0089 2-23
EE 499: Control System Design h= [0.8033 0.4872 0.2955 0.1792 0.1087 0.0659 0.0400 0.0243 0.0147 0.0089] 5. How to handle the delay For example G ( s ) =
1 e 0.5 s delay = 0.5 second 1 step (delay=1 T) s +1
h= [0 0.8033 0.4872 0.2955 0.1792 0.1087 0.0659 0.0400 0.0243 0.0147 0.0089] 6. Estimate hmax and hmin Make the range based on your estimation about the uncertainty of the process If the range is assumed to be 20 percent hmax=1.2*h (20% up) hmin=0.8*h (20% down)
h=[0 0.8033 0.4872 0.2955 0.1792 0.1087 0.0659 0.0400 0.0243 0.0147 0.0089] hmax=1.2*h; hmin=0.8*h; n=11; smax(1)=hmax(1);for j=2:n;smax(j)=smax(j-1)+hmax(j);end;% compute s(n) y0=1;% Set-point % prepare initial values for computation convenience for k=1:100+n;u(k)=0;deltau(k)=0;end; for k=100+n:100+n+n;deltau(k)=0;end; for k=n+1:100+n;% control loop starts % sample the output y(k)=0;for j=1:n;y(k)=y(k)+h(j)*u(k-j);end; %if k>50 y(k)=y(k)+0.5+0.2*(rand-0.5); end; % constant disturbance % end of sampling the output % Start to compute the prediction of maxy(k+n)under condition deltau(k)=deltau(k+1)=...=0 yhatmax(k+1)=y(k); for j=1:n; aa=deltau(k+1-j)*hmin(j); bb=deltau(k+1-j)*hmax(j); if aa<bb aa=bb;end;yhatmax(k+1)=yhatmax(k+1)+aa; end; for i=2:n; yhatmax(k+i)=yhatmax(k+i-1); for j=1:n;aa=deltau(k+i-j)*hmin(j);bb=deltau(k+i-j)*hmax(j); if aa<bb aa=bb;end; yhatmax(k+i)=yhatmax(k+i)+aa; end; end; % End of computing the prediction % compute deltau(k) deltau(k)=(y0-yhatmax(k+n))/smax(n); % compute u(k)
2-24
1.4
1.2
0.8 output
0.6
0.4
0.2
10
20
30
40
50
60
70
80
90
100
0.5 0.49 0.48 0.47 control signal 0.46 0.45 0.44 0.43 0.42 0.41
10
20
30
40
50
60
70
80
90
100
2-25
10
20
30
40
50
60
70
80
90
100
1.5
control signal
0.5
-0.5
-1
10
20
30
40
50
60
70
80
90
100
2-26
EE 499: Control System Design If you want faster: use smax(m) to replace smax(n) where m<n Use m=4
h=[0 0.8033 0.4872 0.2955 0.1792 0.1087 0.0659 0.0400 0.0243 0.0147 0.0089] hmax=h; hmin=h; n=11; smax(1)=hmax(1);for j=2:n;smax(j)=smax(j-1)+hmax(j);end;% compute s(n) y0=1;% Set-point % prepare initial values for computation convenience for k=1:100+n;u(k)=0;deltau(k)=0;end; for k=100+n:100+n+n;deltau(k)=0;end; for k=n+1:100+n;% control loop starts % sample the output y(k)=0;for j=1:n;y(k)=y(k)+h(j)*u(k-j);end; %if k>50 y(k)=y(k)+0.5+0.2*(rand-0.5); end; % constant disturbance % end of sampling the output % Start to compute the prediction of maxy(k+n)under condition deltau(k)=deltau(k+1)=...=0 yhatmax(k+1)=y(k); for j=1:n; aa=deltau(k+1-j)*hmin(j); bb=deltau(k+1-j)*hmax(j); if aa<bb aa=bb;end;yhatmax(k+1)=yhatmax(k+1)+aa; end; for i=2:n; yhatmax(k+i)=yhatmax(k+i-1); for j=1:n;aa=deltau(k+i-j)*hmin(j);bb=deltau(k+i-j)*hmax(j); if aa<bb aa=bb;end; yhatmax(k+i)=yhatmax(k+i)+aa; end; end; % End of computing the prediction % compute deltau(k) m=4;deltau(k)=(y0-yhatmax(k+m))/smax(n); % compute u(k) u(k)=u(k-1)+deltau(k); yy(k-n)=y(k);uu(k-n)=u(k);% shift back so that t=1T as the start time end; % control loop ends
plot(yy);ylabel('output')
2-27
1.4
1.2
0.8 output
0.6
0.4
0.2
10
20
30
40
50
60
70
80
90
100
0.57 0.56 0.55 0.54 control signal 0.53 0.52 0.51 0.5 0.49
10
20
30
40
50
60
70
80
90
100
How to Obtain Discrete-Time Impulse Response h(1), h( 2),..., h( n) from Impulse Transfer Function G ( z ) (1) h(k ) = Z 1 (G ( z )) (2) Select the order (3) Estimate the ranges of h( k ) for k n .
n so that
2-28
2-29