Académique Documents
Professionnel Documents
Culture Documents
Tp N°3 :
Réalisé par :
Haddad liza
Zitouni malika
But du TP :
Réalisation et implémentation des différentes structures de filtre.
Etude du cycle limite et de la quantification.
Implémentation des filtres numériques :
Définition :
Un filtre numérique peut être défini par une équation aux différences, c'est-à-
dire l'opération mathématique du filtre dans le domaine temporel (discret).
La forme générale du filtre d'ordre M est l'une des suivantes
Fonction de transfert :
Une fonction de transfert, dans le domaine fréquentiel (Transformée en Z), permet
également de définir un filtre numérique. Ainsi, la fonction de transfert générale
d'ordre N d'un filtre numérique est la suivante :
Ou autrement écrit :
Fonction de transfert en z :
In this form, there are two parts to this filter, the moving average
part and the recursive part (or the numerator and denominator
parts)
Cascade form
Parallel form
Une propriété importante des filtres RIF est que les coefficients b du
filtre sont égaux à la réponse impulsionnelle du filtre. D'autre part, la forme
temporelle du filtre est tout simplement la convolution du signal avec les
coefficients b (ou réponse impulsionnelle).
Les filtres de la seconde famille, les RII (Filtre à réponse impulsionnelle infinie),
en anglais IIR (infinite impulse response), possèdent une réponse
impulsionnelle qui ne s'annule jamais définitivement ou qui converge
éventuellement vers zéro à l'infini. Ce type de filtre est récursif, c'est-à-dire
que la sortie du filtre dépend à la fois du signal d'entrée et du signal de sortie, il
possède ainsi une boucle de contre-réaction (feedback). Les filtres IIR sont
principalement la version numérique des filtres analogiques
traditionnels : Butterworth, Tchebychev, Bessel, Elliptique.
Réalisation :
Les filtres numériques peuvent être réalisés à l'aide de trois éléments ou
opérations de base, soit l'élément gain, l'élément de sommation et le retard
unitaire ; ces éléments sont suffisants pour réaliser tous les filtres numériques
linéaires possibles.
Propriété :
Les remarques générales suivantes peuvent être portées sur les filtres RII :
Partie pratique :
Exo1 :
Programme :
b=[1 -3 11 -27 18]; a=[16 12 2 -4 -1]; %On introduit les valeurs des
coefficients a & b
[b0,B,A]=dir2cas(b,a) % On convertit depuis la forme directe à la forme
cascade
delta = impseq(0,0,7) % On génere les 8 échantillons
format long
hcas=casfiltr(b0,B,A,delta) %On génère la forme cascade du filtre
hdir=filter(b,a,delta) % On génere la forme direct du filtre
L’exécution :
hcas =
Columns 1 through 4
0.06250000000000 -0.23437500000000 0.85546875000000 -
2.28417968750000
Columns 5 through 8
2.67651367187500 -1.52264404296875 0.28984069824219
0.49931716918945
hdir =
Columns 1 through 4
0.06250000000000 -0.23437500000000 0.85546875000000 -
2.28417968750000
Columns 5 through 8
2.67651367187500 -1.52264404296875 0.28984069824219
0.49931716918945
Remarque : la réponse impulsionnelle délivré par la structure cascade et directe
est la même, résultat précis.
Exo 2 :
b=[1 -3 11 -27 18]; a=[16 12 2 -4 -1]; %On introduit les valeurs des
coefficients a & b
[C,B,A]=dir2par(b,a) % On convertit depuis la forme directe à la forme
parralele
format long; %15 chiffres sont affichés après la virgule décimale.
delta = impseq(0,0,7); % On génère la réponse impulsionelle
hpar=parfiltr(C,B,A,delta) %On génère la forme parallèle du filtre
hdir=filter(b,a,delta) %On génère la forme directe du filtre
L’exécution :
hpar =
Columns 1 through 4
0.06250000000000 -0.23437500000000 0.85546875000000 -
2.28417968750000
Columns 5 through 8
2.67651367187500 -1.52264404296875 0.28984069824219
0.49931716918945
hdir =
Columns 1 through 4
0.06250000000000 -0.23437500000000 0.85546875000000 -
2.28417968750000 Columns 5 through 8
2.67651367187500 -1.52264404296875 0.28984069824219
0.49931716918945
Remarque: on retrouve les mêmes résultats en directe et parallèle.
Exo3: The structure contains a cascade of two parallel sections. The first
parallel section contains 2 biquads, while the second one contains 3 biquads. We
will have to convert each parallel section into a direct form using the par2dir
function, giving us a cascade of 2 direct forms. The overall direct form can be
computed by convolving the corresponding numerator and denominator
polynomials. The overall cascade and parallel forms can now be derived from the
direct form.
Programme:
C0=0; B1=[2 4;3 1]; A1=[1 1 0.9; 1 0.4 -0.4]; %On introduit les valeurs des
coefficients
B2=[0.5 0.7;1.5 2.5;0.8 1]; A2=[1 -1 0.8;1 0.5 0.5;1 0 -0.5]; %On introduit
les valeurs des coefficients
[b1,a1]=par2dir(C0,B1,A1) % On convertit depuis la forme parallèle à la
forme directe
[b2,a2]=par2dir(C0,B2,A2) % On convertit depuis la forme parralèle à la
forme directe
b=conv(b1,b2) % Convolution du nominateur
a=conv(a1,a2) % Convolution du dénominateur
[b0,Bc,Ac]=dir2cas(b,a) % On convertit depuis la forme directe à la forme
cascade
[C0,Bp,Ap]=dir2par(b,a) % % On convertit depuis la forme directe à la forme
parallèle
L’éxécution
b1 =
5.0000 8.8000 4.5000 -0.7000
a1 =1.0000 1.4000 0.9000 -0.0400 -0.3600
b2 =2.8000 2.5500 -1.5600 2.0950 0.5700 -0.7750
a2 =1.0000 -0.5000 0.3000 0.1500 0.0000 0.0500 -0.2000
b=
Columns 1 through 7
14.0000 37.3900 27.2400 6.2620 12.4810 11.6605 -5.7215
Columns 8 through
9-3.8865 0.5425
a=
Columns 1 through 7
1.0000 0.9000 0.5000 0.0800 0.1400 0.3530 -0.2440
Columns 8 through
11-0.2890 -0.1820 -0.0100 0.0720
b0 =14.0000
Bc =1.0000 1.8836 1.13281.0000 -0.6915 0.67191.0000 2.0776
0.86661.0000 0 01.0000 -0.5990 0.0588
Ac =1.0000 1.0000 0.90001.0000 0.5000 0.50001.0000 -1.0000
0.80001.0000 1.5704 0.61051.0000 -1.1704 0.3276
C0=[]
Bp =-20.4201 -1.600024.1602 5.14482.4570 3.3774-0.8101 -
0.23828.6129 -4.0439
Ap =1.0000 1.0000 0.90001.0000 0.5000 0.50001.0000 -1.0000
0.80001.0000 1.5704 0.61051.0000 -1.1704 0.3276
Remarque: by using the MATLAB functions developed in this section, we can
probe and construct a wide variety of structures.
Exo4:
r=0.9; theta = (pi/180)*[-55:5:-35,35:5:55]’;
p=r*exp(j*theta); a = poly(p); b = 1;% Direct form: quantized
coefficients
N=15; [ahat,L,B] = Qcoeff(a,N);TITLE = sprintf(’%i-bit (1+%i+%i)
Precision’,N+1,L,B);% Comparison of Pole-Zero
Plotssubplot(1,2,1); [HZ,HP,Hl] =
zplane(1,a);set(HZ,’color’,’g’,’linewidth’,1);
set(HP,’color’,’g’,’linewidth’,1);set(Hl,’color’,’w’); axis([-
1.1,1.1,-1.1,1.1]);title(’Infinite
Precision’,’fontsize’,10,’fontweight’,’bold’);
The figure :
shows the pole-zero plots for filters with both infinite and 16-bit precision
coefficients. Clearly, with 16-bit word length, the resulting filter is completely
different from the original one and is unstable. To investigate finite word-length
effect on the cascade-form structure, we first converted the direct-form
coefficients into the cascade-form coefficients using thedir2casfunction,
quantized the resulting set of coefficients, and then converted back to the
direct-form for pole-zero plotting. We show results for two different word
lengths. In the first case, we used the same 16-bit word length. Since the cas-
cade coefficients have smaller integer parts that require only one integer bit,
the number of fractional bits is 14. In the second case we used 9 fractional bits
(same as those in the direct form) for a total word length of 11 bits.
subplot(1,2,2); [HZhat,HPhat,Hlhat] =
zplane(1,ahat);set(HZhat,’color’,’r’,’linewidth’,1);
set(HPhat,’color’,’r’,’linewidth’,1);set(Hlhat,’color’,’w’);
title(TITLE,’fontsize’,10,’fontweight’,’bold’);axis([-1.1,1.1,-
1.1,1.1]);
% Cascade form: quantized coefficients: Same N[b0,B0,A0] =
dir2cas(b,a); [BAhat1,L1,B1] = Qcoeff([B0,A0],N);TITLE1 =
sprintf(’%i-bit (1+%i+%i) Precision’,N+1,L1,B1);Bhat1 =
BAhat1(:,1:3); Ahat1 = BAhat1(:,4:6);[bhat1,ahat1] =
cas2dir(b0,Bhat1,Ahat1);subplot(1,2,1); [HZhat1,HPhat1,Hlhat1] =
zplane(bhat1,ahat1);set(HZhat1,’color’,’g’,’linewidth’,1);
set(HPhat1,’color’,’g’,’linewidth’,1);set(Hlhat1,’color’,’w’);
axis([-1.1,1.1,-
1.1,1.1]);title(TITLE1,’fontsize’,10,’fontweight’,’bold’);
The filter is a bandpass filter with 10 tightly clustered poles implemented using
the direct and the cascade forms. For the direct-form structure, we compute
the magnitude response for infinite precision as well as for 16-bit quantization.
For the cascade-form structure, we use 16-bit and 11-bit representations.
The top row shows plots for the direct form, and the bottom row shows those
for the cascade form. As expected, the magnitude plot of the direct form is
severely distorted for 16-bit representation, while those for the cascade form
are preserved even for 11-bit word length.
Exo6:
We conclude that:
In our previous MATLAB simulations, we did not worry about the quantization in
multiplication or addition operations because the emphasis was on either signal
quantization or on filter coefficient quantization. The important operation that
we have to consider is the arithmetic overflow characteristics. We assume that
there presented numbers are in fractional two’s-complement format. Then in
practice, two overflow characteristics are used: a two’s-complement overflow,
which is a modulo (periodic) function, and a saturation, which is a limiting
function.
Exo7:
Hs_1 = stem([-1,m],y,'filled');set(Hs_1,'markersize',3,'color',[0,1,0]);
set(gca,'ytick',[-1:0.25:1],'fontsize',6);
ylabel('Amplitude','fontsize',8);
title('\alpha = -0.5, Truncation','fontsize',10);
xlabel('Sample index n','fontsize',8);
The output signal in the left plot agrees with that in previous
example and has an asymptotic period of two samples. The
middle plot for α = 0.5 (lowpass filter) shows that the limit cycle
has a period of one sample with amplitude of 1/8. Finally, the
right plot shows that the limit cycles vanish for the truncation
operation. This behavior for the
Truncation operation is also exhibited for lowpass filters
Exo 8 :
yn1 = 0; yn2 = 0;
m = 0:20; y = [yn2,yn1,zeros(1,length(m))];
x = 0.375*impseq(m(1),m(1)-2,m(end));
for n = m+3
yn1 = y(n-1); yn2 = y(n-2);
y(n) = QFix(a1*yn1,3,'round','satur')+QFix(a2*yn2,3,'round','satur')+x(n);
end
subplot('position',[0.1,0.2,0.39,0.6]);
plot([-1,20],[0,0],'w'); axis([-1,20,-0.5,0.5]); hold on;
Hs_1 = stem([-2,-1,m],y,'filled');
set(Hs_1,'markersize',3,'color',[0,1,0]);
set(gca,'ytick',[-0.5:0.25:0.5],'fontsize',6);
ylabel('Amplitude','fontsize',8);
title('Rounding Operation','fontsize',10);
xlabel('Sample index n','fontsize',8);
% Truncation operation in multipliers
yn1 = 0; yn2 = 0;
m = 0:20; y = [yn2,yn1,zeros(1,length(m))];
x = 0.375*impseq(m(1),m(1)-2,m(end));
for n = m+3
yn1 = y(n-1); yn2 = y(n-2);
y(n) = QFix(a1*yn1,3,'trunc','satur')+QFix(a2*yn2,3,'trunc','satur')+x(n);
end
subplot('position',[0.59,0.2,0.39,0.6]);
plot([-1,20],[0,0],'w'); axis([-1,20,-0.5,0.5]); hold on;
Hs_1 = stem([-2,-1,m],y,'filled');
set(Hs_1,'markersize',3,'color',[0,1,0]);
set(gca,'ytick',[-0.5:0.25:0.5],'fontsize',6);
ylabel('Amplitude','fontsize',8);
title('Truncation Operation','fontsize',10);
xlabel('Sample index n','fontsize',8);
Remarque: The round-off limit cycles have a period of six samples and amplitude
of 0.25, Unlike in the case of 1st-order filters, the limit cycles for the 2nd-
order exist even when truncation is used in the quantizer.
Conclusion:
Une autre forme de non linéarité qu’on peut rencontrer dans les signaux et
systèmes numériques, est le dépassement, qui se produit lorsqu’une quantité x
cherche à atteindre une valeur en dehors de ses limites (-X, X) qui un autre
effet non linéaire.