Ψηφιακή Επεξεργασία Σήματος FIR Filter Design Methods

Slides:



Advertisements
Παρόμοιες παρουσιάσεις
ΕΠΕΞΕΡΓΑΣΙΑ ΣΗΜΑΤΩΝ ΝΙΚ. Α. ΤΣΟΛΙΓΚΑΣ
Advertisements

Εργαστήριο Ψηφιακής Επεξεργασίας Εικόνας
ΤΕΧΝΟΛΟΓΙΚΟ ΕΚΠΑΙΔΕΥΤΙΚΟ ΙΔΡΥΜΑ (Τ. Ε. Ι
Factoring and Testing Primes in Small Space Viliam Geffert P.J.Šafárik University, Košice, Slovakia Dana Pardubská Comenius University, Bratislava, Slovakia.
ΨΗΦΙΑΚΗ ΕΠΕΞΕΡΓΑΣΙΑ ΣΗΜΑΤΩΝ-ΦΙΛΤΡΑ.
ΨΗΦΙΑΚΗ ΕΠΕΞΕΡΓΑΣΙΑ ΣΗΜΑΤΩΝ-ΦΙΛΤΡΑ. Σχεδίαση FIR Φίλτρων – Ιδανικές Προδιαγραφές 0πω-π 1 ωcωc -ωc-ωc.
ΗΥ430 ΨΗΦΙΑΚΕΣ ΕΠΙΚΟΙΝΩΝΙΕΣ
1 ΣΧΕΔΙΑΣΗ ΨΗΦΙΑΚΩΝ ΦΙΛΤΡΩΝ Κ. Ψυχαλίνος, Σ. Νικολαϊδης Θεσσαλονίκη 2004 Αριστοτέλειο Πανεπιστήμιο Θεσσαλονίκης Τμήμα Φυσικής Μεταπτυχιακό Ηλεκτρονικής.
Θεωρία Γραφημάτων Θεμελιώσεις-Αλγόριθμοι-Εφαρμογές Ενότητα 8 Τ ΕΛΕΙΑ Γ ΡΑΦΗΜΑΤΑ Σταύρος Δ. Νικολόπουλος 1.
ΗΥ Παπαευσταθίου Γιάννης1 Clock generation.
6/26/2015HY220: Ιάκωβος Μαυροειδής1 HY220 Asynchronous Circuits.
Παρεμβολή (Interpolation)
Week 11 Quiz Sentence #2. The sentence. λαλο ῦ μεν ε ἰ δότες ὅ τι ὁ ἐ γείρας τ ὸ ν κύριον Ἰ ησο ῦ ν κα ὶ ἡ μ ᾶ ς σ ὺ ν Ἰ ησο ῦ ἐ γερε ῖ κα ὶ παραστήσει.
Πολυώνυμα και Σειρές Taylor 1. Motivation Why do we use approximations? –They are made up of the simplest functions – polynomials. –We can differentiate.
ΜΕΤΑΣΧΗΜΑΤΙΣΤΕΣ TRANSFORMERS Reference : ΤΕΙ Κρήτης - Ηλεκτρικές Μηχανές Συλλιγνάκης.
Ο PID έλεγχος. Integral Lag Distance velocity lag Υλοποιούμε την.
Προσομοίωση Δικτύων 4η Άσκηση Σύνθετες τοπολογίες, διακοπή συνδέσεων, δυναμική δρομολόγηση.
TΕΙ Κρήτης Τμήμα Μουσικής Τεχνολογιας & Ακουστικής Microphone Sensitivity.
Μετασχηματισμός αναλογικών φίλτρων σε ψηφιακά Η κλασική μέθοδος για το σχεδιασμό ψηφιακών φίλτρων βασίζεται στο μετασχηματισμό ενός αναλογικού φίλτρου.
Αριθμητική Επίλυση Διαφορικών Εξισώσεων 1. Συνήθης Δ.Ε. 1 ανεξάρτητη μεταβλητή x 1 εξαρτημένη μεταβλητή y Καθώς και παράγωγοι της y μέχρι n τάξης, στη.
Intermodulation distortion - IMD “Αρμονική παραμόρφωση δεν είναι το χειρότερο είδος Παραμόρφωσης που μπορούμε να έχουμε σε συστήματα ήχου...” Ηχητικά Συστήματα.
Τεχνολογικό Εκπαιδευτικό Ίδρυμα Κρήτης Τμήμα Εφηρμοσμένης Πληροφορικής και Πολυμέσων Εργαστήριο Νευρωνικών Δικτύων Slide 1 ΨΗΦΙΑΚΑ ΦΙΛΤΡΑ Προδιαγραφές.
ΣΗΜΑΤΑ ΚΑΙ ΣΥΣΤΗΜΑΤΑ II Καθ. Πέτρος Π. Γρουμπός Διάλεξη 3η Μετασχηματισμός Fourier.
OFDM system characteristics. Effect of wireless channel Intersymbol interference in single carrier systems due to multipath propagation with channel delay.
ΣΗΜΑΤΑ ΚΑΙ ΣΥΣΤΗΜΑΤΑ II Καθ. Πέτρος Π. Γρουμπός Διάλεξη 4η Δειγματοληψία.
Relations Chapter 9.
Αναπαράσταση αριθμών στον υπολογιστή Σφάλματα
Αναλογικά φίλτρα Σεραφείμ Καραμπογιάς
Αλγόριθμος κατασκευής ψηφιακών IIR φίλτρων από αντίστοιχα αναλογικά
Matrix Analytic Techniques
ΣΗΜΑΤΑ & ΣΥΣΤΗΜΑΤΑ Θεωρία Σημάτων: ανάλυση στο χρονικό και στο φασματικό πεδίο Θεωρία Γραμμικών Συστημάτων Συνεχής συνέλιξη (Continuous convolution) Διακριτού.
Στο μάθημα συζητήσαμε για το spatial frequency tuning των κυττάρων της V1, που σημαίνει ότι τέτοια κύτταρα έχουν μέγιστη απόκριση για τον προτεινόμενο.
Υλοποίηση ψηφιακών φίλτρων
Αν. Καθηγητής Γεώργιος Ευθύμογλου
Αν. Καθηγητής Γεώργιος Ευθύμογλου
Αν. Καθηγητής Γεώργιος Ευθύμογλου
φίλτρα IIR (Infinite Impulse Response)
Άλλη επιλογή: Κύλινδρος:
ΤΕΙ ΚΕΝΤΡΙΚΗΣ ΜΑΚΕΔΟΝΙΑΣ-ΣΕΡΡΕΣ ΜΗΧΑΝΙΚΩΝ ΠΛΗΡΟΦΟΡΙΚΗΣ
Απόκριση Γραμμικών Συστημάτων σε Εκθετικές Εισόδους
(ALPHA BANK – EUROBANK – PIRAEUS BANK)
Example Rotary Motion Problems
Αν. Καθηγητής Γεώργιος Ευθύμογλου
Αν. Καθηγητής Γεώργιος Ευθύμογλου
Μία πρακτική εισαγωγή στην χρήση του R
Πανεπιστήμιο Θεσσαλίας
Συστήματα Αναμονής (Queuing Systems)
Find: φ σ3 = 400 [lb/ft2] CD test Δσ = 1,000 [lb/ft2] Sand 34˚ 36˚ 38˚
GLY 326 Structural Geology
Find: angle of failure, α
ΕΝΣΤΑΣΕΙΣ ΠΟΙΟΣ? Όμως ναι.... Ένα σκάφος
Find: minimum B [ft] γcon=150 [lb/ft3] γT=120 [lb/ft3] Q φ=36˚
Γραμμικός Προγραμματισμός
Find: ρc [in] from load γT=110 [lb/ft3] γT=100 [lb/ft3]
Find: ρc [in] from load γT=106 [lb/ft3] γT=112 [lb/ft3]
ΑΝΟΡΓΑΝΗ & ΑΝΑΛΥΤΙΚΗ ΧΗΜΕΙΑ
Find: σ1 [kPa] for CD test at failure
Καθηγητής Γεώργιος Ευθύμογλου
Βάλια Τόλιου, Registry Manager for Greece
Καθηγητής Γεώργιος Ευθύμογλου
τ [lb/ft2] σ [lb/ft2] Find: c in [lb/ft2] σ1 = 2,000 [lb/ft2]
Find: Force on culvert in [lb/ft]
Αλγόριθμος κατασκευής ψηφιακών IIR φίλτρων από αντίστοιχα αναλογικά
Καθηγητής Γεώργιος Ευθύμογλου
Deriving the equations of
Δοκοί Διαγράμματα Τεμνουσών Δυνάμεων και Καμπτικών Ροπών
Find: ρc [in] from load (4 layers)
CPSC-608 Database Systems
Μεταγράφημα παρουσίασης:

Ψηφιακή Επεξεργασία Σήματος FIR Filter Design Methods Αν. Καθηγητής Γεώργιος Ευθύμογλου November 16, 2018 Module Title

Εισαγωγή Προδιαγραφές ψηφιακών φίλτρων FIR φίλτρα με γραμμική φάση Κρουστική απόκριση φίλτρου FIR φίλτρα με γραμμική φάση Zero locations for linear phase FIR filters FIR design methods Window method Frequency sampling Module Title

Filter Specifications Σχέση αναλογικής συχνότητας με ψηφιακή συχνότητα Nyquist frequency = Fs/2

Filter Specifications for low-pass Low-Pass frequency response

Filter Specifications for low-pass Filter specification parameters - passband edge frequency - stopband edge frequency - peak ripple value in the passband - peak ripple value in the stopband

Filter Specifications for high-pass High-Pass frequency response

Filter Specifications for band-pass Pass-band frequency response

Filter Specifications for band-stop Stop-band frequency response

Digital Filter Specifications for lowpass Σχέση αναλογικής συχνότητας με ψηφιακή γωνιακή συχνότητα

Filter specifications for low-pass In the passband we require that with a deviation n the stopband we require that

Filter Specifications for low-pass Passband [0, wp] the band of frequency components that are allowed to pass, δp indicates the magnitude of the passband ripple, which equals the maximum deviation from the unity. passband ripple (1+δp) the maximum amount by which attenuation in the passband may deviate from nominal gain Stopband [ws,π] the band of frequency components that are suppressed, stopband attenuation δs is the corresponding tolerance (or ripple) δs indicates the magnitude response of the stopband ripple, which equals the maximum deviation from zero. Transition band [wp, ws], there are no restrictions of the magnitude respponse in this band.

Filter Specifications for low-pass (1st method) Practical specifications are often given in terms of absolute power (in dB) Peak passband ripple dB or Minimum stopband attenuation

Filter Specifications for low-pass (1st method) The gain usually changes gradually through the transition band from 1 (0 dB) in the passband to 0 (−∞ dB) in the stopband. You can measure the passband ripple and stopband ripple in decibels, as shown in the following equations: passband ripple Rp = 20log10(1+δp) or - 20log10(1-δp) stopband ripple As = −20log10(δs) Based on the two equations above, you can convert the passband ripple to or from the decibel representation. For example, if passband ripple equals 0.01 dB, that is, 0.01 = 20log10(1+δp), then δp = 10^(0.01/20) – 1 = 0.00115. Similarly, if stopband ripple equals 60 dB, that is 60 = −20log10(δs), then δs = 0.001.

Filter Specifications for low-pass (2nd method) Practical specifications are often given in terms of relative power specifications in dB Peak passband ripple dB Minimum stopband attenuation

Filter Specifications for low-pass (2nd method) For example, if δp = 0.01 the passband ripple in dB equals Similarly, if δs = 0.001

Analog frequency to digital frequency conversion In practice, passband edge frequency and stopband edge frequency are specified in Hz For digital filter design, normalized band-edge frequencies need to be computed from specifications in Hz using the SAMPLING frequency

Analog frequency to digital frequency conversion Example - Let kHz, kHz, and kHz Then

Ideal Digital Filter Specifications

Linear phase FIR filters For phase linearity the FIR transfer function must have zeros outside the unit circle. The transfer function is given by Which has (M-1) poles at the origin z=0 (trivial poles) and (M-1) zeros located anywhere in the z-plane. The frequency response is

Linear phase FIR filters We impose the linear-phase constraint where β = 0 or α is a constant phase delay. Indicating a constant group delay of α samples!!! The linear phase condition imposes the following symmetry condition on the impulse response h[n]

4 types of linear-phase FIR filters Έστω h(n) είναι συμμετρική γύρω από το α, το οποίο είναι το σημείο συμμετρίας. Έχουμε 4 types of linear-phase FIR filters όταν συνδυέσουμε τις παραπάνω περιπτώσεις με μονά (odd) and ζυγά (even) M. Type I M odd (α=(M-1)/2, integer). The symmetric impulse response:

4 types of linear-phase FIR filters Type II M even (α=(M-1)/2 is not an integer). The symmetric impulse response:

4 types of linear-phase FIR filters Type III M odd (α=(M-1)/2 is an integer). The anti-symmetric impulse response:

4 types of linear-phase FIR filters Type IV M even (α=(M-1)/2 is not an integer). The anti-symmetric impulse response:

Amplitude response of linear phase filters Η απόκριση συχνότητας για κάθε ένα τύπο φίλτρου έχει συγκεκριμένες εκφράσεις και σχήματα όπου Hr(w) είναι ένα amplitude response function και όχι το magnitude response function. Το amplitude response είναι μία πραγματική συνάρτηση, όμως αντίθετα με το magnitude response το οποίο είναι πάντα θετικό, το amplitude response μπορεί να είναι θετικό ή αρνητικό Το phase response που αντιστοιχεί με το magnitude response είναι μία μη-συνεχής συνάρτηση, ενώ αυτή που αντιστοιχεί με το amplitude response είναι μία γραμμική συνάρτηση (linear function).

Example Έστω η κρουστική απόκριση για n=0,1,2. Υπολογίστε την απόκριση συχνότητας. oπότε Όμως επίσης έχουμε:

Type I β=0, α=(M-1)/2 είναι ακέραιος, και h(n)=h(M-1-n), 0≤n≤M-1.

Type I example Έστω η κρουστική απόκριση Υπολογίστε την απόκριση πλάτους και τη θέση των μηδενικών της Η(z)

Type I example Έστω η κρουστική απόκριση Υπολογίστε την απόκριση πλάτους και τη θέση των μηδενικών της Η(z)

Type I example function [Hr,w,a,L] = Hr_Type1(h); M=length(h); L=(M-1)/2; a=[h(L+1), 2*h(L:-1:1)]; n=[0:1:L]; w=[0:1:500]'*pi/500; Hr=cos(w*n)*a'; n=0:M-1; amax=max(a)+1; amin=min(a)-1;

Type I example subplot(2,2,1); stem(n,h);axis([-1 2*L+1 amin amax]) xlabel('n');ylabel('h(n)');title('Impulse Response') subplot(2,2,3);stem(0:L,a);axis([-1 2*L+1 amin amax]) xlabel('n');ylabel('a(n)');title('a(n) coefficients') subplot(2,2,2);plot(w/pi,Hr);grid xlabel('frequency in pi units'); ylabel('Hr');title('Type-1 Amplitude Response') subplot(2,2,4); zplane(h,1)

Type I example Let h(n)={-4,1,-1,-2,5,6,5-2,-1,1,-4}. Determine the amplitude response and the locations of zeros. M=11 odd and symmetric.Type-1. With Matlab: >> h=[-4,1,-1,-2,5,6,5,-2,-1,1,-4]; >> Hr_Type1(h)

Type I example

Zero locations for FIR linear phase filters The transfer function of FIR filters has (M-1) poles at the origin z=0 (trivial poles) and (M-1) zeros located anywhere in the z-plane. For linear phase filters, these zeros posses certain symmetries that are due to the symmetry properties of h[n]. It can be proved that if H(z) has a zero at Then for linear phase there must be a zero at For a real-valued filter we also know that if z1 is complex then there must be a conjugate zero at Which implies that there must also be a zero at

Zero locations for FIR linear phase filters Thus a general zero constellation is a quadraqplet of If r=1, the zeros occur in pairs If θ=0 or θ=π, the zeros are on the real line and occur in pairs

Zero locations for FIR linear phase filters In the previous example we have roots(h) ans = -0.9807 + 0.1956i -0.9807 - 0.1956i -0.5578 + 0.8300i -0.5578 - 0.8300i 0.4052 + 1.2374i 0.4052 - 1.2374i 1.2169 0.8218 0.2390 + 0.7299i 0.2390 - 0.7299i

Type II β=0, α=(M-1)/2 δεν είναι ακέραιος, και h(n)=h(M-1-n) 0≤n≤M-1. Στο w=π παίρνουμε: ανεξάρτητα από τα b(n) ή h(n). Επομένως δεν μπορούμε να χρησιμοποιήσουμε αυτό το τύπο φίλτρου για highpass ή bandstop filters.

Type II in matlab function [Hr, w, b, L] = Hr_Type2(h) M = length(h); L = M/2; b = [2*h(L:-1:1)]; n=[1:1:L]; w=[0:1:500]'*pi/500; Hr=cos(w*(n - 0.5))*b'; n=0:M-1; bmax=max(b)+1; bmin=min(b)-1; subplot(2,2,1); stem(n,h);axis([-1 2*L+1 bmin bmax]) …

Type III β=π/2, α=(M-1)/2 είναι ακέραιος, και h(n)=-h(M-1-n) 0≤n≤M-1 και h((M-1)/2)=0. Στο w=0 και w=π έχουμε Hr(w)=0, ανεξάρτητα από τα c(n) ή h(n). Αυτός ο τύπος φίλτρου δεν είναι κατάλληλος για σχεδιασμό lowpass filter or highpass filter or band-stop filter.

Type IV β=π/2, α=(M-1)/2 δεν είναι ακέραιος , and h(n)=h(M-1-n) 0≤n≤M-1. Στο w=0 έχουμε Hr(w)=0, ανεξάρτητα από τα d(n) ή h(n). Αυτός ο τύπος φίλτρου δεν είναι κατάλληλος για σχεδιασμό lowpass filter.

FIR filter types Type II, M-1 odd Therefore H(z) shοuld have a zero at z=-1 (ω=π) Similarly, Type III and IV For Type III only, since M-1 is even Type I is the only filter type with no restrictions

FIR Digital Filter Design Three commonly used approaches to FIR filter design Windowed Fourier series approach Frequency sampling approach (3) Computer-based optimization methods

Window method Η ιδανική απόκριση συχνότητας ενός low-pass filter είναι όπου ωc είναι η συχνότητα αποκοπής (cutoff frequency) και Αυτή όμως δεν είναι αιτιατή κρουστική απόκριση.

Window method Η ιδανική απόκριση συχνότητας ενός low-pass filter είναι όπου ωc είναι η συχνότητα αποκοπής (cutoff frequency) και α είναι η καθυστέρηση σε δείγματα που προκαλεί το φίλτρο

Window method This operation is called “windowing” Η χρονική διάρκεια του φίλτρου θα είναι M δείγματα Η χρονική καθυστέρηση όλων των συχνοτήτων θα είναι δείγματα Ποια επίπτωση θα έχει το μήκος της κρουστικής απόκρισης στην απόκριση συχνότητας του φίλτρου?

Window method %Ideal Lowpass filter computation function hd = ideal_lp(wc,M) alpha = (M-1)/2; n=[0:1:M-1]; m = n-alpha+eps; hd = sin(wc*m)./(pi*m); function hd = ideal_lp2(wc,M) m=n-alpha; fc =wc/(2*pi); hd = 2*fc*sinc(2*fc*m)

Window method Next routine returns the magnitude response in absolute as well as in relative dB scale, the phase response, and the group delay response. function [dB,mag,pha,grd,w]=freqz_m(b,a); [H,w]=freqz(b,a,1000,'whole'); H=(H(1:1:501))'; w=(w(1:1:501))'; mag=abs(H); dB=20*log10((mag+eps)/max(mag)); pha=angle(H); grd=grpdelay(b,a,w);

Window method Design a digital FIR lowpass filter with the following specifications: wc=0.25π M=19; Obtain the value of As >> hd=ideal_lp(0.25*pi,19); >> stem(hd) >> xlabel('sample, n') >> ylabel('amplitude')

Window method

Window method by hand

Window method in Matlab hd=ideal_lp(0.25*pi,19) hd = Columns 1 through 5 0.0250 -0.0000 -0.0322 -0.0531 -0.0450 Columns 6 through 10 0.0000 0.0750 0.1592 0.2251 0.2500 Columns 11 through 15 0.2251 0.1592 0.0750 0.0000 -0.0450 Columns 16 through 19 -0.0531 -0.0322 -0.0000 0.0250

Window method

Window method [db,mag,pha,grd,w]=freqz_m(hd,1); plot(w/pi,db) title('Magnitude Response in dB') xlabel('w/pi') ylabel('20*log10(|H(e^{jw})|') observe the maximum attenuation of -21 dB at stopband:

Επίδραση χρονικού παραθύρου w(n) Η απευθείας περικοπή του hd(n) σε πεπερασμένο αριθμό δειγμάτων ισοδυναμεί με τον πολλαπλασιασμό της κρουστικής απόκρισης με ένα ορθογώνιο window του τύπου: δηλαδή Στο πεδίο συχνότητας ο παραπάνω πολλαπλασιασμός στο χρονικό πεδίο αντιστοιχεί στη συνέλιξη του HD(ω) με το W(ω), όπου W(ω) είναι ο μετασχηματισμός Fourier της συνάρτησης παραθύρου w(n).

Επίδραση χρονικού παραθύρου w(n) Επειδή το W(ω) έχει το κλασσικό sin(x)/x σχήμα, δημιουργείται μία ζώνη μετάβασης (transition width), το εύρος της οποίας εξαρτάται από τον αριθμό Μ αφού η συνάρτηση sinc έχει το 1ο μηδενικό στη συχνότητα 2π/Μ. Το αποτέλεσμα της συνέλιξης στο πεδίο συχνοτήτων φαίνεται στο παρακάτω σχήμα.

Επίδραση χρονικού παραθύρου w(n) For rectangular window Using

Επίδραση χρονικού παραθύρου w(n) For rectangular window The running integral of the window amplitude response is necessary in the accurate analysis of the transition bandwidth and the stop-band attenuation.

Επίδραση χρονικού παραθύρου w(n) Transition width is determined by the main lobe of the frequency response of signal w(n) The main lobe width depends on the length of the filter Stop-band ripples (attenuation) are determined by the side lobes of the frequency response of signal w(n) For rectangular window w(n) these two parameters are given by Exact transition width = 1.8π/Μ As = 21 dB Question: how can we increase the stopband attenuation?

Επίδραση χρονικού παραθύρου w(n) Use a different w(n)

Επίδραση χρονικού παραθύρου w(n)

Επίδραση χρονικού παραθύρου w(n) Bartlett window Bartlett suggested a more gradual transition in the form of a triangular window, which is given by: Hanning window This is a raised cosine window function given by:

Επίδραση χρονικού παραθύρου w(n) Hamming window This window is similar to the Hanning window except that it has a small amount of discontinuity and is given by: Blackman window This window is also similar to the previous two but contains a second harmonic term and is given by:

Επίδραση χρονικού παραθύρου w(n) Kaiser window This is one of the most useful and optimum windows. It is optimum in the sense of providing a large main lobe width for the given stopband attenuation, which implies the sharpest transition width. The window function is due to J. F. Kaiser: I0 = modified zero-order Bessel function β = parameter that depends on M and that can be chosen to yield various transition widths and near-optimum stopband attenuation.

Επίδραση χρονικού παραθύρου w(n) Kaiser window properties This window can provide different transition widths for the same M, which is something other windows lack. β Transition width (Δω) Min. stop attn dB 2.12 3π/M 30 4.54 5.8π/M 50 5.66 7.7π/Μ 60 6.76 8.6π/M 70 8.96 11.4π/M 90

Design equations for Kaiser window Given Normalized transition width Filter order Parameter

Επίδραση χρονικού παραθύρου w(n) Το εύρος μετάβασης (transition width) του φίλτρου καθορίζεται από το εύρος του κύριου λοβού του window, που τώρα είναι μεγαλύτερο από ότι με το ορθογώνιο παράθυρο. Όμως, οι πλαϊνοί λοβοί είναι υπεύθυνοι για τους κυματισμούς στη passband και στη stopband περιοχή, και τώρα έχουν μειωθεί σε σχέση με το ορθογώνιο παράθυρο. Window Method Specify the desired frequency response Select a window function based on the As filter specification and estimate the number of filter coefficients, N Obtain the ideal impulse response hd(n) (truncated to N values) Obtain N coefficients of the window function, w(n) Obtain the FIR filter coefficients as h(n) = hd(n) x w(n)

Επίδραση χρονικού παραθύρου w(n)

Επίδραση χρονικού παραθύρου w(n) Design a digital FIR lowpass filter with the following specifications: Wp=0.2π Ws=0.3π Rp=0.25 dB As=50 dB Choose an appropriate window function and determine the impulse response and provide a plot of the frequency response of the designed filter.

Επίδραση χρονικού παραθύρου w(n) clear wp=0.2*pi; ws=0.3*pi; tr_width = ws - wp; M = ceil(6.6*pi/tr_width) + 1 n=[0:1:M-1]; wc = (ws+wp)/2; % Ideal LPF cutoff frequency hd = ideal_lp(wc,M) w_ham = hamming(M)' h = hd .* w_ham;

Επίδραση χρονικού παραθύρου w(n) [db,mag,pha,grd,w]=freqz_m(h,1); plot(w/pi,db) title('Magnitude Response in dB') xlabel('w/pi') ylabel('20*log10(|H(e^{jw})|') delta_w=2*pi/1000; Rp=-(min(db(1:1:wp/delta_w+1))) As=-round(max(db(ws/delta_w+1:1:501)))

Επίδραση χρονικού παραθύρου w(n) Rp = 0.0394 As = 52

Επίδραση χρονικού παραθύρου w(n) plot(w/pi,db) title('Magnitude Response in dB') xlabel('w/pi') ylabel('20*log10(|H(e^{jw})|')

Other filter responses: High Pass The high-pass frequency response can be obtained as the complementary of the low-pass, that is

Other filter responses: Band-Pass The band-pass frequency response can be obtained from a combination of 2 low-pass filters, that is LP(wc2) – LP(wc1)

Other filter responses: Band-Stop The band-stop frequency response can be obtained from a combination of 2 filters, that is LP(wc1) + HP(wc2)

FIR filter design example using fir1 Παράδειγμα 1 Σχεδιάστε με τη μέθοδο Window ένα ψηφιακό FIR Lowpass με τις εξής προδιαγραφές Passband edge frequency 1 KHz Stopband edge frequency 4.3 KHz Fs 10 KHz Use Hamming window.

FIR filter design example using fir1 The fir1 function in matlab is used to design FIR filters using the window method. The basic command h = fir1(N-1, Fc) assumes a Hamming window and low-pass filter with cuttoff Fc Fc should be normalized to the Nyquist frequency Fs/2 The syntax can be extended to different filter types and window functions, as follows: h = fir1(N-1, Fc, ‘filter-type’) % filter type = high or stop % for both bandpass and bandstop filters Fc is a vector of 2 cutoff frequencies h = fir1(N-1,Fc, window) % window = boxcar(N), blackman(N)… hamming (N), hanning(N), kaiser(N,beta) h = fir1(N-1, Fc, ‘filter-type’, window)

FIR filter design example using fir1 Δf = (4.3 – 1)/10 =0.33 (normalized digital transition band) Δf = 3.3/Ν → N = 3.3/0.33 = 10  N=11 (Type I) Επίσης cutoff frequency παίρνουμε στο μέσο της transition band Fc = 1+(4.3 – 1)/2 = 2.65 KHz Kανονικοποιημένη ως προς την συχνότητα Nyquist (Fs/2): Fc (normalized λόγω matlab function fir1) = 2.65/5 = 0.53 fc = 0.53; N=11; hd=fir1(N-1,fc,boxcar(N)); % boxcar for rectangular window wn=hamming(N); hn=fir1(N-1,fc,wn);

FIR filter design example 1 hd' ans = 0.0529 0.0273 -0.0950 -0.0278 0.2955 0.4942 hn' ans = 0.0045 0.0049 -0.0403 -0.0202 0.2875 0.5272 n=[0:10]; plot(n,hn,'bx-',n,hd,'ro-') xlabel('sample index') ylabel('impulse response') legend('hamming', 'rectangular')

FIR filter design example 1 Fs=10000; [H,f]=freqz(hn,1,256, Fs); % freq response data stored in H mag=20*log10(abs(H)); plot(f,mag), grid on xlabel('Frequency (Hz)') ylabel('Magnitude Response (dB)') hold on [Hd,f]=freqz(hd,1,256, Fs); magd=20*log10(abs(Hd)); plot(f,magd,'r') legend('Hamming', 'Rectangular')

FIR filter design example 2 Σχεδιάστε ένα ψηφιακό FIR lowpass filter με τις παρακάτω προδιαγραφές Επιλέξτε κατάλληλη συνάρτηση παραθύρου. Υπολογίστε την κρουστική απόκριση και δώστε την απόκριση συχνότητας του φίλτρου. Απάντηση Τα παράθυρα Hamming και Blackman δίνουν εξασθένιση (attenuation) περισσότερο από 50 dB. Ας επιλέξουμε το Hamming παράθυρο.

FIR filter design example 2 clear; wp=0.2*pi; ws=0.3*pi; tr_width = ws - wp; M = ceil(6.6*pi/tr_width) + 1 % M = 67 n=[0:1:M-1]; wc = (ws+wp)/2; % ideal LowPass cutoff frequency hd = ideal_lp(wc, M); w_ham = (hamming(M))'; h = hd .* w_ham;

FIR filter design example 2 [H, w] = freqz(h, 1, 500); % obtain frequency response in % 500 frequencies from 0 -pi delta_w = pi/500; H_dB = 20*log10(abs(H)); Rp = -min(H_dB(1:1:wp/delta_w+1)) % Actual Passband Ripple As = -round(max(H_dB(ws/delta_w+1:1:500))) %Minimum Stopband Attenuation M = 67 Rp = 0.0191 As = 52

FIR filter design example 2 figure(1) stem(n,h) xlabel('n') ylabel('impulse response… h(n)')

FIR filter design example 2 figure(2) plot(w/pi, H_dB) xlabel('frequency … in pi units') ylabel('20*log10(abs(H))')

FIR filter design example 3 Σχεδιάστε ένα ψηφιακό FIR bandpass filter με τις παρακάτω προδιαγραφές Lower stopband edge Lower passband edge Upper passband edge Upper stopband edge Επιλέξτε κατάλληλη συνάρτηση παραθύρου. Υπολογίστε την κρουστική απόκριση και δώστε την απόκριση συχνότητας του φίλτρου. Απάντηση Στο φίλτρο αυτό υπάρχουν δύο ζώνες μετάβασης και οι οποίες πρέπει να είναι ίδιες για τη σχεδίαση με τη μέθοδο Window. Για την προδιαγραφή εξασθένισης στη περιοχή αποκοπής (stopband) μπορούμε να έχουμε παράθυρα Kaiser ή Blackman. Επιλέγουμε Blackman παράθυρο.

FIR filter design example 3 clear; ws1=0.2*pi; wp1=0.35*pi; wp2=0.65*pi; ws2=0.8*pi; tr_width = min ((wp1 - ws1), (ws2-wp2)); M = ceil(11*pi/tr_width) + 1 n=[0:1:M-1]; wc1 = (ws1+wp1)/2; wc2 = (wp2+ws2)/2; hd = ideal_lp(wc2, M) - ideal_lp(wc1, M); w_bla = (blackman(M))'; h = hd .* w_bla;

FIR filter design example 3 [H, w] = freqz(h, 1, 500); % obtain frequency response in % 500 frequencies from 0 -pi delta_w = pi/500; H_dB = 20*log10(abs(H)); Rp = -min(H_dB(wp1/delta_w+1:1:wp2/delta_w+1)) % Actual Passband Ripple As = -round(max(H_dB(ws2/delta_w+1:1:500))) %Minimum Stopband Attenuation M = 75 Rp = 0.0016 As = 75

FIR filter design example 3 figure(1) stem(n,h) xlabel('n') ylabel('impulse … response h(n)')

FIR filter design example 3 figure(2) plot(w/pi, H_dB) xlabel('frequency in pi units') ylabel('20*log10(abs(H))')

FIR filter design example 4 Σχεδιάστε με τη μέθοδο Window ένα ψηφιακό FIR bandpass με τις εξής προδιαγραφές Passband 150 – 250 Hz Transition width 50 Hz Passband ripple 0.1 dB Stopband attenuation 60 dB Sampling frequency 1KHz Using Kaiser window.

FIR filter design example 4 Για Kaiser έχουμε οπότε N = 73 The ripple parameter is Οι ιδανικές cutoff συχνότητες λαμβάνονται στο μέσο της ζώνης μετάβασης

FIR filter design example 4 clear; Fs = 1000; Fn = Fs/2; N = 73; beta = 5.65; fc1 = 125/Fn; %normalized for Matlab function fir1 fc2 = 275/Fn; %normalized for Matlab function fir1 FC = [fc1, fc2] % vector with 2 cutoffs hn = fir1(N-1, FC, kaiser(N, beta)); [H,f]=freqz(hn,1,256, Fs); mag=20*log10(abs(H)); figure(2) plot(f,mag), grid on xlabel('Frequency (Hz)'); ylabel('Magnitude Response (dB)'); legend('Kaiser')

FIR filter design example 4

FIR filter design example 5: High pass Σχεδιάστε το ιδανικό ψηφιακό FIR highpass filter με τις παρακάτω προδιαγραφές % Ideal highpass filter computation function hd = ideal_hp(wc, M) alpha = (M-1)/2; n=[0:1:M-1]; m = n-alpha+eps; hd = - sin(wc*m)./(pi*m); hd(alpha+1)=1-wc/pi;

FIR filter design example 5: High pass hd=ideal_hp(0.5*pi,19); [H,w]=freqz(hd,1,200); plot(w/pi, 20*log10(abs(H))) xlabel('w/pi') ylabel('20*log10(abs(H))')

Μέθοδος δειγματοληψίας συχνότητας Ας υποθέσουμε πως επιθυμούμε να αποκτήσουμε FIR συντελεστές του φίλτρου, του οποίου η συχνότητα απόκρισης απεικονίζεται στο διπλανό Σχήμα. Μπορούμε να αρχίσουμε παίρνοντας Ν δείγματα από την απόκριση συχνότητας σε συχνότητες f(k) = k Fs / N, k = 0, 1,…, Ν-1.

Frequency sampling method (1/6) Οι συντελεστές φίλτρου h(n) μπορούν να αποκτηθούν από τον αντίστροφο DFT (IDFT) των δειγμάτων συχνότητας: όπου H(k), k = 0,1…, N-1, είναι τα δείγματα της ιδανικής απόκρισης συχνότητας για ψηφιακές γωνιακές συχνότητες Από το Σχήμα 1b παρατηρούμε ότι γνωρίζουμε μόνο τα πλάτη της απόκρισης συχνότητας αλλά όχι την φάση, ώστε να χρησιμοποιήσουμε τον IDFT για να βρούμε την κρουστική απόκριση h(n).

Frequency sampling method (2/6) Γενικά λόγω της συμμετρίας ή αντισυμμετρίας που παρουσιάζουν τα FIR τόσο για άρτιο όσο και για περιττό μήκος Ν της κρουστικής τους απόκρισης, παίρνουμε 4 είδη FIR με γραμμική φάση. Η απόκριση συχνότητας για όλα τα FIR μπορεί να γραφεί από τη σχέση όπου είναι η απόκριση πλάτους του φίλτρου και η γραμμική φάση είναι . Η φάση της απόκρισης συχνότητας για FIR φίλτρα είναι γνωστή και για τα 4 είδη (Types) FIR που υπάρχουν.

Frequency sampling method (3/6) Επομένως στην μέθοδο δειγματοληψίας συχνότητας, η απόκριση συχνότητας δίνεται από όπου υπολογίζουμε την απόκριση πλάτους στις ψηφιακές γωνιακές συχνότητες , όπου λόγω συμμετρίας της απόκρισης πλάτους γύρω από το ω=π.

Frequency sampling method (4/6) Η προϋπόθεση ότι h(n) θα έχει πραγματικές τιμές απαιτεί ότι η απόκριση συχνότητας θα είναι συζυγής συμμετρική (conjugate symmetric). Θεωρήστε Ν άρτιο: (1) Επειδή ο Discrete Fourier Transform είναι περιοδικός, έχουμε (2) Επομένως από την (1) και (2) έχουμε:

Frequency sampling method (5/6) Η φάση προκύπτει με δειγματοληψία της στις και δίνεται από:

Frequency sampling method (6/6) Η επιθυμητή κρουστική απόκριση υπολογίζεται από τη σχέση

Frequency sampling method using fir2 The fir2 command is used to design FIR filters with arbitrary frequency response characteristics h = fir2(N-1, F, H) calculates a N-length FIR filter the vector F specifies the normalized frequency points in the range 0 to 1 (with frequency values normalized to half the sampling frequency, as before) the vector H specifies the desired magnitude response at the frequency points specified by F.

Frequency sampling method using fir2 Υπολογίστε τους συντελεστές ενός φίλτρου με 15 συντελεστές το οποίο έχει τις παρακάτω τιμές για το μέτρο της απόκρισης συχνότητας clear >> N=15; >> fd=[0 1/7 2/7 3/7 4/7 5/7 6/7 1]; >> Hd=[1 1 1 1 0.5571 0.0841 0 0]; >> hn=fir2(N-1, fd, Hd);

Frequency sampling method using fir2 >> Fs=2000; >> [H,f]=freqz(hn,1,512,Fs); >> plot(f, abs(H)), grid on >> xlabel('Frequency (Hz)') >> ylabel('Magnitude')

Frequency sampling method με τη μέθοδο δειγματοληψίας συχνότητας. Έστω ότι επιλέγουμε Ν = 20 Τότε Επομένως έχουμε 3 δείγματα απόκρισης συχνότητας στην περιοχή διέλευσης ζώνης (passband) [0≤ω≤ωp] και 7 δείγματα στη περοχή αποκοπής (stopband) [ωs ≤ω≤π]

Frequency sampling method Δηλαδή η ιδανική απόκριση πλάτους είναι : Επίσης, επειδή Ν=20 και πρόκειται για Type-2 FIR , οπότε

Frequency sampling method N = 20; alpha = (N-1)/2; k = 0:N-1; wk = (2*pi/N)*k; Hrs = [1,1,1,zeros(1,15),1,1]; %ideal amplitude response sampled k1 = 0:floor((N-1)/2); k2 = floor((N-1)/2)+1:N-1; angH = [-alpha*(2*pi/N)*k1, alpha*(2*pi/N)*(N-k2)]; %linear phase H = Hrs.*exp(j*angH); % ideal frequecy response h = real(ifft(H, N)); % h is the IDFT of H

Frequency sampling method [H_pr, w] = freqz(h,1,256) [H_pr2, w2] = freqz(h,1,10) % freq response sampled at wk subplot(2,1,1) stem(h, 'o') xlabel('n') ylabel('h(n)') subplot(2,1,2) plot(w/pi,abs(H_pr),w2/pi,abs(H_pr2),'o') xlabel('frequency in pi units') ylabel('Hr(w)')

Frequency sampling method

Frequency sampling method with optimization Πρέπει τώρα να εξετάσουμε αν ο παραπάνω σχεδιασμός με τη μέθοδο δειγματοληψίας συχνότητας ικανοποιεί την αρχική προδιαγραφή για τη stopband attenuation As [H, w] = freqz(h, 1, 500); % obtain frequency response in % 500 frequencies from 0 -pi delta_w = pi/500; H_dB = 20*log10(abs(H)); Rp = -min(H_dB(1:1:wp/delta_w+1)) % Actual Passband Ripple % Stopband Attenuation As = -round(max(H_dB(ws/delta_w+1:1:500))) %ws/delta_w+1=151 >> As=15

Frequency sampling method with optimization Για να αυξήσουμε τη stopband attenuation As με τη μέθοδο δειγματοληψίας συχνότητας πρέπει να αυξήσουμε το μήκος Ν να προσδιορίσουμε κάποια ή κάποιες τιμές στην περιοχή μετάβασης ‘Εστω Ν=40, οπότε έχουμε 1 δείγμα στην περιοχή μετάβασης 0.2π<ω<0.3π Επειδή τα δείγματα στην περιοχή μετάβασης είναι στο k=5 και στο k=40-5=35. Έστω η τιμή του δείγματος είναι Τ1

Frequency sampling method with optimization Επειδή Ν=40 T1=0.5; >> As = 30 Τ1=0.39 >>As = 43

Frequency sampling method with optimization Εστω Ν=60, οπότε έχουμε 2 δείγματα στην περιοχή μετάβασης 0.2π<ω<0.3π, με τιμές έστω Τ1 και Τ2 Από πίνακες προκύπτει ότι οι βέλτιστες (optimized) τιμές για τα Τ1 και Τ2 είναι Τ1 = 0.5925 και Τ2=0.1099 Χρησιμοποιώντας τις παραπάνω τιμές, το Αs βρίσκεται >>As = 63 το οποίο ικανοποιεί την προδιαγραφή για As > 50 dB. Παρατηρήστε ότι το μήκος Ν=60 είναι μικρότερο από αυτό με τη μέθοδο παραθύρου Ν=73.

Linear-Phase FIR Filter Design by Optimization Amplitude response for all 4 types of linear-phase FIR filters can be expressed as where

Linear-Phase FIR Filter Design by Optimization Αφού έχουμε μία κοινή μαθηματική έκφραση για το μπορούμε να ορίσουμε το Chebyshev approximation problem ως εξής: έστω η συνάρτηση σφάλματος επιθυμητής και εφικτής απόκρισης πλάτους: Υπολογίστε τους συντελεστές Ώστε να ελαχιστοποιείται η συνάρτηση σφάλματος στις περιοχές passband και stopband.

Weighted function W(ω) Το W(ω) ορίζεται έτσι ώστε το μέγιστο σφάλμα τόσο στην passband όσο και στη stopband να είναι Επομένως αν πετύχουμε ελαχιστοποίηση του σφάλματος σε σχέση με το ικανοποιούμε αυτόματα και την απαίτηση για το

Linear-Phase FIR Filter Design by Optimization Modified form of weighted error function Where and therefore

Linear-Phase FIR Filter Design by Optimization Optimization Problem - Determine which minimizes the peak absolute value of over the specified frequency bands After has been determined, construct the original and hence h(n)

Related problem to min-max How many local maxima and minima exist in the error function E(ω) for a given M-point filter? The answer is in the expression of P(ω), as a Chebyshev polynomial That is P(ω) is an L-th order polynomial of cos(ω), cos(ω) is a monotonic function in 0 < ω < π P(ω) has at most (L-1) local extrema in the open interval 0 < ω < π If we include the end points ω=0 and ω=π, P(ω) has at most (L+1) local extrema The filter specs have to be met at the edge frequencies, so the error function has at most L+3 extrema in region S.

Find coefficients β(n) of P(ω) using trigonometric identities Example: h(n)= [1 2 3 4 3 2 1]/15. M=7 and h(h) symmetric Type 1

w=[0:1:200]. pi/200; >> p=(8/15). cos(w). ^2+(8/15). cos(w) w=[0:1:200]*pi/200; >> p=(8/15).*cos(w).^2+(8/15).*cos(w).^3; >> plot(w/pi, p) P(w) has L-1 = (M-1)/2 – 1 = 2 extrema in the open interval 0 < ω < π

The error function E(w) has L+3 = 6 extrema Based on this, we return to the problem

Linear-Phase FIR Filter Design by Optimization Chebyshev approximation problem: Define S as any closed subset of closed interval [0, π] Determine P(ω) such that Solution: Alternation Theorem In order that P(ω) be the unique min-max approximation to Ηdr(ω) on S, it is necessary and sufficient that E(ω) has at least L+2 “alternations” in S: A solution exists and it is unique, but how do we obtain it?

Parks-McClellan algorithm (1/2) Unknown: filter length M, ωi , a(n), δ Parks and McClellan gave an iterative solution using the Remez exchange algorithm. It assumes that the filter length M, and ratio δs/ δp are known. Then we choose the weighting function If M is chosen correctly, then δ = δs when the solution is found.

Parks-McClellan algorithm (2/2) The Parks-McClellan algorithm begins by guessing (L+2) external frequencies ωi and estimating the maximum error δ at these frequencies. It then fits an L-th order polynomial given by through points Local maximum errors are determined in more frequencies in S and the external frequencies ωi are adjusted to the new external values. The iteration continues until the optimum set of frequencies ωi and the global maximum error δ αre found.

Related problem to min-max The iterative procedure yields polynomial P(ω) From the expression of P(ω) The coefficients β(n) are determined. Finally, the coefficients α(n) as well as the impulse response h(n) are computed. In Matlab: [h] = remez(N, f, m, weights, ftype) filter length M=N+1 f contains band-edge frequencies in units of π, m contains desired magnitude response at frequencies in vector f

FIR Digital Filter Order Estimation Solution is obtained via the Alternation Theorem The optimal solution has equiripple behaviour consistent with the total number of available parameters. Parks and McClellan used the Remez algorithm to develop a procedure for designing linear FIR digital filters. Kaiser’s Formula: that is, M is inversely proportional to transition band width and not on transition band location Both formulae provide only an estimate of the required filter order M. If specifications are not met, increase filter order until they are met.

Using Parks-McClellan algorithm Ας σχεδιάσουμε το προηγούμενο lowpass φίλτρο χρησιμοποιώντας τον αλγόριθμο Parks-McClellan wp=0.2*pi; ws=0.3*pi; Rp = 0.25; As=50; delta1 = (10^(Rp/20)-1)/ (10^(Rp/20)+1) delta2=(1+delta1)*(10^(-As/20)) weights=[delta2/delta1, 1] deltaf=(ws-wp)/(2*pi) M = ceil((-20*log10(sqrt(delta1*delta2))-13)/(14.6*deltaf)+1) >> M=43

Using Parks-McClellan algorithm f = [0 wp/pi ws/pi 1]; m = [1 1 0 0]; h = remez(M-1, f, m, weights); [H, w] = freqz(h, 1, 500); % obtain frequency response in % 500 frequencies from 0 -pi delta_w = pi/500; H_dB = 20*log10(abs(H)); As = -round(max(H_dB(ws/delta_w+1:1:500))) >> As = 47.85 M=M+1 … until we find As > 50 …