DSPRelated.com
Forums

group delay DC filter

Started by Dinne January 7, 2009
Dear all,

My task is to implement a very narrow high pass filter to remove a DC
offset of a signal. So the cut off frequency of the filter is very low. The
filter must be linear phase.

A first implementation was made using a double cascaded moving average
filter. The filter seems to do its job very well. Unfortunately the group
delay of the filter is too large.

I have read some articles on multi rate filtering. Although I the feeling
I could use this to find a filter with a shorter group delay most articles
point out that multi rate filtering is not used to lessen the group delay. 


Let's say I have a signal X at sample rate Fs. 

1. I split the signal in two new signals Xlowpass and Xhighpass by
applying a low and high pass filter with a cutoff of about Fs/4. 
2. Because Xlowpass does not contain any frequencies above Fs/4 I can
downsample the signal Xlowpass without aliasing in a resulting signal
Xdown. 
3. Now I can find a low pass filter to do the original DC filtering at
this lower rate on the signal Xdown. The DC filter will have to be less
narrow resulting in a lower group delay.
4. After the DC filtering I can upsample the signal Xdown and add the high
frequency part Xhighpass to get the final signal but now DC filtered. 

Maybe someone can point out why this will not work. An alternative idea to
lessen the group delay of the DC filter would also be greatly appreciated.

Regards,
Dinne



Dinne wrote:

> Dear all, > > My task is to implement a very narrow high pass filter to remove a DC > offset of a signal. So the cut off frequency of the filter is very low. The > filter must be linear phase. > > A first implementation was made using a double cascaded moving average > filter. The filter seems to do its job very well. Unfortunately the group > delay of the filter is too large.
Too, very, well, seems, good, bad, high, low... those words express your attitude but tell no information. Engineers use the numbers. The group delay in your filter can't be smaller then 1/cutoff frequency, regadless of the sample rate and the method of the implementation. This is a physical limit. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On Wed, 07 Jan 2009 08:56:29 -0600, Dinne wrote:

> Dear all, > > My task is to implement a very narrow high pass filter to remove a DC > offset of a signal. So the cut off frequency of the filter is very low. > The filter must be linear phase. > > A first implementation was made using a double cascaded moving average > filter. The filter seems to do its job very well. Unfortunately the > group delay of the filter is too large. > > I have read some articles on multi rate filtering. Although I the > feeling I could use this to find a filter with a shorter group delay > most articles point out that multi rate filtering is not used to lessen > the group delay. > > > Let's say I have a signal X at sample rate Fs. > > 1. I split the signal in two new signals Xlowpass and Xhighpass by > applying a low and high pass filter with a cutoff of about Fs/4. 2. > Because Xlowpass does not contain any frequencies above Fs/4 I can > downsample the signal Xlowpass without aliasing in a resulting signal > Xdown. > 3. Now I can find a low pass filter to do the original DC filtering at > this lower rate on the signal Xdown. The DC filter will have to be less > narrow resulting in a lower group delay. 4. After the DC filtering I can > upsample the signal Xdown and add the high frequency part Xhighpass to > get the final signal but now DC filtered. > > Maybe someone can point out why this will not work. An alternative idea > to lessen the group delay of the DC filter would also be greatly > appreciated. > > Regards, > Dinne
Combine "Narrow band" with "linear phase" and you get "big delay". Why? Because the delay of the filter is going to be inversely proportional to the width of the band -- and your delay is probably going to be on the order of one to three times the reciprocal of the frequency. So unless the "too big" phase delay threshold is longer than 1/bandwidth, you have to ditch the linear phase requirement. So: why do you think you need linear phase? Do you need _absolutely_ linear phase, or can you stand having some phase oddities close to the notch? Etc. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html
On Jan 7, 10:56&#4294967295;pm, "Dinne" <di...@bluemelon.org> wrote:
> Dear all, > > My task is to implement a very narrow high pass filter to remove a DC > offset of a signal. So the cut off frequency of the filter is very low. The > filter must be linear phase. > > A first implementation was made using a double cascaded moving average > filter. The filter seems to do its job very well. Unfortunately the group > delay of the filter is too large. > > I have read some articles on multi rate filtering. Although I the feeling > I could use this to find a filter with a shorter group delay most articles > point out that multi rate filtering is not used to lessen the group delay. > > Let's say I have a signal X at sample rate Fs. > > 1. I split the signal in two new signals Xlowpass and Xhighpass by > applying a low and high pass filter with a cutoff of about Fs/4. > 2. Because Xlowpass does not contain any frequencies above Fs/4 I can > downsample the signal Xlowpass without aliasing in a resulting signal > Xdown. > 3. Now I can find a low pass filter to do the original DC filtering at > this lower rate on the signal Xdown. The DC filter will have to be less > narrow resulting in a lower group delay. > 4. After the DC filtering I can upsample the signal Xdown and add the high > frequency part Xhighpass to get the final signal but now DC filtered. > > Maybe someone can point out why this will not work. An alternative idea to > lessen the group delay of the DC filter would also be greatly appreciated. > > Regards, > Dinne
How many DC removal questions does that make this week? :-) You are almost certainly making the problem too hard by looking for strict compliance with the idea of linear phase, instead of being pragmatic. Estimate the DC, which you can do with a single noise shaped pole. You can make the bandwidth incredibly narrow, provided you can tolerate the long settling time. Once you have a steady DC estimate, you can just subtract it from the signal. Is it linear phase? No, but you can get it so damned close it won't matter in most applications. You can easily make the estimator so narrow band that is has almost no effect of any kind at all within the band of interest. Regards, Steve

