[chbot] EMA IIR cutoff calculation

Robin Gilks gb7ipd at gmail.com
Wed Jan 24 10:46:13 GMT 2024


I'm already using (and have been for years) IIR filters like this but I've
always used seat-of-the-pants trial and error to determine the ALPHA value.
I'd like to be a bit more precise.
BTW: I'm using a micro with hardware floating point !

On Wed, Jan 24, 2024 at 8:17 PM Charles Manning <cdhmanning at gmail.com>
wrote:

> 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.
>
> _______________________________________________
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20240124/2028b333/attachment.html>


More information about the Chchrobotics mailing list