Home / Codes / Implementing an 8-point Moving Average Filter

Implementing an 8-point Moving Average Filter

If you read sensors using microcontrollers before, you have dealt with data that is always moving above or below a set point. This “noisy” data can be processed using a moving average filter.

The 8-point moving average filter is one of the many low-pass FIR filters. It can be imagined as a window of eight elements moving along the array, one element at a time.

8 point moving average filter

The algorithm is simple: the middle element of the window is to be changed into the the average of all elements in the window. In the image above, the average of all the elements is 20, thus, the middle element (26) is changed to 20. However, note that changing the middle element must be changed only after all the elements of the window have passed.

As the window moves at the end of the array, its size gets lesser and lesser. Thus, data at the end of the array are unfiltered.

Source Code in Assembly: Download

Full Application Note:

doc0940

Check Also

bubble sort algorithm

Implementing Bubble Sort in AVR/Arduino

This is a short note on implementing the Bubble Sort algorithm on the AVR and …

Leave a Reply

Your email address will not be published. Required fields are marked *