Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting from samplerate/cutoff frequency to pi-radians/sample in a discrete time sampled IIR filter system

I am working on doing some digital filter work using Python and Numpy/Scipy.

I'm using scipy.signal.iirdesign to generate my filter coefficents, but it requires the filter passband coefficents in a format I am not familiar with

wp, ws : float

  Passband and stopband edge frequencies, normalized from 0 to 1 (1 corresponds 
      to pi radians / sample). 
  For example:
  Lowpass: wp = 0.2, ws = 0.3
  Highpass: wp = 0.3, ws = 0.2

(from here)

I'm not familiar with digital filters (I'm coming from a hardware design background). In an analog context, I would determine the desired slope and the 3db down point, and calculate component values from that.

In this context, how do I take a known sample rate, a desired corner frequency, and a desired rolloff, and calculate the wp, ws values from that?

(This might be more appropriate for math.stackexchange. I'm not sure)

like image 867
Fake Name Avatar asked Feb 26 '23 09:02

Fake Name


1 Answers

If your sampling rate is fs, the Nyquist rate is fs/2. This represents the highest representable frequency you can have without aliasing. It is also equivalent to the normalized value of 1 referred to by the documentation. Therefore, if you are designing a low pass filter with a corner frequency of fc, you'd enter it as fc / (fs/2).

For example, you have fs=8000 so fs/2=4000. You want a low pass filter with a corner frequency of 3100 and a stop band frequency of 3300. The resulting values would be wp=fc/(fs/2)=3100/4000. The stopband frequency would be 3300/4000.

Make sense?

like image 124
sizzzzlerz Avatar answered Mar 22 '23 23:03

sizzzzlerz