<div dir="ltr">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. <div>BTW: I'm using a micro with hardware floating point !</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 24, 2024 at 8:17 PM Charles Manning <<a href="mailto:cdhmanning@gmail.com">cdhmanning@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Have a play around on <a href="https://fiiir.com/" rel="noreferrer" target="_blank">https://fiiir.com/</a>. This has sections for both<br>
FIR and IIR.<br>
<br>
These are the simplest filters you can build, but I would recommend<br>
using fixed point if you are running it on a low power micro. You can<br>
avoid multiplies by doing things like<br>
<br>
out = out + (in - out)/4; // (which will turn into +, - and a shift).<br>
<br>
<br>
<br>
<br>
On Wed, Jan 24, 2024 at 4:59 PM Robin Gilks <<a href="mailto:gb7ipd@gmail.com" target="_blank">gb7ipd@gmail.com</a>> wrote:<br>
><br>
> Greetings all<br>
><br>
> I'm after the simplest answer to the question: what is the cutoff frequency of an Exponential Moving Average Infinite Impulse Response filter.<br>
> 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 😀<br>
><br>
><br>
> #define ALPHA 0.3<br>
> static float EMA_S; // Exponential Moving Average - Signal<br>
><br>
> EMA_S = (ALPHA*sample) + ((1-ALPHA)*EMA_S);<br>
><br>
><br>
> Cheers<br>
> --<br>
> Robin Gilks<br>
><br>
> _______________________________________________<br>
> Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank">Chchrobotics@lists.ourshack.com</a><br>
> <a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
> Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
> Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>
> When replying, please edit your Subject line to reflect new subjects.<br>
<br>
_______________________________________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank">Chchrobotics@lists.ourshack.com</a><br>
<a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>
When replying, please edit your Subject line to reflect new subjects.</blockquote></div>