1
$\begingroup$

The issue: I have a signal in the time domain sampled at 51.2KHz. I want to apply a highpass filter with a pass frequency of 20 Hz.

The problem: Using Matlab to do that, the design of the filter takes forever to design. Having made a bit of research on this, it seems that this happens because of the high ratio of $\frac{sampling frequency}{Fpass}$ .

This got me wondering, is there a rule of thumb regarding this quantity?

$\endgroup$
  • $\begingroup$ You may also look at IIR bandpass filters designed from analog prototyping using bilateral transformation. They have nonlinear phase however. $\endgroup$ – Fat32 Jun 29 '17 at 14:50
  • $\begingroup$ Consider using a simple DC notch filter- see the first part of my answer on this post dsp.stackexchange.com/questions/31028/… $\endgroup$ – Dan Boschen Jun 29 '17 at 17:02
2
$\begingroup$

In addition to @David's comments about theoretical results, there is another approach you can take. The idea is to filter with a low-pass filter, then downsample, then repeat N times. The LPFs do not need to be very long, and each filter in the sequence is less complex than the previous one, because it works at a slower sampling rate.

An especially interesting use case is when you use half-band filters, because their computational complexity is so low. These filters have cutoff frequency at $f_N/2$.

In your case, the first HB filter would have $f_c=25.6$ kHz, and would be followed by a decimator that reduces the sampling rate by half. Subsequent low-pass filters have cutoff frequencies at 12.8, 6.4, 3.2, 1.6 kHz, 800, 400, 200, 100, 50, 25 Hz. So you would have 11 filters in series, and maybe one last one to get rid of the final 5 Hz.

Even though you have a large sequence of filters/downsamplers, I think you'll find this much easier to design than a single, extremely high-order filter.

My favorite reference on this subject is

Bellanger, M., Daguet, J., and Lepagnol, G. 1974. "Interpolation, extrapolation, and reduction of computation speed in digital filters." IEEE Transactions on Acoustics, Speech, and Signal Processing 22 (4): 231-235. doi:10.1109/TASSP.1974.1162581.

$\endgroup$
  • $\begingroup$ Using a series of half-band filters would produce a really wide transition band in terms of the original sample rate. $\endgroup$ – hotpaw2 Jun 29 '17 at 20:24
  • $\begingroup$ @hotpaw2 In my experience, using this technique it is possible to obtain good filters that may meet the requirements of many applications. By choosing the order of the HB filters you can control the transition bandwidth, and you can always do a final (non-HB) low-pass filter at low sampling rate. Given that many filter design techniques fail for very large orders, and that there may be numerical stability issues even if they don't, I think the sequence of HB filters is worth keeping in one's bag of tricks. $\endgroup$ – MBaz Jun 29 '17 at 23:06
2
$\begingroup$

In the most general case, there isn't really a formula for how long the filter should be. There are papers which show the empirical relationships between the filter transition width, passband ripple, and stopband attenuation. You typically have - for a fixed sampling frequency:

  1. A smaller transition width (from the stopband to the passband), as a percentage of the sampling frequency, requires a longer filter. A 100 Hz transition width for fsamp=5kHz would require a smaller filter than a 100 Hz transition width with fsamp=15kHz - assuming other requirements are equal.
  2. Smaller ripples in the passband, requires a longer filter
  3. More attenuation in the stopband requires a longer filter

That said, for remez type designs there are a couple of published formulas that give you an estimated length of the filter. In Matlab you could use the remezord() function. These formulas work fairly well, but they do run into problems when the transition frequencies are near 0 Hz or fs/2.

There are some published papers that give equations for the length of filter using a Kaiser window for a windowed Sinc design - but you don't have as much control in the specification of the filter - if I recall correctly.

$\endgroup$
0
$\begingroup$

The length of data that has to be seen by a filter is roughly inversely proportional to a filter's transition width (other things being similar).

Imagine if you were to FFT a signal sampled at 50kHz to see a difference in that signals spectrum between 15 Hz and 20 Hz. You would need an FFT of length 10,000 or longer in order for those two frequencies to end up in separate FFT result bins. To see a nice clean 5 Hz wide transition band below that 20 Hz cut-off, you would need an even longer FFT, than maybe 20k samples.

A FIR filter kernel would need to have roughly the same order of length as that FFT to gather enough information from the signal to produce the same filter transition separation, low pass or high pass. That's probably an unrealistic length for a FIR filter, as the accumulated numerical noise might dominate the process. An IIR filter with a pole that close to the unit circle would also be near or past the limits of numerical stability.

If a much wider transition band meets your needs, you might try downsampling your signal by a few orders of magnitude, low pass filtering that result, upsampling the low pass result to the original sample rate, and subtracting that low frequency content from the original signal. Or, if not, using FFT/IFFT overlap-add/save fast convolution with very long FFTs, maybe on the order of 128k samples in length, etc.

$\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.