Recursive Moving Average Filter
The moving average filter is a FIR filter of length N with all taps set equal to (1/N). It's known for lousy frequency separation, but excellent time response -- in that sense, it out-Bessels a Bessel filter. You can implement it with SigmaStudio's FIR block as described here:
https://ez.analog.com/message/21716#21716
The longer the filter, the more smoothing -- but the standard FIR filter algorithm uses lots of instructions for huge filters, because it has to multiply coefficients for every tap. This is a waste when all the coefficients are the same. As Chapter 15 of Steven W. Smith's book points out, you can make a moving average filter with a recursive technique that has a tap before and after a (N-1) size delay. Such a filter appears below as part of a test circuit with signal source and a Bessel filter for comparison:
Coefficients are pulled out to the single gain block at the input. The present sample adds to the output as it enters the delay, the delayed sample subtracts from the output as it exits. The adder with the feedback accumulates these additions and subtractions to form the output -- this does something that's trivial in C but is otherwise a pain in the GUI. Although a recursive technique is used, the filter remains a true FIR filter -- the length of its impulse response is set only by your delay.
My test input is a square wave with added noise. Filtered results appear as the upper trace in both photos -- First the moving average filter:
The Bessel filter:
The moving average filter allows more noise through, but it better preserves the square wave's shape -- it doesn't round the corners, and the up and down slopes are symmetrical (it's linear phase). Listening to the two waveforms with headphones shows a similar result -- more noise with the moving average filter, but the characteristic sound of a square wave comes through.
smoothing
bessel
filter
accumulator
fir
moving_average
recursive
Show More
Hi Bob,
That's great! Maybe I can convince the software team to make a new cell from that concept and add it to the "Envelopes" library.
Brett.
That would make my day to see that filter incorporated into SigmaStudio. Users would only need to input the FIR length and the compiler would do the rest. Great idea!
Bob
Please log in to reply.




