Engineering Experimentation Lab Report System

advertisement
Engineering Experimentation
Lab Report
System Identification using PRBS
Introduction
This report will generate a pseudo random binary sequence (PBRS) and investigate
the effects of generator parameters, autocorrelation and power spectral characteristics
of the PRBS. Also, the statistical testing method will be employed to identify the
frequency response of a motion system.
Description
System identification implies to the process of determining means of practically
testing a transfer function or its equivalent mathematical description for the dynamic
characteristics of a system.
A statistical method of identification used for determination of transfer functions is by
on-line testing during normal plant operation with minimum disturbance to that
operation. A non-deterministic forcing function is used by this method, which has
random characteristics and it can be considered as a wanted noise signal. If its
amplitude is small, it will be identical to the normal input signal.
Using non-deterministic forcing functions for system identification, and carrying out
the analysis in the time domain, the appropriate statistical descriptions for the signals
are termed as correlation function. A high correlation is expected when two time
instants are very close together (that is, small time shifts) but much less correlation
when two time shifts are widely separated. (that is, larger time shifts).
System Identification using Spectral Density Function
Power spectral density, a frequency function, describes quantitatively how the energy
in a signal is distributed over the frequency spectrum. A system affects the magnitude
and phase of input signal components of different frequencies by different amounts.
The amplitude of the output of a system with transfer function G(s), for a frequency
ω1, is the input amplitude multiplied by jG(ω1)j, and the phase of the output relative
to the input is \G(ω1). With the knowledge of the power density spectra of the input
and output signals and the appropriate cross-spectra, it is possible to determine the
transfer function.
The output spectral density is obtained from the input spectral density by multiplying
by the square of jG(jω)j as the spectral density represents signal power, or in other
words amplitude squared. Therefore, knowing Φxx(ω) and Φyy(ω), jG(jω)j can be
found.
Motion System
Figure: Shows a vehicle suspension system
The system can be written as:
x = Ax +Bu
Response due to suspension parameters:
Parameters governing a time response of the vehicle suspension system are mass (m),
spring constant (k) and dashpot(b).
The above figure shows the graph of response versus time obtained from parametersm=500; b=15000; k=100000
The response of the system obtained above shows that the overshoot =0 and damping
ratio = 1.
Changing the parameter b=1500, with all parameters kept the same, the following
graph is obtained:
The response of the system now shows an overshoot when value of b is decreased to
1500 from 15000 and the damping ratio > 1. Therefore, the above figure shows an
under damped system.
Thus, decrease in the value of b results in an overshoot in the system along with a
decrease in the damping ration of the system, making it an under damped system.
Taking the parameters to be m=5000; b=1500; k=100000
Increasing the mass would increase the rise time, the ring time and delay the time to
reach first maxima.
And if the parameters are altered such that the spring constant (k) is increased, with
m=500; b=15000; k=10000000;
The following graph shows that when the spring constant is increased, the rise time
decreases by a large amount and the first maxima is reached quickly.
Choosing the PRBS parameters:
If the signal 𝑓(𝑡) has only random components, then the autocorrelation function
(ACF) response must have a sudden decrease with a non-zero time-shift, that is,
φ(t) → 0 as τ → ∞.
The number shift registers (N), the XOR input and the output from which shift
register are observed. The parameters are determined such that the PRBS is most nonrepeating, that is, the best ACF should have the smallest value among the different
parameter settings.
The above figure shows the PRBS function versus time with amplitude of +1.
The above figure shows a graph of ACF versus Time step. The graph indicates that
there is a close co-relation between the two signals as ACF is almost 1. But as the
value reaches 5, ACF reaches 0, showing very less co-relation between the two
signals.
The above graph shows the power spectral densities distributed over the range of
frequencies.
Conclusion:
PBRS closely represents a simulation carried out in real life. It adds the noise while
carrying out the analysis. PBRS are the forcing functions most commonly used in
statistical testing. It provides approximations to white noise, and is the best example
of a statistical method of identifying non-deterministic signals thus, avoiding the need
of using an explicit function.
Due to the binary nature of the PRBS function, signals are generated and introduced
into the system quickly and easily. PRBS is the most suitable forcing function as it
has low intensity and energy spread over a vast range of frequencies. This makes
PRBS ideal for use.
Appendix:
Shown below is the Matlab Code:
clc; clear all; close all;
%Specify the system parameters
m=500; b=15000; k=100000;
%Specify the time parameter
dt=1e-2; tF=20; t=0:dt:tF; tL=length(t);
%which set the time step to 1ms and the test lasts for 3sec.
%Specify the input forcing signal
Ug=1; U=ones(1,tL)*Ug; dU(2:tL)=diff(U)/dt;
dU(1)=(U(2)-U(1))/dt; F=b*dU+k*U;
%which gives a step function of magnitude Ug.
%Setup the system equation using
A=[0 1; -k/m -b/m]; B=[0; 1/m]; C=[1 0];
[Ad,Bd]=c2d(A,B,dt);
%Simulate the time response
Z=zeros(2,1);
for j=1:tL-1,
Z(:,j+1)=Ad*Z(:,j)+Bd*F(j);
end;
zZ=Z(1,:)/Ug;
%Where zZ gives the normalised displacement of the mass m as the wanted
%system output
threshold90 = 0.9*(zZ(tL)-zZ(1));
threshold110 = 1.1*(zZ(tL)-zZ(1));
%Plot the response against time
hold on;
plot(t,zZ);
plot(t,threshold90, 'r-');
plot(t,threshold110, 'r-');
title('Resonse v/s Time');
ylabel('Response');
xlabel('Time');
%overshoot
overshoot = 0;
zmax = max(zZ);
if zmax >1;
overshoot = 1;
end
if overshoot;
%Calculating settling time
tSettleArrayHigh = find(zZ > threshold110);
tSettleLengthHigh = length(tSettleArrayHigh);
tSettleLastHighIndex = tSettleArrayHigh(tSettleLengthHigh);
tSettleLastHigh = t(tSettleLastHighIndex);
threshold90 = 0.9*(zZ(tL)-zZ(1));
tSettleArrayLow = find(zZ < threshold90);
tSettleLengthLow = length(tSettleArrayLow);
tSettleLastLowIndex = tSettleArrayLow(tSettleLengthLow);
tSettleLastLow = t(tSettleLastLowIndex);
if tSettleLastLow < tSettleLastHigh;
t10 = tSettleLastHigh;
plot(t10, zZ(tSettleLastHighIndex),'m*');
text(t10+0.05, zZ(tSettleLastHighIndex)+0.05,sprintf('90 Percent Settling time = %4.2f s',t10));
zZ(tSettleLastLowIndex);
else
t10 = tSettleLastLow;
plot(t10, zZ(tSettleLastLowIndex));
end
% Calculating ringing time
for tS=tL:-1:1;
if zZ(tS)<0.9 || zZ(tS)>1.1;
break;
end;
end
[mxa,a]=max(zZ);
plot(t(a),mxa,'go');
zZ1=zZ(a+1:end);
[mxb,b]=min(zZ1);
zZ2=zZ1(b+1:end);
[mxc,c]=max(zZ2);
plot(t(a+b+c),mxc,'go');
tRing = t(a+b+c) - t(a);
text(t(a+b), zZ(a),sprintf('Ring Time = %4.2f s',tRing));
else
% tconstant
dZ = zZ - (1-exp(-1));
[mi,index] = min(abs(dZ));
tau=t(index);
plot(tau,zZ(index),'m*');
text(tau+0.05, zZ(index),sprintf('Tau time constant = %4.2f s',tau));
firstOrderCurve=1-exp(-t/tau);
plot(t,firstOrderCurve,'m-');
end
% Calculating 90% rise time
t90array = find(zZ >= threshold90);
t90index = t90array(1);
t90 = t(t90index);
plot(t90, zZ(t90index),'m*');
text(t90+0.05, zZ(t90index)-0.05,sprintf('90 Percent Rise time = %4.2f s',t90));
hold off;
%Generate a Pseudo Random Binary Sequence2
stages = 7;
N = 2^7-1;
dt=0.01;
tf = 10*ceil(stages*dt);
nt=length(0:dt:tf);
SR = ones(stages,1);
PRBS=[];
for k=1:nt
temp=xor(SR(stages),SR(stages-4));
SR(2:end)=SR(1:end-1);
SR(1) = temp;
PRBS=[PRBS SR];
end
PRBS=PRBS(1,:);
PRBS=(PRBS-0.5)*2;
%plot of PRBS numbers
figure;
stairs(PRBS);
title('PRBS');
ylabel('PRBS');
xlabel('Time');
ax = axis;
axis([ax(1:2) -2 2]);
%ACF
%Construct the Autocorrelation Function (ACF)
for i=1:nt-N;
ACF(i)=corr(PRBS(1:N)',PRBS(i:i+N-1)');
end
corr(PRBS(1:stages)',PRBS(1:stages)')
%Determine PRBS Parameters
figure;
stairs(ACF);
figure(5);
plot(1,ACF(1))
title('Random Sequence');
ylabel('ACF');
xlabel('Time Step');
tL = nt;
%Construct the PSD
Fs = 1/dt; Nn=2^floor(log(tL)/log(2));
[Pp,f]=periodogram(PRBS,[], Nn, Fs);
Pp=10*log10(Pp);
figure(4);
semilogx(f,Pp, 'color', 'k'); grid on;
xlabel('Frequency(Hz)');
%Estimate of System Frequency Response
Uu = 0.5;
Uf=1.5;
Pp=0.05;
% t=0:dt:tF;
U=sin(2*pi*Uf*t)*Uu;
% PRBS=PRBS';
% size(PRBS)
% size(U)
U=U+PRBS*Pp;
dU(2:tL)=diff(U)/dt;
dU(1)=(U(2)-U(1))/dt;
F=b*dU+k*U;
%Setup the system equation using
A=[0 1; -k/m -b/m]; B=[0; 1/m]; C=[1 0];
[Ad,Bd]=c2d(A,B,dt);
%Simulate the time response by using
Z=zeros(2,1);
for j=1:tL-1,
Z(:,j+1)=Ad*Z(:,j)+Bd*F(j);
end;
zZ=Z(1,:)/Ug;
% figure;
% plot(t,zZ);
%Construct the PSD
Fs = 1/dt; Nn=2^floor(log(tL)/log(2));
[ppA,f]=periodogram(zZ,[ ], Nn, Fs);
ppA=10*log10(ppA);
[ppB,f]=periodogram(F,[ ], Nn, Fs);
ppB=10*log10(ppB);
%[ppC,f]=periodogram(PRBS,[ ], Nn, Fs); ppC=10*log10(ppC);
ppD = ppA-ppB;
%[ppD,f]=periodogram(ratio,[ ], Nn, Fs); ppD=10*log10(ppD);
figure(4);hold on;grid on
semilogx(f,ppA, 'color', 'g');
semilogx(f,ppB, 'color', 'b');
%semilogx(f,ppC, 'color', 'k');
semilogx(f,ppD, 'color', 'r');
xlabel('Frequency(Hz)');
ylabel('Magnitude(db)');
title('Estimated power spectral densities');
for j=1:10;
[P,S]=polyfit(f,ppD,j);
[p,delta(j,:)] =polyval(P,f,S);
end;
[mi,ix]=min(mean(delta,2));
[P,S]=polyfit(f,ppD,ix);
p=polyval(P,f,S);
semilogx(f,p,'color','k');
legend('PRBS','Output','Input','Xfer');
hold off;
Download