A moving average filter averages a number of input samples and produce a single output sample. This averaging action removes the high frequency components present in the signal. Moving average filters are normally used as low pass filters. In recursive filtering algorithm, previous output samples also are taken for averaging.

A moving average filter averages a number of input samples and produce a single output sample. This averaging action removes the high frequency components present in the signal. Moving average filters are normally used as low pass filters. In recursive filtering algorithm, previous output samples also are taken for averaging. This is the reason why it's impulse response extends to infinity.

How to use the sample program

The .zip file contains both source code and executable. To compile and run the source code you need to have Visual Basic 6.0 installed in your computer. To run the executable, you must download and install Visual Basic 6.0 runtime files. Run movavgfilt.exe and you will see the main window. In the main window , the top most part is the Function generator , which produces different waveforms to test the filter. We can interactively change the amplitude, frequency and shape of the generated signal.

To test the program we must first generate an appropriate waveform. Here we will generate a complex waveform which consists of two different frequencies. Leave everything in default settings and click "generate" button. Now you can see a 10 Hz signal in the graph next to the signal generator. Figure below shows the waveform.

Now change the Frequency to 100 Hz and click "generate" button again. The newly generated waveform is added to the existing waveform and resulting waveform looks like a 10Hz sin wave with 100 Hz noise. See the waveform below.

This waveform is best suitable for testing the filter since it contains two different frequencies. You can run the filter by clicking the "Filter" button. From the options available left to the "Filter" button , you can choose Recursive, non-recursive filtering or no filtering at all. The figure below shows the output of the filter.