FIR Filters Without the Math

Jon Titus

August 2, 2013

3 Min Read
FIR Filters Without the Math

Previous columns have described how analog and switched-capacitors filters work and provided a real example of each. Now on to digital filters that process discrete-time digital values, rather than analog signals.

To start, consider a moving average of the Standard-and-Poor's 500 Index. The Wall Street Journal, for example, uses a 65-day moving average to plot a new point on its chart of value vs. time for each day. The moving average acts like a low-pass filter that smooths price extremes. Because each of the past 65 daily S&P 500 evaluations -- discrete-time samples -- carries equal weight, people call this rectangular, or "box-car," averaging. Each trading day, a new value moves into the "rectangle" to become the "today" value, and the oldest value gets discarded. The diagram shows the process as values flow through a buffer memory, and undergo multiplications and a summation.

You could add all the values and divide by 65 to get the average, or multiply each value by 1/65 and then add the 65 results. In the latter case, each sample in the moving average would have a coefficient of 0.01538. Finite-impulse-response filters work the same way, but they multiply discrete samples by different coefficients, calculated for a specific set of filter characteristics.

153521_422208.jpg

The name "finite impulse response" arises from how the filter's output responds to inputs. Say an FIR filter receives varying S&P 500 prices for many days and then the price settles at $50 and remains there. The output of the filter will become constant as soon as the last varying price no longer gets averaged. Thus, a FIR filter has a finite response to a set of data. For the S&P 500 "filter" described above, the filter output becomes $50 after the 65th day. Another type of digital filter, the infinite-impulse filter (IIR), includes feedback paths, so its outputs can change in an infinite number of ways, depending on the feedback values it saves after each set of calculations. An IIR filter has some advantages over its FIR sibling, but I'll leave that topic for another column.

People use software to implement FIR filters. The incoming values go into a buffer memory, or into registers. Those values get multiplied by coefficients, then added together, and output. Many microcontrollers include signal-processing elements called multiplier-accumulators that increase the speed of filter operations. Although you can use fixed-point math to handle FIR-filter calculations, a floating-point unit (FPU) provides better precision. Years ago I used 8-bit fixed-point math to create an FIR filter and got decent results. Many MCU manufacturers also offer FIR example programs you can use.

The next column will describe where the FIR-filter coefficients come from and how you use them to create a filter in software.

For more information:
Lyons, Richard G. "Understanding Digital Signal Processing," 2nd ed., Prentice-Hall, 2004. ISBN: 978-0-13-108989-1.
Castor-Perry, Kendall, "Analyze FIR Filters Using High-School Math."

Related posts:

Sign up for the Design News Daily newsletter.

You May Also Like