Moving average Digital Filter implementation using TI TMS320 DSP

In this article, Gaurav Singh from Embedded Engineering website shows you how to implement the simplest possible digital filter “moving average filter”.

———–

Though it is very easy to implement but still in many applications this is more than good enough. for example reducing random noise from signal. ofcourse when it is very simple it does have issues like , it does no have very sharp filter Response.

there not much need to be done to calculate output signal. you just need to decide how many point average you want to take for each output point. the more cutoff frequency will go less and less as you increase number of point to be take for average. A 5 point average will have pretty high cutoff frequency than a 11 point average. for a point a 5 point average is calculated with this simple formula, we take two samples from back and two from front and calculate average for current sample.

little issue come up when i < half of average lenght , because it will make few of the index for input “negative”, >as there are very few programming language that support negative index we need to a little adjustment the calculation. we will only take sample from ahead of the current position , this arrangement not going to just going to shift the signal a little ahead in time , other property will remain same.

Firmware. Fimrware is quite simple , i use ezdsp5502 board with on board TMS320VC5502 and TLV320AIC23B codec. TLV320AIC23B codec is used to sample input signal at 48Khz rate and same is used to play back filtered signal , due to limitation you can see the maximum amplitude is limited.

mcBSP is used to transfer sampled data between dsp and TLV320AIC23B, TLV320AIC23B works as I2S master and send data to DSP , DSP has mcBSP receive interrupt enabled , mcBSP isr receive data and put into a three part ring buffer.

Ring Buffer. Ring buffer is maintained as three 64 sample long array , one 64 sample long array for input anther for processing and last one for output. these buffer keep on cycle through different stages. firmware can handle negative array index. though you can easily getaway without this all source code is available on this github repo.