<div dir="ltr"><div></div><div>Yes you're right. I was absorbed thinking about quantization as I was writing and missed that double division.</div><div><br></div><div>Also noted a typo: filtered_value
was supposed to be written as filt_value in my original response.</div><div><br></div><div>Another thing to add that might be useful is to initialize the filter in some way, such as:</div><div>filt_value = raw_value;</div><div>filt_sum = 100 * filt_value;</div><div><br></div><div>Or instead of basing it on one raw sample, use some nominal expected value to get you to your settled value faster.</div><div><br></div><div>Mikael<br></div><div><br></div><div><br></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 18, 2018 at 12:47 PM Volker Kuhlmann <<a href="mailto:list57@top.geek.nz">list57@top.geek.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> filt_sum = filt_sum - filt_sum / 100 + raw_value;<br>
> filt_value = filt_sum / 100;<br>
> <br>
> The second line only needs to be evaluated when you actually need to use<br>
> the result.<br>
<br>
Why is that an evaluation improvement?<br>
It's the same as<br>
<br>
filt_value = filt_sum / 100;<br>
filt_sum = filt_sum - filt_value + raw_value;<br>
<br>
where you can read filt_value for the filter result any time. It has the<br>
same number of expression statements but adds one store to filt_value<br>
per step. That's very cheap compared with a division.<br>
<br>
Volker<br>
<br>
-- <br>
Volker Kuhlmann<br>
<a href="http://volker.top.geek.nz/" rel="noreferrer" target="_blank">http://volker.top.geek.nz/</a> Please do not CC list postings to me.<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></div>