DSPRelated.com
Forums

Low pass filters in the time domain?

Started by tomb18 April 20, 2015
Hi,
I have an IQ signal that I mix with a complex oscillator to bring signals
down to 0 hz.  I now need to do a lowpass filter on the signal to remove
all other signals before demodulating the signal.
Currently, I have this working by using a 5 pole butterworth filter with a
cut off frequency of 3000Hz. This works nice, and I can get the
coefficients from online resources.  However, what I really want is a
filter that one can adjust the cutoff frequency in real time and not one
that needs coefficients for every frequency. This if I want 3.0 kHz.
2.9kHz, etc down to 1.8 kHz I need 12 sets of coefficients.  I tried
something like this however, as one goes down in frequency the audio
output level decreases to the point you can hardly hear it anymore. Also
if I also need a filter down to 400Hz, or even 50Hz it does not make sense
to have all those filter coefficients.
So can anyone suggest a better way?  A better filter?
Thanks
---------------------------------------
Posted through http://www.DSPRelated.com
On Mon, 20 Apr 2015 14:40:28 -0500, "tomb18" <103312@DSPRelated>
wrote:

>Hi, >I have an IQ signal that I mix with a complex oscillator to bring signals >down to 0 hz. I now need to do a lowpass filter on the signal to remove >all other signals before demodulating the signal. >Currently, I have this working by using a 5 pole butterworth filter with a >cut off frequency of 3000Hz. This works nice, and I can get the >coefficients from online resources. However, what I really want is a >filter that one can adjust the cutoff frequency in real time and not one >that needs coefficients for every frequency. This if I want 3.0 kHz. >2.9kHz, etc down to 1.8 kHz I need 12 sets of coefficients. I tried >something like this however, as one goes down in frequency the audio >output level decreases to the point you can hardly hear it anymore.
Check the gain of each filter. DC gain is easily computed by just adding up all the coefficients. If the narrow filters have a smaller sum, you can multiply each coefficient by a constant to bring the gain back up.
> Also >if I also need a filter down to 400Hz, or even 50Hz it does not make sense >to have all those filter coefficients. >So can anyone suggest a better way? A better filter? >Thanks
In general the narrower the cutoff the longer the impulse response will be, so the longer a FIR filter will naturally become. If you need less complexity then perhaps look at IIR filters, or, perhaps, CIC filters. Both have their own tradeoffs. Neither make it trivial to adjust the cutoff frequency on the fly; that's a much harder problem. Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
"tomb18" <103312@DSPRelated> writes:

> Hi, > I have an IQ signal that I mix with a complex oscillator to bring signals > down to 0 hz. I now need to do a lowpass filter on the signal to remove > all other signals before demodulating the signal. > Currently, I have this working by using a 5 pole butterworth filter with a > cut off frequency of 3000Hz. This works nice, and I can get the > coefficients from online resources. However, what I really want is a > filter that one can adjust the cutoff frequency in real time and not one > that needs coefficients for every frequency. This if I want 3.0 kHz. > 2.9kHz, etc down to 1.8 kHz I need 12 sets of coefficients. I tried > something like this however, as one goes down in frequency the audio > output level decreases to the point you can hardly hear it anymore. Also > if I also need a filter down to 400Hz, or even 50Hz it does not make sense > to have all those filter coefficients. > So can anyone suggest a better way? A better filter?
You may get more useful responses if you back up a bit and state what your higher-level goal is. E.g, "I want to detect DTMF tones" or somesuch. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
On 20.4.15 23:23, Randy Yates wrote:
> "tomb18" <103312@DSPRelated> writes: > >> Hi, >> I have an IQ signal that I mix with a complex oscillator to bring signals >> down to 0 hz. I now need to do a lowpass filter on the signal to remove >> all other signals before demodulating the signal. >> Currently, I have this working by using a 5 pole butterworth filter with a >> cut off frequency of 3000Hz. This works nice, and I can get the >> coefficients from online resources. However, what I really want is a >> filter that one can adjust the cutoff frequency in real time and not one >> that needs coefficients for every frequency. This if I want 3.0 kHz. >> 2.9kHz, etc down to 1.8 kHz I need 12 sets of coefficients. I tried >> something like this however, as one goes down in frequency the audio >> output level decreases to the point you can hardly hear it anymore. Also >> if I also need a filter down to 400Hz, or even 50Hz it does not make sense >> to have all those filter coefficients. >> So can anyone suggest a better way? A better filter? > > You may get more useful responses if you back up a bit and state what > your higher-level goal is. E.g, "I want to detect DTMF tones" or > somesuch.
He's building a SSB receiver. There is an old Rohde & Schwartz patent with two conversions and two filters to create continuously variable bandwidth. The patent has gone old, and the construction has been in ham radios for some decades. -- -TV
On Mon, 20 Apr 2015 14:40:28 -0500, tomb18 wrote:

