Digital Filters

A collection of various digital filters I’ve designed as they were needed for other projects.



Narrowband matched-sine FIR filter

As part of my LF/VLF experiments, I wanted a narrowband 60 kHz filter for receiving the time broadcast by NIST on station WWVB. The bandwidth needed is minimal, as basic time information is only transmitted at 1 bps, so the narrower the filter, the better. I first considered a filter based on the Goertzel algorithm, but set it aside due to its instability and instead decided to use a matched filter.

Efficient filter implementation

What I want to share here is not the matched filter itself, as there’s nothing special about that, but rather how it will be implemented. Given my system parameters - 60 kHz filter with a 3 MHz sampling frequency - a straightforward FIR matched filter of only one period in length would require 50 complex-coefficient taps. Using real-valued coefficients, either the sine or cosine rather than ej2π, slightly distorts the filter response, but it remains acceptable. More importantly, because of symmetries in the coefficients, it is possible to reduce this filter to a 12-tap FIR filter with some additional delays and summations.


f=n=049anznan=ej2πn50

These two equations give the formula for the FIR filter using the z-transform. This could be directly and inefficiently implemented as a 50-tap delay line and 50 multipliers. Examining an, however, one can see that there are only 13 unique coefficients, corresponding to values of n for which the argument of the exponent is between 0 and π/2. All other coefficients are either mirrored or negated versions thereof. For instance, when an is defined as a function of a sine:


a0=0an=an25 n[25,49]an=a25n n[13,24]

We can therefore rewrite the filter more efficiently, as follows.


f=(1z25)n=124anzn=(1z25)(n=112anzn+z12n=112a13nzn)

The first (1z25) term is easy to implement as a delay line and a sum at the output of the filter, and could potentially be moved to after later decimation steps. The sums of an and a13n can be computed from the same set of multipliers by using the transposed form of a FIR filter, summing both to the left and to the right after the multipliers. The output from these two can then be summed, the appropriate one first being multiplied by z12.

12 multipliers, 24 two-term adders, and 61 delay elements to implement a full-speed 50-tap filter, as opposed to 50 multipliers, 49 delay elements and 1 fifty-term adder for the naïve implementation. The naïve implementation has less fan-out into the multipliers, but a significantly longer critical path through the final adder.

Narrowing the filter

A single-period matched sine filter will not be narrow enough for WWVB reception. As you can see in the figure below, the single period filter, green, has a 60 kHz bandwidth. Increasing the number of periods will narrow the filter and is best done with a second filter, either a FIR filter such as N1n=0z50n, not shown, or an IIR filter such as 1/(1+(11/N)z25), blue.

Filter characteristic
Comparison of FIR and IIR filters for 60 kHz

The IIR filter results in a sharper filter for a given N and it requires fewer delay elements. The (1-1/N) term can be implemented as a sum of bit shifts if N is a power of 2. Either filter should be placed after a decimator, 25x in this case, to reduce the number of delay elements needed.


Last updated on 2014-09-21, fixed typos in equations


Written with StackEdit using markdown.css, google-code-prettify and MathJax.