Forums

IIR Notch Filter Implementation

Started by m.nabaee August 16, 2007
Hi,

I want to implement a digital IIR notch filter on FPGA.
I used FDA tool HDL coder, but it seems not to work properly.
However, can you give me a vhdl code or example of it?

Thanks...


On Thu, 16 Aug 2007 09:05:55 -0500, m.nabaee wrote:

> Hi, > > I want to implement a digital IIR notch filter on FPGA. > I used FDA tool HDL coder, but it seems not to work properly. > However, can you give me a vhdl code or example of it? > > Thanks...
You have pointed up what I hate most about "wizards" and other software that purports to do my thinking for me -- by the time you've figured out how to choke production-quality designs out of it you could have learned how to do the design from first principals, and you always run the risk that it just won't work. At any rate: A quick web search didn't cough up any convenient formulae for IIR notch filters. This is not surprising because they're harder to write down that you'd think, and it's not the World's Most Common DSP App. Here's how to do it in bits: Search around the web for implementing 2nd-order direct-form IIR filters in VHDL. There will be something. Now all that you're missing is the transfer function. Here it is: z^2 - 2 cos (th) z + 1 H(z) = a ---------------------- z^2 - b z + d^2 where: th is the frequency of your notch in radians/sample, i.e. th = 2 * pi * f * Ts where f is your real-world notch frequency and Ts is your sampling rate, d is the z-domain pole equivalent to 1/2 your desired filter bandwidth, i.e. d = e^(-2 * pi * f_w/2 * Ts) where f_w is your real-world desired bandwidth, a = (1 + d^2) / 2 and b = (1 + d^2) * cos(th). If this z transform stuff leaves you cold, I have an article on my web site: http://www.wescottdesign.com/articles/zTransform/z-transforms.html. It was written to fit into a 5000 word limit for a magazine, so it's a bit terse (and they rejected before they saw it, to boot). It does show you what this z transform stuff means, and how to code up an IIR filter in C (it's up to you to translate this into VHDL, or search out a recipe). -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
My Problem is in the first step.
A code that works as a 2-nd order Direct Form section.
I need such code.
On Fri, 17 Aug 2007 06:46:31 -0500, m.nabaee wrote:

> My Problem is in the first step. > A code that works as a 2-nd order Direct Form section. > I need such code.
What's wrong with this? http://www.altavista.com/web/results?itag=ody&q=%2B%22Direct+form%22+%2BFPGA+%2BIIR&kgs=0&kls=0 -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
That's it.
I have surfed the internet very much, but I couldn't find anything.
I found a couple of codes that doesn't work properly.
I will appreciate you if you can give me any ready-to-use example.


On Fri, 17 Aug 2007 11:24:33 -0500, m.nabaee wrote:

> That's it. > I have surfed the internet very much, but I couldn't find anything. > I found a couple of codes that doesn't work properly. > I will appreciate you if you can give me any ready-to-use example.
I don't have any. For that you may want to try the FPGA newsgroup at any rate -- but each FPGA implementation has a different set of requirements for speed, precision and size. One person's ready-made example is another one's disaster. What's keeping you from understanding the bones of the algorithm and writing your own code? -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
On Aug 17, 12:24 pm, "m.nabaee" <mahdy.nab...@gmail.com> wrote:
> That's it. > I have surfed the internet very much, but I couldn't find anything. > I found a couple of codes that doesn't work properly.
if the cookbook notch doesn't work properly as listed http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt , i would be interested in knowing that. it is literally a "code that works as a 2- nd order Direct Form section." r b-j
Of course, the problem is not about the derivating of the coefficieents.
It is from the HDL code of mine.