> Hi, > I have an IQ signal that I mix with a complex oscillator to bring > signals down to 0 hz. I now need to do a lowpass filter on the signal > to remove all other signals before demodulating the signal. > Currently, I have this working by using a 5 pole butterworth filter with > a cut off frequency of 3000Hz. This works nice, and I can get the > coefficients from online resources. However, what I really want is a > filter that one can adjust the cutoff frequency in real time and not one > that needs coefficients for every frequency. This if I want 3.0 kHz. > 2.9kHz, etc down to 1.8 kHz I need 12 sets of coefficients. I tried > something like this however, as one goes down in frequency the audio > output level decreases to the point you can hardly hear it anymore. Also > if I also need a filter down to 400Hz, or even 50Hz it does not make > sense to have all those filter coefficients. > So can anyone suggest a better way? A better filter?
Are you implementing your 5 pole Butterworth as an IIR filter? Why not calculate the coefficient values on the fly? As Eric pointed out, there's difficulties involved with changing cutoff frequencies on the fly (they'll probably sound like "THUMP!"), but if you ramp the cutoff frequency at a rate significantly slower (probably 5x, at a guess) than the filter's settling time you should be OK. If you can calculate the coefficients on the fly, and if you have a means of changing them fairly rapidly, then you're made in the shade. You are implementing your 5-pole IIR filter as two 2nd-order filters and one 1st-order one, right? -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
On 20.04.2015 22:40, tomb18 wrote:

>However, what I really want is a > filter that one can adjust the cutoff frequency in real time and not one > that needs coefficients for every frequency.
Perhaps you know that it's fairly easy to adjust the cutoff frequency of a 1-st order IIR filter. Now, what will you get if you put five identical 1-st order IIR filters in a row, one after another? You would get a 5-th order IIR filter, perhaps not very fitting your particular needs, but it would have the same decibels / decade after the cutoff as any other 5-th order IIR filter. Note that it's not unlike the way CIC filters are constructed (although in a CIC filter you have several boxcar FIR filters, rather than several IIR filters). And probably, in complete analogy to CIC filters you could also compensate for the unwanted filter attenuation in the passband by downsampling the signal and then using a simple compensation FIR filter. HTH, Evgeny.
On Tue, 21 Apr 2015 11:01:01 +0300, Evgeny Filatov
<e.v.filatov@ieee.org> wrote:

>On 20.04.2015 22:40, tomb18 wrote: > >>However, what I really want is a >> filter that one can adjust the cutoff frequency in real time and not one >> that needs coefficients for every frequency. > >Perhaps you know that it's fairly easy to adjust the cutoff frequency of >a 1-st order IIR filter. > >Now, what will you get if you put five identical 1-st order IIR filters >in a row, one after another? You would get a 5-th order IIR filter, >perhaps not very fitting your particular needs, but it would have the >same decibels / decade after the cutoff as any other 5-th order IIR filter. > >Note that it's not unlike the way CIC filters are constructed (although >in a CIC filter you have several boxcar FIR filters, rather than several >IIR filters). And probably, in complete analogy to CIC filters you could >also compensate for the unwanted filter attenuation in the passband by >downsampling the signal and then using a simple compensation FIR filter. > >HTH, > >Evgeny. >
I don't have much experience with IIR filters, but I do have a fair amount with analog filters. If you cascade N identical 1-pole analog filters you get a pile of mush, and I think that IIR filters surely must be the same. Although the numerical order of the filter may be technically N, the overall performance is abysmal... not even remotely close to a properly designed Nth order filter and certainly not an Nth order Butterworth. With analog filters the target polynomial is traditionally broken into 2-pole sections (plus one 1-pole section if N is odd). Each 2-pole section is easily designed and implemented, with its own time constant and gain. The sections are all cascaded together to get the overall output, but the important point is that the sections are not all the same... they are as determined by the polynomial (Bessell, Butterworth, Chebyshev, etc). So what you *can* do is design a proper N-th order filter and simply scale the time constants (not the gains) of each section to change the frequency. This works perfectly with (ideal) analog filters, but my recollection is that this isn't quite true with IIRs and you need to include a compensating prewarp. I'm sure there are many here who can point you in the right direction on that. Best regards, Bob Masta DAQARTA v7.60 Data AcQuisition And Real-Time Analysis www.daqarta.com Scope, Spectrum, Spectrogram, Sound Level Meter Frequency Counter, Pitch Track, Pitch-to-MIDI FREE Signal Generator, DaqMusiq generator Science with your sound card!
Look at digital state-variable filters. They have independent control of frequency and Q, and if you are "oversampled  enough" you can ignore the errors from running in discrete time. So you can then have a global frequency control variable applied to all stars-variable filters and will frequency-scale the entire filter. I would recommend that you be oversampled by a minimum factor of 4.

