[chbot] EMA IIR cutoff calculation

Charles Manning cdhmanning at gmail.com
Wed Jan 24 20:28:14 GMT 2024


Here's a relatively simple article on first order IIRs

https://dsp.stackexchange.com/questions/34969/cutoff-frequency-of-a-first-order-recursive-filter

On Wed, Jan 24, 2024 at 11:47 PM Robin Gilks <gb7ipd at gmail.com> wrote:
>
> 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.
>
> _______________________________________________
> 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