# AW: efficient dc-removal filter

Duane Wise dwise at wholegrain-ds.com
Thu Apr 2 10:22:49 EST 1998

```Hello:

>	y[n] + e[n] = (1+p)/2*x[n] - (1+p)/2*x[n-1] + p*y[n-1] + e[n-1]
>
>and	y[n] = floor( y[n] + e[n] )
>
>y[n] and e[n] are, essentially, the signed MSW and unsigned LSW comprising
>the double word resulting in the full precision accumulation of the filter.
>the floor() function just truncates the LSW.  p is the 1st order pole and
>should be very close to one.  i think the correct formula for p is
>
>	p = 1/cos(w) - tan(w)
>
>where w is the normalized radian frequency of the -3 dB corner frequency.

The formula for p is correct.

>for fixed point arithmetic, it's important that the differentiator (the
>zero) precedes the pole (the leaky integrator) otherwize the leaky
>integrator will saturate.  the problem is, even though the differentiator
>kills all the DC in the input signal, the integrator produces it's own DC
>due to the limit-cycling due to rounding and there is no differentiator to
>kill that DC.  so, it appears to me, that the differentiator followed by
>the leaky integrator with noise shaping, is the only simple fixed-point
>solution.  i think if you use this trick, you can let the pole (p) get as
>close to DC as you want.

Robert has a good point here.  There are two other ways I know of to
eliminate limit cycles.

1) Dithering, just like noise shaping except that the LSW added in is
uniformly distributed unsigned noise calculated separately.  Is there much
of a difference between dithering and noise shaping?  Probably not, but it
makes for good debate.

2) Sign-magnitude truncation, or truncation towards zero.  Truncate
positive results as usual (floor function), but employ a ceiling function
for negative results.  This nonlinearly affects the result, however, and
more so as the result gets smaller.

Enjoy, Duane Wise (dwise at wholegrain-ds.com)

```