Another approach is to use filter sections based on allpass filters. Just Google "Sanjit Mitra", he is the master of this approach. 

Bob
On Mon, 20 Apr 2015 16:22:36 -0500, Tim Wescott
<seemywebsite@myfooter.really> wrote:

>Are you implementing your 5 pole Butterworth as an IIR filter? > >Why not calculate the coefficient values on the fly?
The easiest way is to run two filters in parallel and cross-mix between them. Have filter "A" handling the signal, compute the new coefficients on-the-fly, incorporate those new coefficients into filter "B", start passing the signal through filter "B" and allow the transient to settle-out, and then gradually transition from the output of filter "A" to that of filter "B".
>As Eric pointed out, there's difficulties involved with changing cutoff >frequencies on the fly (they'll probably sound like "THUMP!"), but if you >ramp the cutoff frequency at a rate significantly slower (probably 5x, at >a guess) than the filter's settling time you should be OK. If you can >calculate the coefficients on the fly, and if you have a means of changing >them fairly rapidly, then you're made in the shade. > >You are implementing your 5-pole IIR filter as two 2nd-order filters and >one 1st-order one, right?
The elegant way is to compute the coefficients on-the-fly, and then gradually transition the coefficients themselves from the "old" to the "new". But don't just ramp them all linearly; ramp them with due regard for what the coefficients represent. For example, let's assume that you have a 2nd-order s-domain filter denominator: s^2 + (w0/Q)s + (w0)^2 For this example, let's assume that you want to transition the filter cutoff from w0=5 to w0=1 in four steps. To make the numbers easier to work with, assume that Q=1. Initial denominator: s^2 + 5s + 25 Final denominator: s^2 + s + 1 Well, a linear ramp from "5" to "1" in four steps will be "5,4,3,2,1", and a linear ram from "25" to "1" in four steps will be "25,19,13,7,1". So you could gradually transition between filters having the following denominators: s^2 + 5s + 25 s^2 + 4s + 19 s^2 + 3s + 13 s^2 + 2s + 7 s^2 + 1s + 1 But look closely at those intermediate filters. For example, the filter "s^2 + 3s + 13" has w0=sqrt(13)=3.60555 and Q=1.20185. Well, "3.60555" is not halfway between "5" and "1", and "1.20185" is not "1". If, instead, you consider what the coefficients mean when performing the transition, you will find the following sequence of denominators to be appropriate: s^2 + 5s + 25 s^2 + 4s + 16 s^2 + 3s + 9 s^2 + 2s + 4 s^2 + 1s + 1 In this case, w0 follows a linear ramp and Q is always "1". Does it matter? In most cases, probably not. I only claimed that it was elegant. Greg
On 4/21/15 9:05 AM, Bob Masta wrote:
> > I don't have much experience with IIR filters, but I do have > a fair amount with analog filters. If you cascade N > identical 1-pole analog filters you get a pile of mush,
well, if N=4 and you loop some feedback around the pile (and label the knob with the word "regeneration"), you get what we, in the music synthesizer domain, call a "4-pole Moog filter". -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."