mikael.stewart at gmail.com
Thu Oct 18 01:49:41 BST 2018
Yes you're right. I was absorbed thinking about quantization as I was
writing and missed that double division.
Also noted a typo: filtered_value was supposed to be written as filt_value
in my original response.
Another thing to add that might be useful is to initialize the filter in
some way, such as:
filt_value = raw_value;
filt_sum = 100 * filt_value;
Or instead of basing it on one raw sample, use some nominal expected value
to get you to your settled value faster.
On Thu, Oct 18, 2018 at 12:47 PM Volker Kuhlmann <list57 at top.geek.nz> wrote:
> > filt_sum = filt_sum - filt_sum / 100 + raw_value;
> > filt_value = filt_sum / 100;
> > The second line only needs to be evaluated when you actually need to use
> > the result.
> Why is that an evaluation improvement?
> It's the same as
> filt_value = filt_sum / 100;
> filt_sum = filt_sum - filt_value + raw_value;
> where you can read filt_value for the filter result any time. It has the
> same number of expression statements but adds one store to filt_value
> per step. That's very cheap compared with a division.
> Volker Kuhlmann
> http://volker.top.geek.nz/ Please do not CC list postings to me.
> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
> 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...
More information about the Chchrobotics