4
$\begingroup$

I am attempting to implement a basic bandpass filter but the center frequency of my filter seems to be irrelevant as I can change it all I want but it has no effect on the filter. where am I going wrong?

I have given my calculations here in the hope that someone will be able to point out where I'm making a mistake.

Filter specs:
supression of DC and Fs/2 (zeroes at +1 and -1)
center frequency at pi/4
bandwith of pi/16

2(1-R)=pi/2
1-R=pi/32
R=(pi/32)-1
R=-0.9018252296

 K*(z-1)*(z+1)
---------------
z-R*cos(pi/4)+R

     K*(z^2 -1)
-------------------
z^2-R^2*cos(pi/4)+R

all leading to a difference equation of

Y[n]=R^2*cos(pi/4)*Y[n-1]-R*Y[n-2]+K*(X[n]-X[n-2])
$\endgroup$
  • $\begingroup$ The denominator looks wrong - you need a complex conjugate pole pair. $\endgroup$ – Paul R Jun 19 '12 at 8:30
  • $\begingroup$ the intention is to implement this in c, maybe I should have said that $\endgroup$ – Gurba Jun 19 '12 at 8:42
  • $\begingroup$ I'll be sure to place a similar question in a more appropriate place next time $\endgroup$ – Gurba Jun 19 '12 at 9:24
3
$\begingroup$

Your denominator is wrong. It should be on this form

$$ (1-z_0z^{-1})(1-z_0^*z^{-1}) = 1-2R\cos(\phi)z^{-1}+R^2z^{-2} $$ where $z_0 = Re^{j\phi}$.

If your goal is to block DC and create an anti-aliasing filter in a simple way, I would recommend not to use complex poles. Instead use the procedure described in detail here: http://www.dsprelated.com/showmessage/172787/1.php.

It even provides a C implementation.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.