steveu@coppice.org wrote:


> How many DC removal questions does that make this week? :-) You are > almost certainly making the problem too hard by looking for strict > compliance with the idea of linear phase, instead of being pragmatic.
But everybody knows that the nonlinear phase produces the artifacts, and that the IIR filters are unstable :) VLV
On 7 Jan., 17:24, ste...@coppice.org wrote:
> On Jan 7, 10:56&#4294967295;pm, "Dinne" <di...@bluemelon.org> wrote: > > > > > > > Dear all, > > > My task is to implement a very narrow high pass filter to remove a DC > > offset of a signal. So the cut off frequency of the filter is very low. The > > filter must be linear phase. > > > A first implementation was made using a double cascaded moving average > > filter. The filter seems to do its job very well. Unfortunately the group > > delay of the filter is too large. > > > I have read some articles on multi rate filtering. Although I the feeling > > I could use this to find a filter with a shorter group delay most articles > > point out that multi rate filtering is not used to lessen the group delay. > > > Let's say I have a signal X at sample rate Fs. > > > 1. I split the signal in two new signals Xlowpass and Xhighpass by > > applying a low and high pass filter with a cutoff of about Fs/4. > > 2. Because Xlowpass does not contain any frequencies above Fs/4 I can > > downsample the signal Xlowpass without aliasing in a resulting signal > > Xdown. > > 3. Now I can find a low pass filter to do the original DC filtering at > > this lower rate on the signal Xdown. The DC filter will have to be less > > narrow resulting in a lower group delay. > > 4. After the DC filtering I can upsample the signal Xdown and add the high > > frequency part Xhighpass to get the final signal but now DC filtered. > > > Maybe someone can point out why this will not work. An alternative idea to > > lessen the group delay of the DC filter would also be greatly appreciated. > > > Regards, > > Dinne > > How many DC removal questions does that make this week? :-) &#4294967295;You are > almost certainly making the problem too hard by looking for strict > compliance with the idea of linear phase, instead of being pragmatic. > > Estimate the DC, which you can do with a single noise shaped pole. You > can make the bandwidth incredibly narrow, provided you can tolerate > the long settling time. Once you have a steady DC estimate, you can > just subtract it from the signal. Is it linear phase? No, but you can > get it so damned close it won't matter in most applications.
It's a trick for DC removal that can actually be easily tuned (almost) continually from perfect linear-phase response to minimum-phase response. Imagine a linear-phase DC estimation filter (a narrowband lowpass), for example given by the impulse response h_1 = 1/N [1 1 .... 1] (N ones). If N is odd, you can subtract the ouptut from the appropriately delayed input to make a linear-phase DC blocking filter. This gives h_2 = 1/N [-1 -1 ... -1 (N-1)/N -1 ... -1] (N taps). ^ | middle tap By moving the middle tap value forwards in the impulse response, the input signal gets delayed less relative to the output of the linear- phase lowpass DC estimation filter. However, because the symmetry is broken, the resulting DC blocking filter won't be linear-phase (even though the DC estimation filter is linear phase). By moving the middle tap value all the way to the beginning, we get a minimum-phase DC blocking FIR filter: h_3 = 1/N [(N-1)/N -1 -1 ... -1] (N taps). This trick can be done with any other linear-phase DC estimation filter (lowpass) to get better frequency response. Using the boxcar filter results in quite a rippley frequency response (but it is very efficient to compute for arbitrary N, one just needs the memory). +------+ - /---\ x -----+------>| h_1 |----------->| + |------> y | +------+ \---/ | | | +------+ | +------>| z^-k |---------------+ +------+ y = h_3 * x Adjusting the delay "k" from (N-1)/N to 0 to crossfade from linear- to minimum-phase DC blocking filter. Regards, Andor
>On 7 Jan., 17:24, ste...@coppice.org wrote: >> On Jan 7, 10:56=A0pm, "Dinne" <di...@bluemelon.org> wrote: >> >> >> >> >> >> > Dear all, >> >> > My task is to implement a very narrow high pass filter to remove a
DC
>> > offset of a signal. So the cut off frequency of the filter is very
low.=
> The >> > filter must be linear phase. >> >> > A first implementation was made using a double cascaded moving
average
>> > filter. The filter seems to do its job very well. Unfortunately the
gro=
>up >> > delay of the filter is too large. >> >> > I have read some articles on multi rate filtering. Although I the
feeli=
>ng >> > I could use this to find a filter with a shorter group delay most
artic=
>les >> > point out that multi rate filtering is not used to lessen the group
del=
>ay. >> >> > Let's say I have a signal X at sample rate Fs. >> >> > 1. I split the signal in two new signals Xlowpass and Xhighpass by >> > applying a low and high pass filter with a cutoff of about Fs/4. >> > 2. Because Xlowpass does not contain any frequencies above Fs/4 I
can
>> > downsample the signal Xlowpass without aliasing in a resulting
signal
>> > Xdown. >> > 3. Now I can find a low pass filter to do the original DC filtering
at
>> > this lower rate on the signal Xdown. The DC filter will have to be
less
>> > narrow resulting in a lower group delay. >> > 4. After the DC filtering I can upsample the signal Xdown and add the
h=
>igh >> > frequency part Xhighpass to get the final signal but now DC
filtered.
>> >> > Maybe someone can point out why this will not work. An alternative
idea=
> to >> > lessen the group delay of the DC filter would also be greatly
appreciat=
>ed. >> >> > Regards, >> > Dinne >> >> How many DC removal questions does that make this week? :-) =A0You are >> almost certainly making the problem too hard by looking for strict >> compliance with the idea of linear phase, instead of being pragmatic. >> >> Estimate the DC, which you can do with a single noise shaped pole. You >> can make the bandwidth incredibly narrow, provided you can tolerate >> the long settling time. Once you have a steady DC estimate, you can >> just subtract it from the signal. Is it linear phase? No, but you can >> get it so damned close it won't matter in most applications. > >It's a trick for DC removal that can actually be easily tuned (almost) >continually from perfect linear-phase response to minimum-phase >response. Imagine a linear-phase DC estimation filter (a narrowband >lowpass), for example given by the impulse response > >h_1 =3D 1/N [1 1 .... 1] (N ones). > >If N is odd, you can subtract the ouptut from the appropriately >delayed input to make a linear-phase DC blocking filter. This gives > >h_2 =3D 1/N [-1 -1 ... -1 (N-1)/N -1 ... -1] (N taps). > ^ > | > middle tap > >By moving the middle tap value forwards in the impulse response, the >input signal gets delayed less relative to the output of the linear- >phase lowpass DC estimation filter. However, because the symmetry is >broken, the resulting DC blocking filter won't be linear-phase (even >though the DC estimation filter is linear phase). By moving the middle >tap value all the way to the beginning, we get a minimum-phase DC >blocking FIR filter: > >h_3 =3D 1/N [(N-1)/N -1 -1 ... -1] (N taps). > >This trick can be done with any other linear-phase DC estimation >filter (lowpass) to get better frequency response. Using the boxcar >filter results in quite a rippley frequency response (but it is very >efficient to compute for arbitrary N, one just needs the memory). > > +------+ - /---\ >x -----+------>| h_1 |----------->| + |------> y > | +------+ \---/ > | | > | +------+ | > +------>| z^-k |---------------+ > +------+ > >y =3D h_3 * x > >Adjusting the delay "k" from (N-1)/N to 0 to crossfade from linear- to >minimum-phase DC blocking filter. > >Regards, >Andor >
Dear all, Thank you all for your extensive answers. Apparently it is possible to get a much lower group delay if I relax the linear phase constraint. I will check what consequences this will have on the output of the system. Regards, Dinne
On Jan 8, 3:56&#4294967295;am, "Dinne" <di...@bluemelon.org> wrote:
> Dear all, > > My task is to implement a very narrow high pass filter to remove a DC > offset of a signal. So the cut off frequency of the filter is very low. The > filter must be linear phase. > > A first implementation was made using a double cascaded moving average > filter. The filter seems to do its job very well. Unfortunately the group > delay of the filter is too large. > > I have read some articles on multi rate filtering. Although I the feeling > I could use this to find a filter with a shorter group delay most articles > point out that multi rate filtering is not used to lessen the group delay. > > Let's say I have a signal X at sample rate Fs. > > 1. I split the signal in two new signals Xlowpass and Xhighpass by > applying a low and high pass filter with a cutoff of about Fs/4. > 2. Because Xlowpass does not contain any frequencies above Fs/4 I can > downsample the signal Xlowpass without aliasing in a resulting signal > Xdown. > 3. Now I can find a low pass filter to do the original DC filtering at > this lower rate on the signal Xdown. The DC filter will have to be less > narrow resulting in a lower group delay. > 4. After the DC filtering I can upsample the signal Xdown and add the high > frequency part Xhighpass to get the final signal but now DC filtered. > > Maybe someone can point out why this will not work. An alternative idea to > lessen the group delay of the DC filter would also be greatly appreciated. > > Regards, > Dinne
Try a large capacitor in series and a resistor to ground. H.