Sunday, February 7, 2016

The Exponential Digital Lowpass Filter

In the last lab note we looked at the boxcar filter structure. That was an example of an FIR filter. The exponential filter is an IIR filter.  If I need a little filtering I usually use this filter structure. In a simple implementation of this filter we calculate the filter output by taking the current sample, adding it to the previous output then dividing by 2. Mathematically y=(x+yz-1) ; where y is the current output, x is the current input, and yz-1is the previous output.  The z-1 term shifts back in time 1 sample period.  Since the output is a function of the previous output this is an Infinite Impulse Response filter, or IIR filter.

In a typical embedded system we work with a fixed point math.

For the above function the characteristic equation is H(z) = Y/X = 1/(2-z-1)= z/(2z-1); There is a zero at 0 and a single pole at z=1/2. This is within the unit circle, thus the filter is stable. To plot the frequency response we set z=ejωT. Then we normalize by setting T=1. We can use Wolfram Alpha to plot the equation H(ω) = 1/(2-e-jω) . Click this link to see plot.  I copied the plot here for convenience.
Exponential Lowpass Filter response.

Here the horizontal axis is in Hz This filter attenuates to 0.7 at a frequency of 0.14Hz (remember this equation is normalized to a sampling frequency of 1 Hz).

If this is too much filtering, or too little filtering you can try adjusting the weighting of the two terms in the exponential filter. For instance, what if you choose the weighting y = ¼ (3x + yz-2)?  Here I tried to use a power of 2 divisor to make the math dead nuts simple to implement on a fixed point processor. On an FPGA you would not even need to divide or shift, just pick off the right bits. The FPGA would need just two 'add' operations. Can you calculate the frequency domain function and plot it?

If you have any other common filter questions, leave a comment for future discussion.

No comments:

Post a Comment