# Designing a Chebyshev type 2 filter directly in the discrete-time domain?

8 views (last 30 days)
Christoph F. on 10 Nov 2017
Edited: Christoph F. on 14 Nov 2017
I am trying to design a Chebyshev type 2 filter in the discrete-time domain in order to have control over the placement of the filters zero. My attempt is almost successful, but I seem to be missing one last condition for the coefficients.
The following parameters are given:
Fs=250 % sampling frequency
Fnotch=7 % position of the zero
H(f=0Hz)=1 % Unity gain at DC
H(f=fs/2)=R % Max. stopband ripple at f=fs/2
B can be calculated directly from Fnotch and Fs:
B=poly([exp(2*pi*i*Fnotch/Fs) conj(exp(2*pi*i*Fnotch/Fs))])
A can be calculated from the two conditions for H(z):
f=0Hz -> z=1 (b0+b1+b2)/(1+a1+a2)=1 -> a1+a2=b0+b1+b2-1
and
f=fs/2Hz -> z=-1 (b0-b1+b2)/(1-a1+a2)=A -> -a1+a2=(1/A)*(b0-b1+b2)-1
This gives a nice linear equation system for a1 and a2 and ultimately the vector of filter coefficients A:
R=db2mag(-40);
A=[1 1; -1 1]\[sum(B)-1; (1/R)*(B(1)-B(2)+B(3))-1];
A=[1 A.']
freqz(B, A, 4096, Fs)
As you can see, the filter [B, A] fulfills all the conditions for notch position and gain at DC and fs/2, but it certainly doesn't look anything like a cheby2 filter in the frequency domain. And why? Because B isn't
B=poly([exp(2*pi*i*Fnotch/Fs) conj(exp(2*pi*i*Fnotch/Fs))])
but actually
vvv
B= G * poly([exp(2*pi*i*Fnotch/Fs) conj(exp(2*pi*i*Fnotch/Fs))])
^^^
There is a scale factor in B that requires an additional equation. Does anyone know what equation this is?
(If I use cheby2 to design a filter with a notch at Fnotch and insert the resulting B(1) as G into the above equation, the result for B and A will look much better.)
Christoph F. on 13 Nov 2017
I believe the equation I am looking for is related to the flatness of the amplitude response of the inverse Chebyshev filter in the passband.
The parameter G basically determines if the resulting filter is an inverse Chebyshev filter, an elliptic filter, or something else altogether.

Christoph F. on 14 Nov 2017
Edited: Christoph F. on 14 Nov 2017
The missing criterion is indeed related to the maximum flatness - the second derivative of the squared filter gain (d/(d omega))^2 G(omega)^2 with respect to frequency at omega=0 needs to be zero (the first derivative is always zero). G(omega)^2 = abs(H(exp(i*omega)))^2
This leads to the following design algorithm:
b=-2*cos(2*pi*Wnotch);
a=1+1/R;
c=1-1/R;
% It's magic!
G=(-4*sqrt((b^2-4)*c*(a+c))+8*a+4*b*c)/(4*a^2+a*(-b^2+4*b+4)*c+4*c^2);
A = [1 1; -1 1] \ [(G*(b+2)-1); ((1/R*G*(2-b))-1)];
A = [1; A].';
B = G*[1 b 1];
Inverse Chebyshev filter with a given stopband ripple R (linear, not dB) and given notch position, without any pesky analog prototyping/bilinear transform/whatnot.