340 likes | 477 Views
Digital Signal Processing Introduction Course R.WEBER SP2 ESI module Traitement Numérique. A] Time and Frequency description of a digital signal B] Digital Filtering : Analysis and Design Tools. PART A Time and Frequency description of a digital signal. Temporal Description. ?.
E N D
Digital Signal Processing Introduction Course R.WEBERSP2 ESI module Traitement Numérique A] Time and Frequency description of a digital signal B] Digital Filtering : Analysis and Design Tools
Temporal Description ? What really happens here ? x=[ 2.1 -0.5 1.3 0.5 0 1.7 -0.4 0.3 -1.9 -0.8 ]; -1 0 1 2 3 4 5 6 7 8 9 10 n (time index or relative time) Dr. R.Weber / Digital Signal Processing
Theoretical spectral description ! Remarks : ! X(f+1)=X(f) • periodicity of the spectrum • f can be limited to [0, 0.5] for real signal (spectrum symmetry) • f can be limited to [- 0.5 , 0.5] or [0 , 1] for complex signal ? The problem : Yes, with the Fourier Transform The answer : Dr. R.Weber / Digital Signal Processing
Theoretical spectrum of basic signals impulse x = [ 1 zeros(1,1023)]; f 0 1.5 -1.5 1 -0.5 -1 0.5 Complex exponential x = A.*exp(2*pi*j*(0:1023)*fo); f fO 0 1.5 -1.5 1 -0.5 -1 0.5 x = A.*cos(2*pi*(0:1023)*fo); sine wave f fO 0 1.5 -1.5 1 -0.5 -1 0.5 Dr. R.Weber / Digital Signal Processing
Theoretical spectrum of basic signals White Gaussian Noise x = .*randn(1, 1024); f 0 1.5 -1.5 1 -0.5 -1 0.5 General case : time and frequency are related f ? • How will appear • a pure sine wave, • a pure impulse ? n specgramdemo(x,Fs); Dr. R.Weber / Digital Signal Processing
Basic spectral properties (1) Pure delay : Modulation or frequency shift: Dr. R.Weber / Digital Signal Processing
Basic spectral properties (2) Product and Convolution: Parceval relation : Dr. R.Weber / Digital Signal Processing
Practical spectral description (1) ! No digital implementation possible X=fft(x); FFT(x) = DFT(x) with M a power of 2 Theoretical Formulation : Approximations : The Discrete Fourier Transform • n[0, M-1] • Only f / f=k/M Dr. R.Weber / Digital Signal Processing
Practical spectral description (2) Theoretical spectrum (n]-,+ [) |X(f)| M Windowed spectrum (n]0,M]) h(n) H(f) n f 0 0.5 Practical spectrum (n]0,M], f k/M) |X(k)| n n k/M 0 0.5 1/M 2/M Possibility to reduce distortion by using different kinds of windows, h(n) Dr. R.Weber / Digital Signal Processing
Windowing Hamming Rectangular Blackmann-Harris Hann WINtool sous Maltab Dr. R.Weber / Digital Signal Processing
DFT properties Inverse DFT : x=ifft(X); Parceval relation : Power spectral density cov(x) Dr. R.Weber / Digital Signal Processing
Power Spectral density(1) with ? What is the measured power spectral density of a sinus wave when using a classical DFT ? Spectral line case :a complex exponential or s(n) is sine wave DFT so then When s=sin(2*pi*(0:1023)*20/1024); plot((abs(fft(s)).^2)/1024) Dr. R.Weber / Digital Signal Processing
Power Spectral density (2) ! Problem : each slice of M samples will give a different power spectral density estimation Solution : averaging of all the local power spectral density L samples M samples 50% overlap Impact of the windowing psd(s,M,Fs,[h(0) h(1) … h(M-1)]) = Random noise case : f=k/M Dr. R.Weber / Digital Signal Processing
Signal Power ? What is the mean power ? psd psd f 0 f 1 0.5 - 0.5 0.5 0 ? What is the mean power of the sum of signals ? Dr. R.Weber / Digital Signal Processing
Signal Processing goals • s’(n) s(n) • Power(b’(n)) 0 Goal : y(n)=s’(n)+b’(n) x(n)=s(n)+b(n) processing Signal to noise ratio : Example : Spectral point of view Temporal point of view s(n) x(n)=s(n)+b(n) Dr. R.Weber / Digital Signal Processing
Linear Digital filtering y = filter(b,a,x); b = [ b0 b1 … bN]; a = [ 1 a1 … aD]; 1. Filter if x1(n) y1(n) Filter thenx1(n)+x2(n) y1(n)+y2(n) Filter if x2(n) y2(n) Filter y(n-T) then x(n-T) Filter if x(n) y(n) Formulations : temporal view x(n) Filter y(n) non recursive part recursive part Basic properties : Linearity Temporal reproducibility Dr. R.Weber / Digital Signal Processing
Impulse response The impulse response (n) h(n) =(n) =h(n) x = [ 1 zeros(1,29)]; h = filter(b,a,x); Formulation : y(n) x(n) Filter Consequences : Non recursive Finite impulse response (FIR) Recursive Infinite impulse response (IIR) Dr. R.Weber / Digital Signal Processing
Application to stability Always stable h(n) c=0.985 c=0.95 c=0.995 Example : c=0.999 c=1 c=1.001 Formulation : Consequences : Finite impulse response (FIR) Infinite impulse response (IIR) Risk of instability Example : x = [ 1 zeros(1,400)]; c=0.985; b= 1; a=[1 -2*c*cos(2*pi*0.01) c.^2]; h = filter(b,a,x); plot(h) Dr. R.Weber / Digital Signal Processing
Convolution Filter with impulse response h(n) x(n) x(0)(n) + x(1)(n-1) + x(2)(n-2) Remarks : + which is coherent ! x(3)(n-3) + Formulation : = -- A recursive filter can be approximated by a non recursive one h(n) Dr. R.Weber / Digital Signal Processing
The Z-transform Application to the filtering: ZT ZT Formulation : useful (and simple) properties: • Given X(z)=ZT(x) and Y(z)=ZT(y) • linearity : ZT(x(n) + y(n)) = X(z) + Y(z) • convolution : Zt[(x@y)(n)] = X(z) Y(z) • ZT(x(n+1)) = z X(z) ; ZT(x(n+k)) = zk X(z) • ZT(x(n-1)) = z-1 X(z) ; ZT(x(n-k)) = z-k X(z) These make the ZT very interesting ! Dr. R.Weber / Digital Signal Processing
Stability rule o zeros x poles Im(z) Instable filter Stable filter Re(z) Formulation : o 1 x Filter stability if |zp,i|<1 o x ? x Verify this rule with the previous example 1 x o x o zplane(b,a); Dr. R.Weber / Digital Signal Processing
Frequency response (1) Filter with impulse response h(n) Formulation : x = [ 1 zeros(1,1023)]; c=0.985; b= 1; a=[1 -2*c*cos(2*pi*0.2) c.^2]; h = filter(b,a,x); H= fft(h); f=(0:1023)/1024; plot(f,10*log10(abs(H).^2)); Dr. R.Weber / Digital Signal Processing
Simple filter design method h(n) happrox(n) n n L values • Draw the frequency response, H(f), you are looking for. • Compute the impulse response, h(n), by applying an inverse Fourier Transform • By truncating the length of this response, you obtain a sequence of values which are also the non-recursive coefficients of an approximate FIR version of your filter. H(f) FT-1 rectangular windowing f Checking : Ripple can not be removed even with L large Solution : other type of windowing (hamming, hanning, blackmannharris…) Dr. R.Weber / Digital Signal Processing
Frequency response (2) Another formulation : ? c=0.985; b= 1; a=[1 -2*c*cos(2*pi*0.2) c.^2]; %zero padding to increase frequency resolution b=[b zeros(1,1023)]; a=[a zeros(1,1020)]; H= fft(b)./fft(a); f=(0:1023)/1024; plot(f,10*log10(abs(H).^2)); [H,f]=freqz(b,a,1024,1); Dr. R.Weber / Digital Signal Processing
Frequency response (3) zplane(b,a); Another formulation : f=0.25 X O f=0.5 f=0 O X Dr. R.Weber / Digital Signal Processing
Frequency response (4) Dr. R.Weber / Digital Signal Processing
Phase response (1) x(n) Filter pure delay : ? ? ? ? general case : Time responses for the given frequencies grpdelay(b,a,1024,1); freqz(b,a,1024,1); Dr. R.Weber / Digital Signal Processing
Phase response (2) linear phase filter : Yes, if FIR filters with symmetric or antisymmetric coefficients No, if IIR Dr. R.Weber / Digital Signal Processing
Filtered Power Spectral density ? Problem : What is the psd after filtering ? x(n) Filter y(n) |H(f)| 2 1 0 f 0.5 f0 Dr. R.Weber / Digital Signal Processing
Filter Specifications(1) Passband Stopband Ripple Attenuation Transition band 2 1 3 4 5 Dr. R.Weber / Digital Signal Processing
Filter Specifications (2) Order or complexity Attenuation or • If Ripple or Transition Band General rules : Ripple Attenuation Transition band then • For a given specification, IIR is always less complex than FIR But be careful to the stability (and the phase linearity) ! Dr. R.Weber / Digital Signal Processing
Basic Design Methods Bandpass : Basic FIR methods : ordre 63 64 coefficients, linear phase Least-square Equiripple order 12 26 coefficients Basic IIR methods : order 24 50 coefficients Cauer or Elliptic Butterworth Dr. R.Weber / Digital Signal Processing