[chbot] EMA IIR cutoff calculation

Charles Manning cdhmanning at gmail.com
Wed Jan 24 07:15:31 GMT 2024


Have a play around on https://fiiir.com/. This has sections for both
FIR and IIR.

These are the simplest filters you can build, but I would recommend
using fixed point if you are running it on a low power micro. You can
avoid multiplies by doing things like

out = out + (in - out)/4;  // (which will turn into +, - and a shift).




On Wed, Jan 24, 2024 at 4:59 PM Robin Gilks <gb7ipd at gmail.com> wrote:
>
> Greetings all
>
> I'm after the simplest answer to the question: what is the cutoff frequency of an Exponential Moving Average Infinite Impulse Response filter.
> This code snippet is called at 8KHz with a sample from the ADC. I know there is a natural log of ALPHA somewhere in the equation but trying to find the simple solution on the 'net buries me in Bode plots and sumof equations. I specifically don't want a mathematical treatise on EMAs, just a simple formula I can plug into my code 😀
>
>
> #define ALPHA     0.3
> static float EMA_S;                     // Exponential Moving Average - Signal
>
>    EMA_S = (ALPHA*sample) + ((1-ALPHA)*EMA_S);
>
>
> Cheers
> --
> Robin Gilks
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
> https://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.



More information about the Chchrobotics mailing list