I am working through the activities in the book "What Color is Your Parachute?" by Richard Nelson Bolles. Part of this effort is to write seven stories about a goal that I wanted to accomplish, and what I did to accomplish it. I decided to start with a recent story. It is titled:
Designing a Decimation Filter with MATLAB without the Filter Design Toolbox
About a year ago, I had a goal to create a better decimation filter for a particular product. This product had an over-sampling system, where eight electrical signals were sampled at a rate 8x higher than needed, and decimated to the desired target rate.
At the time, I understood the basics of FIR filter design, but I never actually designed or implemented an FIR filter. Being a lifetime-learner, and a having a “no fear” approach to software, I attempted to design the filter using only my basic knowledge of FIR filtering, a copy of “Understanding Digital Signal Processing” by Richard Lyon, occasional advice from a seasoned DSP pro, and an abundance of “stick-to-itiveness”.
In summary, I designed the filter as a two stage FIR decimation filter. The first stage reduced the sampling rate by a factor of 4x and the second stage reduced the sampling rate by a factor of 2x. A single FIR filter would have required 96 taps to properly band-limit the signal for decimation. A two-stage FIR filter reduced the required filter taps to only 66 taps total.
I created the filter by modeling the frequency response of the front-end analog filter with a Butterworth filter design in MATLAB. Then, I inverted the frequency response over the bandwidth of interest, and I equalized the frequency response to reduce the attenuation of the hardware filter over the target bandwidth.
I added the frequency response of the equalization to the frequency response of the first stage of the FIR filter, and I used the “fir2” function with a Chebyshev window to design the first stage of the FIR filter. I experimented with the number of coefficients until I had the desired frequency response for the first stage of the decimation filter.
Next, I used the same process to generate the coefficients for the second stage of the filter (i.e., determine the combined frequency response of hardware filter and the first stage analog filter, inverse this response over the bandwidth of interest, adjust the desired frequency response for the proper stop band, and use the “fir2” function to generate the filter coefficients).
Finally, I implemented the filter function in C and added the two stages of filtering to the product. During the source code implementation, I created a set of unit tests, using CUTEST, that verify the functionality of the two-stage decimation system.
The result is a decimation system that equalizes the target passband. Analysis showed that the new decimation system is much better that the old-boxcar approach. The filter, in combination with the analog front-end filter and the system gain, provides full gain over the target passband and –100 dB of attenuation at the Nyquist frequency.
A series of frequency response tests provided that the two-stage decimation filter reduced the aliasing significantly in both the real-world system testing and unit testing. It accomplished this without reducing the target bandwidth for the system.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment