DCBlocker Algorithms
DCBlocker Algorithms
DCBlocker Algorithms
DC Blocker Algorithms
T
he removal of a dc bias (a S(z) = , (2) of (3).
1–pz–1
constant-amplitude compo-
nent) from a signal is a com- where p is a real pole and 0 < p < 1. FIXED-POINT IMPLEMENTATION
mon requirement in signal Equation (2) describes a leaky integrator, To understand the effects of fixed-point
processing systems. Thus, a a nonideal integrator that leaks some arithmetic on the dc blocker algorithm in
good dc blocking algorithm is a desirable energy away rather than perfectly inte- (3), let’s consider the differentiator and
tool to have in one’s bag of signal pro- grating dc. The integrator’s response to a leaky integrator sections independently
cessing tricks. In this article we present dc input will not be an ever-increasing using the network in Figure 2(a). Assume
both a nonlinear phase fixed-point dc output, but rather an output that we are using 16-b input and output bina-
blocker (using a noise-shaping trick that increases for a time and then levels off. ry words as indicated in the figure.
eliminates a signal’s dc bias using fixed- The term “leaky” is carried over from The differentiator’s difference equa-
point arithmetic) and a general linear- analog design in which the capacitor tion is
phase dc blocker network that may prove used to implement an integrator was
useful in various DSP applications. imperfect due to the flow of leakage cur- w[n] = x[n] – x[n – 1]. (4)
rent. The cascaded differentiator/integra-
FIXED-POINT DC BLOCKER tor transfer function is given by Note that, at most, the computation in
Simple fixed-point implementations of a (4) will require one more bit than the
dc blocker algorithm have a vexing quan- 1 – z–1 input (17 b total) to avoid possible over-
H(z) = R(z)S(z) = . (3)
tization problem that can create more dc 1 – pz–1 flow, which happens when the input
bias than they block. In this section we
present a “leaky integrator” and a noise-
shaping trick called “fraction-saving” to
eliminate the quantization problem 0
when using fixed-point arithmetic.
Magnitude (dB)
−5
The simplest filter that blocks dc is p = 0 (Pure Differentiator)
the digital differentiator, whose transfer p = 0.7
−10
function is given by p = 0.8
p = 0.9
−15
R(z) = 1 – z–1 . (1)
−20
0 0.1 0.2 0.3 0.4 0.5
Having a z-plane zero at z = 1, the differ-
Freq, xFs
LINEAR-PHASE DC BLOCKER
f= 0 0 0 ... 0 0 u14 u13 u12 ... u02 u01 u00 Another approach to eliminate the dc
(c) bias of a signal is to compute the moving
average of a signal and subtract that
[FIG2] Fixed-point dc blocking filter: (a) simple structure, (b) optimized integrator average value from the signal as shown
structure, and (c) bit-wise representation of u, s, and f.
in Figure 3(a). The delay element in the
figure is a simple delay line, having a
changes sign and the magnitude of the cant dc offset error into the y[n] output, length equal to the averager’s group
difference is greater than 32,768. and the closer the pole is to the unit cir- delay, enabling us to time-synchronize
However, barring that case, we can cle the larger the potential dc error. the averager’s v [n] output with the x[n]
implement the differentiator without Like any quantizer, the quantiza- input in preparation for the subtraction
requiring extra precision in the interme- tion’s dc error can be shaped by placing operation.
diate computation and thus avoid the feedback around the quantizer. In order The most computationally efficient
associated requantization to 16 b at the to implement our noise-shaping trick, form of a D-point moving averager (MA)
output. Also note that the differentiator
is nonrecursive, so quantization effects,
if they do occur, are not circulated back x [n] y [n]
through the differentiator. Delay +
−
The leaky integrator has a difference
v [n]
equation of Moving Average
(a)
y[n] = p · y[n – 1] + w[n]. (5)
MA
Because the goal is to implement (5) on x [n] − y [n]
a fixed-point (integer) processor, its + + MA +
−
terms must each be represented as an z−D +1 z −1 1/D
integer and the operations must be per-
formed using integer arithmetic. If we
z −1
want the x[n] input and y[n] output to
be scaled identically, then we must quan-
(b)
tize (truncate) the 32-b product result in
(5) to 16 b. It is precisely this quantiza- [FIG3] Linear-phase dc blocker: (a) moving average subtraction method and (b) dual-MA
tion that introduces a potentially signifi- implementation.
is the network whose transfer function is finite-impulse response (FIR) filter samples, yields an improved passband
defined by designs using least-squares error mini- peak-peak ripple of only 0.02 dB as well
mization, or the Parks-McClellan as a reduced-width transition region
1 1–z–D
H MA (z) = · . (6) method, require more than 100 taps to relative to the dual-MA implementa-
D 1–z–1
approximate our D = 32 dc blocking fil- tion. The dc blocker in Figure 4(b) con-
The second ratio in (6) is merely a recur- ter’s performance. tains four 1/ D scaling operations
sive running sum comprising a D-length On a practical note, the MAs in which, of course, can be combined and
comb filter followed by a digital integra- Figure 3(b) contain integrators that can implemented as a single binary right
tor. If D is an integer power of two, the experience data overflow. (An integra- shift by 4log2 (D) bits.
1/D scaling in (6) can be performed using tor’s gain is infinite at dc!) Using two’s
a binary right shift by log2 (D) bits. complement fixed-point arithmetic CONCLUSIONS
However, if D is an integer power of avoids integrator overflow errors if we We presented a nonlinear-phase, but
two, then the MA’s group delay is not an ensure that the number of integrator computationally efficient, dc blocking fil-
integer number of samples, making the (accumulator) bits are at least ter that achieves ideal operation when
synchronization of the delayed x[n] and output data quantization is used. In addi-
v[n] difficult. To solve that problem we tion, we described an alternate dc block-
accumulator bits
use two cascaded D-point MAs as shown ing filter that, at the expense of larger
in Figure 3(b). Because the dual-MA has = number of bits in q [n] data memory, exhibits a linear-phase fre-
an integer group delay of D–1 samples, + log2 (D ), (7) quency response.
our trick is to tap off the first averager’s
delay line, eliminating the bottom-path where q [n] is the input sequence to AUTHORS
“Delay” element in Figure 3(a). an accumulator and k means as fol- Randy Yates ([email protected]) is a con-
The magnitude response of our dual- lows: if k is not an integer, round it up to sultant in audio, communications, and
MA dc blocker, for D = 32, is shown in the next larger integer. signal processing systems at Digital
Figure 4(a). In the figure we show the For a narrower transition region Signal Labs, Inc. He is currently pursu-
details of this dc blocker’s passband with width, in the vicinity of 0 Hz, than that ing an M.S. degree in electrical engineer-
its peak-peak ripple of 0.42 dB. The fre- shown in Figure 4(a), we can set D to a ing at North Carolina State University,
quency axis value of 0.5 corresponds to a larger integer power of two. However, Raleigh, North Carolina.
cyclic frequency of half the input signal’s this will not reduce the dc blocker’s Richard Lyons ([email protected]) is
Fs sample rate. This dc blocker has the passband ripple. a consulting systems engineer and lec-
desired infinite attenuation at 0 Hz. At the expense of three additional turer with Besser Associates in Mountain
What we’ve created then is a linear- delay lines, and four new addition oper- View, California. He is the author of
phase, multiplierless, dc blocking net- ations per output sample, we can Understanding Digital Signal Processing
work having a narrow transition region implement the dc blocker shown in 2/E (Prentice-Hall, 2004), and editor of,
near 0 Hz. It’s worth noting that stan- Figure 4(b). That quad-MA implemen- and contributor to, Streamlining Digital
dard tapped delay-line, linear-phase tation, having a group delay of 2 D–2 Signal Processing, A Tricks of the Trade
Guidebook (IEEE Press/Wiley, 2007).
0
REFERENCES
–0.42 dB [1] C. Dick and F. Harris, “FPGA signal processing
dB