1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 5.00 out of 5)
Loading ... Loading ...
Print Print

Digital Notch filter

by Krishna Sankar on July 14, 2013

In some designs, it may be required to have a digital filter which attenuates a single frequency component with the rest of the frequencies pass through. Filtering out of the power line frequency of 50/60Hz or filtering of spurious correlated frequency signals in a wireless communication receivers etc are some possible scenarios. Such filters are called notch filters and this post goes over the digital notch filter described in the paper  ”Design of Digital Notch Filters,”  by Hirano, K.; Nishimura, S.; Mitra, S.K., in Communications, IEEE Transactions on , vol.22, no.7, pp.964,970, Jul 1974

Filter Design

The transfer function of an analog notch filter is

 , where

is the notch frequency and

is the width of the notch.

Converting to a digital filter using bilinear transformation,

.

Let 

.

where.

Summarizing,

To find the frequency  where the response becomes zero

.

Re-arranging and representing in terms of ,

.

The value is,

.

To find the -3dB bandwidth frequency 

.

After some math**,

** Note : Did not figure out the math. :(

Re-arranging and representing in terms of ,

.

The value is,

.

Representing as an All-Pass structure

The transfer function  represented with and is,

.

This can be alternately represented as,

,

where

Re-arranging,

,

Replacing  and ,

Block diagram 

Multiple structures to implement the above equation is possible. One possible candidate having two delay elements and two multipliers is shown below.

 

digital_notch_filter_block_diagram Figure : Block diagram notch filter (Reference Figure 3(a) Hirano, K.; Nishimura, S.; Mitra, S.K., “Design of Digital Notch Filters,” Communications, IEEE Transactions on , vol.22, no.7, pp.964,970, Jul 1974)

Matab code

% Matlab code for plotting the frequency response of digital notch filter
% Implemented as all pass filter section
clear; close all
fs = 1e6;
fn = 200e3;
fb = 50e3;
omega0T = fn/(fs/2)*pi;
deltaT  = fb/(fs/2)*pi;
a2 = (1-tan(deltaT/2))./(1+tan(deltaT/2));
a1 = (1+a2).*cos(omega0T);
B = [1 -a1 a2];
A = [a2 -a1 1];
[H1 W1] = freqz(B,A,1024,'whole');
[H2 W2] = freqz(1,1,1024,'whole');
H3 = (H1+H2)/2;

h = figure(1);
subplot(2,1,1);
plot([-512:511]/1024*fs/1e6,20*log10(fftshift(abs(H3))),'b-','LineWidth',4);
grid on; ylabel('amplitude, dB'); 
title('notch filter, fs=1MHz, fn=200kHz, fb=50kHz');
axis([-0.5 0.5 -50 10]);
subplot(2,1,2);
plot([-512:511]/1024*fs/1e6,(fftshift(angle(H3)*180/pi)),'m-','LineWidth',4);
grid on; xlabel('freq, MHz'); ylabel('angle, deg'); 
title('phase response');
axis([-0.5 0.5 -180 180]);

 

digital_notch_filter_frequency_phase_response

Figure  : Notch filter – frequency and phase response

 

 

Reference

Hirano, K.; Nishimura, S.; Mitra, S.K., “Design of Digital Notch Filters,” Communications, IEEE Transactions on , vol.22, no.7, pp.964,970, Jul 1974
doi: 10.1109/TCOM.1974.1092311
URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=1092311&isnumber=23820

D id you like this article? Make sure that you do not miss a new article by subscribing to RSS feed OR subscribing to e-mail newsletter. Note: Subscribing via e-mail entitles you to download the free e-Book on BER of BPSK/QPSK/16QAM/16PSK in AWGN.

{ 3 comments… read them below or add one }

Dave Keenan August 12, 2014 at 7:07 am

Hi Krishna,
Your article was of great use to me, as you can read via the attached link. I can’t find anywhere else on the free web that describes Hirano, Nishimura and Mitra’s astoundingly efficient notch filter design, or any other 2 multiplier, 4 adder or better notch filter.

I then had need of the complementary band-pass filter. A colleague told me I could just subtract the output of the notch filter from the original signal, but that would be 5 adders. I figured there was probably a way to do the band-pass with only 2 multipliers and 4 adders too. After much algebra and redrawing of diagrams I figured out the following.

If you code the above notch filter in C as:

static float z1 = 0.0;
static float z2 = 0.0;

float g = x + z2;
float h = a1*z1 – a2*g;
float z0 = x + h;
float y = (g – h) / 2.0; // Only this is specific to notch

z2 = z1;
z1 = z0;

to obtain the complementary band-pass you only need to change that one line to

float y = (z0 – z2) / 2.0; // Only this is specific to bandpass

Regards,
– Dave

Reply

Chien Wang July 15, 2013 at 10:36 am

Hi Krishna,
I enjoyed reading your articles a lot, however, lately I could not see the math equations due to mimetex error, the actual error message is something like “Only dsplog.com may use mimetex…”. I looked up the mimeTeX site and found the following solution:

If you install mimeTeX on one server and try to use it from another, you may instead see messages like

In this case, compile mimetex.cgi with the -DNOREFCHECK switch, e.g.,
cc -DAA -DNOREFCHECK mimetex.c gifsave.c -lm -o mimetex.cgi
and read the -DREFLEVELS=n discussion under compile options.

Please try and update your local mimeTeX server with -DNOREFCHECK, if you intent to us see the math equations.
Thanks and best regards,
Chien

Reply

Krishna Sankar July 15, 2013 at 2:57 pm

@Chien: Oh… ! Thanks for letting know. I tried using multiple browsers (and computers) and was able to see the equations.
Can you please mail me the screenshot of the error – krishna < $AT$> dsplog.com
In anycase, will check the mimeTex compile options and get this resolved.

Reply

Leave a Comment

Previous post: