Shop OBEX P1 Docs P2 Docs Learn Events
Digest Number 1143 — Parallax Forums

Digest Number 1143

ArchiverArchiver Posts: 46,084
edited 2002-03-25 18:15 in General Discussion
At 4:53 PM +0000 3/25/02, basicstamps@yahoogroups.com wrote:
> thisReading = (thisReading */ $00B3) + (lastReading */ $004D)
> lastReading = thisReading

The problem with this technique is that in some cases, the values
won't quite converge all the way because of truncation errors. This
is particularly the case with low values of the digital filter, which
you probably want to use to get things very smooth.

For example, consider a filter that uses 1/16 of the new value:

newReading = (newReading */ $0010) + (oldReading */ $00EF)

with new newReading of $0F and oldReading of $00.

newReading = ($0F */ $0010) + ($00 */ $00EF)
newReading = ($00) + ($00)

As you can see, it never converges to the new reading.

The (inelegant) solution I came up with when I ran into this is to
check if the new and old are different and if they are, but the
smoothed value didn't change, bump it one towards the new value.
--
===========================================================
Robert Woodhead, CEO, AnimEigo http://www.animeigo.com/
===========================================================
http://selfpromotion.com/ The Net's only URL registration
SHARESERVICE. A power tool for power webmasters.
Sign In or Register to comment.