Filtrage Numerique - Semestre 6
Annee Universitaire : 2022-2023
Semestre : 6
Credits : 2,5 ECTS
Specialite : Traitement du Signal et Automatique
PART A - Presentation Generale du Cours
Vue d'ensemble
Ce cours approfondit le traitement numerique du signal avec un focus sur la conception et l'implementation de filtres numeriques. Il couvre les deux grandes familles de filtres : FIR (Finite Impulse Response) et IIR (Infinite Impulse Response), avec leurs methodes de conception respectives. Le cours combine theorie mathematique (transformee en Z, reponse frequentielle) et pratique (MATLAB, implementation).
Objectifs pedagogiques :
- Maitriser la transformee en Z et l'analyse dans le domaine frequentiel
- Concevoir des filtres FIR par methode des fenetres
- Concevoir des filtres IIR par transformation bilineaire et invariance impulsionnelle
- Analyser la stabilite et les performances des filtres numeriques
- Implementer et tester des filtres en MATLAB
Position dans le cursus
Ce cours s'appuie sur et complete :
- Signal (S5) : transformee de Fourier, transformee de Laplace, echantillonnage
- Modelisation Systemes Lineaires (S5) : fonctions de transfert, stabilite
Il prepare aux applications :
- Traitement du Signal Avance : applications audio, biomedicales, communications
- Embedded IA for IoT (S9) : pretraitement de signaux pour machine learning
- Projets de traitement de donnees : analyse spectrale, filtrage adaptatif
PART B - Experience Personnelle et Contexte d'Apprentissage
Organisation et ressources
Le module etait structure autour de trois axes :
1. Cours magistraux :
- Rappels sur l'echantillonnage et la transformee en Z
- Filtres FIR : proprietes, methodes de conception
- Filtres IIR : transformation de filtres analogiques
- Structures d'implementation et effets de quantification
2. Travaux diriges :
- Exercices de conception de filtres FIR par fenetrage
- Transformation bilineaire pour filtres IIR
- Analyse de stabilite (placement poles et zeros)
- Calculs de reponses frequentielles
3. Travaux pratiques MATLAB :
- Utilisation de l'outil fdatool (Filter Design and Analysis Tool)
- Conception et test de filtres FIR et IIR
- Comparaison de performances (ordre, attenuation, phase)
- Application a des signaux reels (audio, ECG)
Ressources pedagogiques :
- Playlist YouTube avec cours et TD : Traitement du Signal
- Annales d'examens 2022 et 2023 avec corrections
- Documentation MATLAB Signal Processing Toolbox
Deroulement et methodologie
Approche progressive :
Le cours adoptait une approche en trois etapes :
- Theorie : etablir les fondements mathematiques (transformee en Z, equations aux differences)
- Methodes : appliquer des techniques systematiques de conception
- Pratique : valider et optimiser avec MATLAB
Figure : Principe du filtrage numerique - Reduction du bruit par filtrage
Exemple de conception de filtre passe-bas FIR :
Cahier des charges :
- Frequence de coupure : 1 kHz
- Frequence d'echantillonnage : 8 kHz
- Attenuation bande coupee : > 40 dB
- Ondulation bande passante : < 0,5 dB
Demarche :
- Choix de la methode (fenetre de Hamming pour compromis)
- Calcul de l'ordre necessaire (fonction du gabarit)
- Generation des coefficients avec MATLAB : fir1(N, Wn, 'low')
- Verification de la reponse frequentielle : freqz(b, a)
- Test sur signal reel
Examens et evaluations
Format des examens :
Les annales montrent une structure recurrente :
Exercice 1 : Filtres FIR (30-40%)
- Conception par fenetrage
- Calcul de l'ordre minimal
- Comparaison de differentes fenetres
- Analyse de la reponse en frequence
Exercice 2 : Filtres IIR (30-40%)
- Transformation bilineaire ou invariance impulsionnelle
- Calcul de la fonction de transfert en Z
- Placement des poles et zeros
- Verification de la stabilite
Exercice 3 : Implementation (20-30%)
- Structure directe ou en cascade
- Effets de quantification
- Optimisation du nombre de bits
- Equations aux differences
Difficultes courantes :
- Confusion entre frequence normalisee (0 a 1) et frequence physique (Hz)
- Erreurs dans la transformation bilineaire (pre-deformation)
- Oubli de verifier la stabilite (poles a l'interieur du cercle unite)
- Mauvaise interpretation des specifications (dB vs lineaire)
Outils MATLAB utilises
Fonctions principales :
% Conception FIR
b = fir1(N, Wn, 'type'); % Fenetre
b = firpm(N, F, A); % Parks-McClellan (optimal)
% Conception IIR
[b,a] = butter(N, Wn, 'type'); % Butterworth
[b,a] = cheby1(N, Rp, Wn, 'type'); % Chebyshev Type I
[b,a] = cheby2(N, Rs, Wn, 'type'); % Chebyshev Type II
[b,a] = ellip(N, Rp, Rs, Wn, 'type'); % Elliptique
% Analyse
freqz(b, a, N); % Reponse frequentielle
zplane(b, a); % Diagramme poles-zeros
grpdelay(b, a); % Delai de groupe
filter(b, a, x); % Filtrage
PART C - Aspects Techniques Detailles
1. Fondements : Transformee en Z
La transformee en Z est l'equivalent discret de la transformee de Laplace.
Definition :
Pour un signal discret x[n], la transformee en Z est :
X(z) = somme de x[n] x z^(-n) pour n de -infini a +infini
Proprietes importantes :
- Linearite : Z{a x x[n] + b x y[n]} = a x X(z) + b x Y(z)
- Decalage temporel : Z{x[n-k]} = z^(-k) x X(z)
- Convolution : Z{x[n] * h[n]} = X(z) x H(z)
Region de convergence (ROC) :
Zone du plan complexe ou la transformee converge. Critique pour la stabilite.
Lien avec la transformee de Fourier :
Sur le cercle unite (z = e^(jw)), la transformee en Z devient la DTFT (Discrete-Time Fourier Transform).
2. Filtres FIR (Finite Impulse Response)
Caracteristiques :
Un filtre FIR a une reponse impulsionnelle de duree finie :
y[n] = b0 x x[n] + b1 x x[n-1] + ... + bN x x[n-N]
Fonction de transfert : H(z) = b0 + b1 x z^(-1) + ... + bN x z^(-N)
Avantages :
- Toujours stable (pas de poles, uniquement des zeros)
- Phase lineaire possible (important pour audio, images)
- Pas de probleme de retroaction
- Implementation simple
Inconvenients :
- Ordre eleve necessaire pour selectivite forte
- Temps de calcul proportionnel a l'ordre
- Delai de groupe constant mais parfois important
Methode des fenetres :
Principe : partir de la reponse impulsionnelle ideale (infinie) et la tronquer avec une fenetre.
| Fenetre | Lobe principal | Attenuation bande coupee | Ondulation |
|---|---|---|---|
| Rectangulaire | Etroit | -21 dB | Forte (9%) |
| Hamming | Moyen | -53 dB | Moyenne (0,2%) |
| Hanning | Moyen | -44 dB | Moyenne |
| Blackman | Large | -74 dB | Faible |
| Kaiser | Ajustable | Parametrable | Parametrable |
Compromis : largeur du lobe principal (bande de transition) vs attenuation bande coupee.
Exemple : filtre passe-bas avec fenetre de Hamming
% Specifications
Fs = 8000; % Frequence d'echantillonnage (Hz)
Fc = 1000; % Frequence de coupure (Hz)
N = 50; % Ordre du filtre
% Frequence normalisee (0 a 1, ou 1 = Fs/2)
Wn = Fc / (Fs/2);
% Conception
b = fir1(N, Wn, 'low', hamming(N+1));
% Visualisation
freqz(b, 1, 1024, Fs);
title('Filtre passe-bas FIR - Hamming');
Methode de Parks-McClellan (optimal) :
Algorithme d'echange de Remez pour obtenir une reponse equi-ondulation (ripple egal en bande passante et bande coupee).
Avantage : ordre minimal pour un gabarit donne.
% Specifications
F = [0 0.2 0.3 1]; % Frequences normalisees
A = [1 1 0 0]; % Amplitudes souhaitees
b = firpm(50, F, A); % Conception optimale
3. Filtres IIR (Infinite Impulse Response)
Caracteristiques :
Un filtre IIR utilise une retroaction (recursion) :
y[n] = b0 x x[n] + b1 x x[n-1] + ... - a1 x y[n-1] - a2 x y[n-2] - ...
Fonction de transfert : H(z) = B(z) / A(z) = (b0 + b1 x z^(-1) + ...) / (1 + a1 x z^(-1) + a2 x z^(-2) + ...)
Avantages :
- Ordre faible pour selectivite elevee (efficacite)
- Correspondent aux filtres analogiques classiques
- Moins de calculs que FIR equivalent
Inconvenients :
- Potentiellement instables (poles hors cercle unite)
- Phase non-lineaire (distorsion de phase)
- Sensibles a la quantification des coefficients
- Risque de cycles limites (oscillations parasites)
Conception par transformation de filtres analogiques :
On part d'un filtre analogique eprouve (Butterworth, Chebyshev, Elliptique) et on le transforme en filtre numerique.
Approximations analogiques :
| Type | Bande passante | Bande coupee | Phase | Ordre |
|---|---|---|---|---|
| Butterworth | Maximalement plate | Monotone | Bonne | Eleve |
| Chebyshev I | Ondulations | Monotone | Moyenne | Moyen |
| Chebyshev II | Plate | Ondulations | Moyenne | Moyen |
| Elliptique | Ondulations | Ondulations | Mauvaise | Faible |
Transformation bilineaire :
Methode la plus utilisee. Transforme l'axe imaginaire du plan s (analogique) vers le cercle unite du plan z (numerique).
Transformation : s = (2/T) x (1 - z^(-1)) / (1 + z^(-1))
ou T est la periode d'echantillonnage.
Pre-deformation en frequence :
La transformation bilineaire deforme les frequences selon :
Omega_analogique = (2/T) x tan(omega_numerique x T/2)
Il faut donc pre-deformer les specifications avant transformation :
% Specifications numeriques
Fs = 1000; % Hz
Fc = 100; % Hz
Wn = Fc / (Fs/2); % Frequence normalisee
% Conception Butterworth ordre 4
[b, a] = butter(4, Wn, 'low');
% Verification stabilite
disp(roots(a)); % Tous les poles doivent etre < 1 en module
Invariance impulsionnelle :
Consiste a echantillonner la reponse impulsionnelle analogique.
Avantage : correspondance exacte en temporel.
Inconvenient : repliement spectral (aliasing) si signal large bande.
4. Stabilite des Filtres Numeriques
Critere de stabilite :
Un filtre numerique est stable si et seulement si tous ses poles sont a l'interieur du cercle unite du plan z.
Module de chaque pole < 1
Diagramme poles-zeros :
Outil essentiel pour visualiser et analyser la stabilite.
[b, a] = butter(4, 0.2, 'low');
zplane(b, a);
- Poles (x) : racines du denominateur A(z)
- Zeros (o) : racines du numerateur B(z)
- Cercle unite : frontiere de stabilite
Interpretation :
- Pole proche du cercle unite → forte resonance
- Zero sur le cercle unite → annulation a cette frequence
- Poles complexes conjugues → oscillations
5. Structures d'Implementation
Forme directe I :
Implementation litterale de l'equation aux differences.
- Avantage : simple a comprendre
- Inconvenient : sensible aux erreurs de quantification
Forme directe II :
Rearrangement pour minimiser les memoires (retards).
- Avantage : moins de memoire (N au lieu de 2N)
- Inconvenient : sensible aux debordements intermediaires
Forme en cascade (biquads) :
Decomposition en cellules du 2eme ordre (sections de second ordre).
H(z) = H1(z) x H2(z) x ... x Hk(z)
- Avantage : robuste a la quantification, stabilite controlee
- Utilisation : standard pour IIR
Forme parallele :
Decomposition en fractions partielles.
H(z) = H0 + H1(z) + H2(z) + ... + Hk(z)
- Avantage : traitement parallelisable
- Inconvenient : plus de multiplications
6. Effets de la Quantification
Sources d'erreurs en virgule fixe :
1. Quantification des coefficients :
- Les coefficients b[k] et a[k] sont arrondis
- Impact : deplacement des poles et zeros
- Risque : poles sortent du cercle unite → instabilite
2. Quantification des calculs :
- Produits et sommes arrondis a chaque etape
- Accumulation d'erreurs (bruit de quantification)
3. Debordement (overflow) :
- Resultats intermediaires depassent la capacite
- Solution : mise a l'echelle (scaling)
Nombre de bits necessaires :
Regle empirique :
- FIR : 12-16 bits suffisent generalement
- IIR : 16-24 bits recommandes (plus sensibles)
- Forme cascade : meilleure robustesse que forme directe
7. Reponse Frequentielle et Analyse
Module et phase :
La reponse frequentielle H(e^(jw)) caracterise le filtre :
- Module |H(w)| : gain a chaque frequence
- Phase arg(H(w)) : dephasage introduit
Phase lineaire :
Condition pour eviter la distorsion de phase : arg(H(w)) = -a x w + b
Les filtres FIR peuvent avoir une phase lineaire si leurs coefficients sont symetriques ou antisymetriques.
Delai de groupe :
Mesure du retard en fonction de la frequence :
tg(w) = -d[arg(H(w))] / dw
Pour phase lineaire : delai de groupe constant.
Analyse MATLAB :
[H, W] = freqz(b, a, 1024);
% Module en dB
subplot(2,1,1);
plot(W/pi, 20*log10(abs(H)));
ylabel('Magnitude (dB)');
% Phase
subplot(2,1,2);
plot(W/pi, angle(H));
ylabel('Phase (radians)');
xlabel('Frequence normalisee (x pi rad/echantillon)');
PART D - Analyse Reflexive et Perspectives
Competences acquises
Conception systematique de filtres :
Le cours a fourni une methodologie rigoureuse pour passer d'un cahier des charges (frequences, attenuations) a un filtre implementable. Savoir choisir entre FIR et IIR selon les contraintes.
Maitrise de MATLAB :
Les TPs ont developpe une aisance avec Signal Processing Toolbox, indispensable pour le traitement du signal moderne. Capacite a prototyper rapidement des solutions.
Analyse frequentielle :
Comprehension approfondie du lien temps-frequence, importance de la stabilite, impact des poles et zeros sur la reponse.
Points cles a retenir
1. FIR vs IIR - Le choix fondamental :
| Critere | Choisir FIR | Choisir IIR |
|---|---|---|
| Phase lineaire requise | oui | non |
| Ordre faible critique | non | oui |
| Stabilite garantie | oui | non (verifier) |
| Audio, images | oui | IIR possible |
| Temps reel contraint | non (ordre eleve) | oui |
2. Stabilite avant tout :
Toujours verifier que les poles sont dans le cercle unite. Un filtre instable est inutilisable.
3. Frequences normalisees :
Attention aux conversions : frequence physique (Hz) → normalisee (0 a 1) → pulsation numerique (0 a pi).
4. Quantification :
En implementation reelle (DSP, FPGA), les effets de virgule fixe peuvent detruire les performances. Toujours simuler avec quantification.
Applications pratiques
Audio et musique :
- Egaliseurs (filtres passe-bande multiples)
- Effets (reverberation, chorus utilisant IIR)
- Reduction de bruit (filtrage adaptatif)
Biomedical :
- Filtrage ECG : passe-bande 0,5-40 Hz pour eliminer 50 Hz secteur
- EEG : extraction de rythmes cerebraux (alpha, beta, theta)
- Detection d'anomalies cardiaques
Telecommunications :
- Filtres de mise en forme (raised cosine)
- Egalisation de canal
- Filtres anti-repliement (avant CAN) et de reconstruction (apres CNA)
Traitement d'images :
- Flou (passe-bas 2D)
- Detection de contours (passe-haut 2D)
- Debruitage (filtres medians, Wiener)
Liens avec projets et autres cours
Projets personnels :
Les competences en filtrage numerique ont ete appliquees dans plusieurs contextes :
- Analyse de signaux vibratoires pour maintenance predictive
- Traitement de signaux audio pour reconnaissance vocale
- Pretraitement de donnees IoT (capteurs accelerometres)
Complementarite avec d'autres cours :
- Signal (S5) : bases theoriques (Fourier, Laplace, echantillonnage)
- Embedded IA (S9) : filtrage comme etape de preprocessing pour ML
- Chaines d'Acquisition (S8) : filtres anti-repliement et reconstruction
- Temps Reel (S8) : contraintes d'implementation et optimisation
Limites et ouvertures
Limites du cours :
- Peu sur les filtres adaptatifs (LMS, RLS)
- Pas de traitement multirate (decimation, interpolation)
- Aspects temps reel peu developpes (latence, throughput)
- Implementation materielle (FPGA, DSP) non abordee
Ouvertures vers :
- Filtrage adaptatif : applications en annulation d'echo, egalisation
- Bancs de filtres : compression audio (MP3), analyse multiresolution
- Traitement temps-frequence : transformees en ondelettes
- Filtrage optimal : filtres de Wiener, Kalman
- Traitement d'antenne : beamforming, filtrage spatial
Evolution technologique
Tendances actuelles :
- Machine learning : remplacement de filtres classiques par reseaux de neurones pour debruitage
- Filtrage embarque : acceleration materielle (GPU, FPGA, ASIC)
- Filtrage distribue : traitement en edge computing pour IoT
- Filtrage quantique : perspectives avec calcul quantique
Outils modernes :
- Python scipy.signal : alternative a MATLAB pour le prototypage
- TensorFlow/PyTorch : filtrage par apprentissage profond
- CMSIS-DSP : bibliotheques optimisees pour ARM Cortex-M
- High-Level Synthesis : conception FPGA en C/C++
Conclusion
Le filtrage numerique est un pilier du traitement du signal. Maitriser FIR et IIR, comprendre le compromis ordre/performances, et savoir utiliser les outils de conception sont des competences essentielles pour l'ingenieur en systemes embarques, telecommunications, ou traitement de donnees.
Ce cours a fourni une base solide theorique (transformee en Z, stabilite) et pratique (MATLAB, implementation). La capacite a concevoir un filtre adapte a un cahier des charges, verifier sa stabilite, et l'implementer efficacement est desormais acquise.
Ressources pour approfondir :
- Playlist YouTube du cours : Traitement du Signal
- Annales avec corrections (2022, 2023) pour s'entrainer
- MATLAB Signal Processing Toolbox documentation
- Livres : "Digital Signal Processing" de Proakis & Manolakis
Liens avec les autres cours :
- Signal - S5 : fondements theoriques
- Electronique Fonctions Analogiques - S6 : filtres actifs
- Chaines Electroniques d'Acquisition - S8 : application complete
- Embedded IA for IoT - S9 : pretraitement ML
Documents de Cours
Sujet Examen 2023
Enonce de l'examen de Filtrage Numerique 2023 avec exercices sur FIR/IIR, transformee en Z et conception de filtres.
Correction Examen 2023
Correction detaillee de l'examen avec les solutions completes et explications des methodes de conception.
Digital Filtering - Semester 6
Academic Year: 2022-2023
Semester: 6
Credits: 2.5 ECTS
Specialization: Signal Processing and Control Systems
PART A - General Course Overview
Overview
This course delves into digital signal processing with a focus on the design and implementation of digital filters. It covers the two main filter families: FIR (Finite Impulse Response) and IIR (Infinite Impulse Response), along with their respective design methods. The course combines mathematical theory (Z-transform, frequency response) and practice (MATLAB, implementation).
Learning objectives:
- Master the Z-transform and frequency-domain analysis
- Design FIR filters using the windowing method
- Design IIR filters using bilinear transformation and impulse invariance
- Analyze the stability and performance of digital filters
- Implement and test filters in MATLAB
Position in the curriculum
This course builds upon and complements:
- Signal Processing (S5): Fourier transform, Laplace transform, sampling
- Linear Systems Modeling (S5): transfer functions, stability
It prepares for applications in:
- Advanced Signal Processing: audio, biomedical, and communications applications
- Embedded AI for IoT (S9): signal preprocessing for machine learning
- Data processing projects: spectral analysis, adaptive filtering
PART B - Personal Experience and Learning Context
Organization and resources
The module was structured around three pillars:
1. Lectures:
- Review of sampling and the Z-transform
- FIR filters: properties, design methods
- IIR filters: transformation of analog filters
- Implementation structures and quantization effects
2. Tutorials:
- FIR filter design exercises using windowing
- Bilinear transformation for IIR filters
- Stability analysis (pole and zero placement)
- Frequency response calculations
3. MATLAB lab sessions:
- Using the fdatool (Filter Design and Analysis Tool)
- Design and testing of FIR and IIR filters
- Performance comparison (order, attenuation, phase)
- Application to real signals (audio, ECG)
Teaching resources:
- YouTube playlist with lectures and tutorials: Signal Processing
- 2022 and 2023 past exam papers with solutions
- MATLAB Signal Processing Toolbox documentation
Progression and methodology
Progressive approach:
The course followed a three-step approach:
- Theory: establish mathematical foundations (Z-transform, difference equations)
- Methods: apply systematic design techniques
- Practice: validate and optimize with MATLAB
Figure: Digital filtering principle - Noise reduction through filtering
Example of FIR low-pass filter design:
Specifications:
- Cutoff frequency: 1 kHz
- Sampling frequency: 8 kHz
- Stopband attenuation: > 40 dB
- Passband ripple: < 0.5 dB
Design steps:
- Choose the method (Hamming window as a compromise)
- Calculate the required order (based on the specification template)
- Generate coefficients with MATLAB: fir1(N, Wn, 'low')
- Verify the frequency response: freqz(b, a)
- Test on a real signal
Exams and assessments
Exam format:
Past papers show a recurring structure:
Exercise 1: FIR Filters (30-40%)
- Design by windowing
- Calculation of the minimum order
- Comparison of different windows
- Frequency response analysis
Exercise 2: IIR Filters (30-40%)
- Bilinear transformation or impulse invariance
- Calculation of the Z-domain transfer function
- Pole and zero placement
- Stability verification
Exercise 3: Implementation (20-30%)
- Direct form or cascade structure
- Quantization effects
- Bit-width optimization
- Difference equations
Common difficulties:
- Confusion between normalized frequency (0 to 1) and physical frequency (Hz)
- Errors in bilinear transformation (frequency pre-warping)
- Forgetting to verify stability (poles inside the unit circle)
- Misinterpretation of specifications (dB vs. linear)
MATLAB tools used
Key functions:
% FIR Design
b = fir1(N, Wn, 'type'); % Window method
b = firpm(N, F, A); % Parks-McClellan (optimal)
% IIR Design
[b,a] = butter(N, Wn, 'type'); % Butterworth
[b,a] = cheby1(N, Rp, Wn, 'type'); % Chebyshev Type I
[b,a] = cheby2(N, Rs, Wn, 'type'); % Chebyshev Type II
[b,a] = ellip(N, Rp, Rs, Wn, 'type'); % Elliptic
% Analysis
freqz(b, a, N); % Frequency response
zplane(b, a); % Pole-zero diagram
grpdelay(b, a); % Group delay
filter(b, a, x); % Filtering
PART C - Detailed Technical Aspects
1. Foundations: The Z-Transform
The Z-transform is the discrete equivalent of the Laplace transform.
Definition:
For a discrete signal x[n], the Z-transform is:
X(z) = sum of x[n] x z^(-n) for n from -infinity to +infinity
Important properties:
- Linearity: Z{a x x[n] + b x y[n]} = a x X(z) + b x Y(z)
- Time shift: Z{x[n-k]} = z^(-k) x X(z)
- Convolution: Z{x[n] * h[n]} = X(z) x H(z)
Region of Convergence (ROC):
The region of the complex plane where the transform converges. Critical for stability.
Relationship with the Fourier transform:
On the unit circle (z = e^(jw)), the Z-transform becomes the DTFT (Discrete-Time Fourier Transform).
2. FIR Filters (Finite Impulse Response)
Characteristics:
An FIR filter has a finite-duration impulse response:
y[n] = b0 x x[n] + b1 x x[n-1] + ... + bN x x[n-N]
Transfer function: H(z) = b0 + b1 x z^(-1) + ... + bN x z^(-N)
Advantages:
- Always stable (no poles, only zeros)
- Linear phase possible (important for audio, images)
- No feedback issues
- Simple implementation
Disadvantages:
- High order required for sharp selectivity
- Computation time proportional to order
- Constant but sometimes significant group delay
Windowing method:
Principle: start from the ideal (infinite) impulse response and truncate it with a window function.
| Window | Main lobe | Stopband attenuation | Ripple |
|---|---|---|---|
| Rectangular | Narrow | -21 dB | High (9%) |
| Hamming | Medium | -53 dB | Medium (0.2%) |
| Hanning | Medium | -44 dB | Medium |
| Blackman | Wide | -74 dB | Low |
| Kaiser | Adjustable | Configurable | Configurable |
Trade-off: main lobe width (transition band) vs. stopband attenuation.
Example: low-pass filter with Hamming window
% Specifications
Fs = 8000; % Sampling frequency (Hz)
Fc = 1000; % Cutoff frequency (Hz)
N = 50; % Filter order
% Normalized frequency (0 to 1, where 1 = Fs/2)
Wn = Fc / (Fs/2);
% Design
b = fir1(N, Wn, 'low', hamming(N+1));
% Visualization
freqz(b, 1, 1024, Fs);
title('FIR Low-pass Filter - Hamming');
Parks-McClellan method (optimal):
Remez exchange algorithm to obtain an equiripple response (equal ripple in passband and stopband).
Advantage: minimum order for a given specification template.
% Specifications
F = [0 0.2 0.3 1]; % Normalized frequencies
A = [1 1 0 0]; % Desired amplitudes
b = firpm(50, F, A); % Optimal design
3. IIR Filters (Infinite Impulse Response)
Characteristics:
An IIR filter uses feedback (recursion):
y[n] = b0 x x[n] + b1 x x[n-1] + ... - a1 x y[n-1] - a2 x y[n-2] - ...
Transfer function: H(z) = B(z) / A(z) = (b0 + b1 x z^(-1) + ...) / (1 + a1 x z^(-1) + a2 x z^(-2) + ...)
Advantages:
- Low order for high selectivity (efficiency)
- Correspond to classical analog filters
- Fewer computations than equivalent FIR
Disadvantages:
- Potentially unstable (poles outside unit circle)
- Non-linear phase (phase distortion)
- Sensitive to coefficient quantization
- Risk of limit cycles (parasitic oscillations)
Design by transformation of analog filters:
Start from a proven analog filter (Butterworth, Chebyshev, Elliptic) and transform it into a digital filter.
Analog approximations:
| Type | Passband | Stopband | Phase | Order |
|---|---|---|---|---|
| Butterworth | Maximally flat | Monotonic | Good | High |
| Chebyshev I | Ripples | Monotonic | Medium | Medium |
| Chebyshev II | Flat | Ripples | Medium | Medium |
| Elliptic | Ripples | Ripples | Poor | Low |
Bilinear transformation:
Most widely used method. Maps the imaginary axis of the s-plane (analog) to the unit circle of the z-plane (digital).
Transformation: s = (2/T) x (1 - z^(-1)) / (1 + z^(-1))
where T is the sampling period.
Frequency pre-warping:
The bilinear transformation warps frequencies according to:
Omega_analog = (2/T) x tan(omega_digital x T/2)
Therefore, specifications must be pre-warped before transformation:
% Digital specifications
Fs = 1000; % Hz
Fc = 100; % Hz
Wn = Fc / (Fs/2); % Normalized frequency
% Butterworth design, order 4
[b, a] = butter(4, Wn, 'low');
% Stability verification
disp(roots(a)); % All poles must have magnitude < 1
Impulse invariance:
Consists of sampling the analog impulse response.
Advantage: exact time-domain correspondence.
Disadvantage: spectral aliasing if the signal is wideband.
4. Stability of Digital Filters
Stability criterion:
A digital filter is stable if and only if all its poles are inside the unit circle in the z-plane.
Magnitude of each pole < 1
Pole-zero diagram:
Essential tool for visualizing and analyzing stability.
[b, a] = butter(4, 0.2, 'low');
zplane(b, a);
- Poles (x): roots of the denominator A(z)
- Zeros (o): roots of the numerator B(z)
- Unit circle: stability boundary
Interpretation:
- Pole close to the unit circle → strong resonance
- Zero on the unit circle → null at that frequency
- Complex conjugate poles → oscillations
5. Implementation Structures
Direct Form I:
Literal implementation of the difference equation.
- Advantage: easy to understand
- Disadvantage: sensitive to quantization errors
Direct Form II:
Rearrangement to minimize memory (delays).
- Advantage: less memory (N instead of 2N)
- Disadvantage: sensitive to intermediate overflow
Cascade form (biquads):
Decomposition into second-order cells (second-order sections).
H(z) = H1(z) x H2(z) x ... x Hk(z)
- Advantage: robust to quantization, controlled stability
- Usage: standard for IIR
Parallel form:
Partial fraction decomposition.
H(z) = H0 + H1(z) + H2(z) + ... + Hk(z)
- Advantage: parallelizable processing
- Disadvantage: more multiplications
6. Quantization Effects
Sources of error in fixed-point arithmetic:
1. Coefficient quantization:
- Coefficients b[k] and a[k] are rounded
- Impact: displacement of poles and zeros
- Risk: poles move outside the unit circle → instability
2. Computation quantization:
- Products and sums rounded at each step
- Error accumulation (quantization noise)
3. Overflow:
- Intermediate results exceed capacity
- Solution: scaling
Required number of bits:
Rule of thumb:
- FIR: 12-16 bits generally sufficient
- IIR: 16-24 bits recommended (more sensitive)
- Cascade form: better robustness than direct form
7. Frequency Response and Analysis
Magnitude and phase:
The frequency response H(e^(jw)) characterizes the filter:
- Magnitude |H(w)|: gain at each frequency
- Phase arg(H(w)): phase shift introduced
Linear phase:
Condition to avoid phase distortion: arg(H(w)) = -a x w + b
FIR filters can achieve linear phase if their coefficients are symmetric or antisymmetric.
Group delay:
Measure of delay as a function of frequency:
tg(w) = -d[arg(H(w))] / dw
For linear phase: constant group delay.
MATLAB analysis:
[H, W] = freqz(b, a, 1024);
% Magnitude in dB
subplot(2,1,1);
plot(W/pi, 20*log10(abs(H)));
ylabel('Magnitude (dB)');
% Phase
subplot(2,1,2);
plot(W/pi, angle(H));
ylabel('Phase (radians)');
xlabel('Normalized frequency (x pi rad/sample)');
PART D - Reflective Analysis and Perspectives
Skills acquired
Systematic filter design:
The course provided a rigorous methodology for going from specifications (frequencies, attenuations) to an implementable filter. Knowing how to choose between FIR and IIR based on constraints.
MATLAB proficiency:
The lab sessions developed fluency with the Signal Processing Toolbox, essential for modern signal processing. Ability to rapidly prototype solutions.
Frequency analysis:
Deep understanding of the time-frequency relationship, importance of stability, and impact of poles and zeros on the response.
Key takeaways
1. FIR vs IIR - The fundamental choice:
| Criterion | Choose FIR | Choose IIR |
|---|---|---|
| Linear phase required | Yes | No |
| Low order critical | No | Yes |
| Guaranteed stability | Yes | No (must verify) |
| Audio, images | Yes | IIR possible |
| Real-time constrained | No (high order) | Yes |
2. Stability first:
Always verify that poles are inside the unit circle. An unstable filter is unusable.
3. Normalized frequencies:
Pay attention to conversions: physical frequency (Hz) → normalized (0 to 1) → digital angular frequency (0 to pi).
4. Quantization:
In real implementations (DSP, FPGA), fixed-point effects can destroy performance. Always simulate with quantization.
Practical applications
Audio and music:
- Equalizers (multiple bandpass filters)
- Effects (reverb, chorus using IIR)
- Noise reduction (adaptive filtering)
Biomedical:
- ECG filtering: bandpass 0.5-40 Hz to eliminate 50 Hz mains interference
- EEG: extraction of brain rhythms (alpha, beta, theta)
- Cardiac anomaly detection
Telecommunications:
- Pulse-shaping filters (raised cosine)
- Channel equalization
- Anti-aliasing filters (before ADC) and reconstruction filters (after DAC)
Image processing:
- Blurring (2D low-pass)
- Edge detection (2D high-pass)
- Denoising (median filters, Wiener)
Links to projects and other courses
Personal projects:
Digital filtering skills were applied in several contexts:
- Vibration signal analysis for predictive maintenance
- Audio signal processing for speech recognition
- IoT data preprocessing (accelerometer sensors)
Complementarity with other courses:
- Signal Processing (S5): theoretical foundations (Fourier, Laplace, sampling)
- Embedded AI (S9): filtering as a preprocessing step for ML
- Acquisition Chains (S8): anti-aliasing and reconstruction filters
- Real-Time Systems (S8): implementation constraints and optimization
Limitations and future directions
Course limitations:
- Little on adaptive filters (LMS, RLS)
- No multirate processing (decimation, interpolation)
- Real-time aspects underdeveloped (latency, throughput)
- Hardware implementation (FPGA, DSP) not covered
Future directions:
- Adaptive filtering: applications in echo cancellation, equalization
- Filter banks: audio compression (MP3), multiresolution analysis
- Time-frequency processing: wavelet transforms
- Optimal filtering: Wiener, Kalman filters
- Antenna processing: beamforming, spatial filtering
Technological evolution
Current trends:
- Machine learning: replacing classical filters with neural networks for denoising
- Embedded filtering: hardware acceleration (GPU, FPGA, ASIC)
- Distributed filtering: edge computing processing for IoT
- Quantum filtering: perspectives with quantum computing
Modern tools:
- Python scipy.signal: alternative to MATLAB for prototyping
- TensorFlow/PyTorch: deep learning-based filtering
- CMSIS-DSP: optimized libraries for ARM Cortex-M
- High-Level Synthesis: FPGA design in C/C++
Conclusion
Digital filtering is a cornerstone of signal processing. Mastering FIR and IIR, understanding the order/performance trade-off, and knowing how to use design tools are essential skills for engineers in embedded systems, telecommunications, or data processing.
This course provided a solid theoretical foundation (Z-transform, stability) and practical experience (MATLAB, implementation). The ability to design a filter matching specifications, verify its stability, and implement it efficiently has been achieved.
Resources for further study:
- Course YouTube playlist: Signal Processing
- Past exam papers with solutions (2022, 2023) for practice
- MATLAB Signal Processing Toolbox documentation
- Books: "Digital Signal Processing" by Proakis & Manolakis
Links to other courses:
- Signal Processing - S5: theoretical foundations
- Analog Electronics - S6: active filters
- Electronic Acquisition Chains - S8: complete application
- Embedded AI for IoT - S9: ML preprocessing
Course Documents
2023 Exam Paper
2023 Digital Filtering exam paper with exercises on FIR/IIR, Z-transform, and filter design.
2023 Exam Solutions
Detailed exam solutions with complete answers and explanations of design methods.
Cours enseigne en 2022-2023 a l’INSA Toulouse, Departement Genie Electrique et Informatique.Course taught in 2022-2023 at INSA Toulouse, Department of Electrical and Computer Engineering.