View Full Version : Averaging 16 bit values without using 32 bit math
sirvo
- 5th October 2007, 17:39
Hello everyone..
I am trying keep a running average of the last 400 samples of signal. This signal's range is 500~1200. Is Darrel's Taylor Running Average routine (thanks Darrel) going to work? Should I increase the range of my signal, for example, for 10000~24000? ( x 20)
Thanks in advance!
Regards..
Darrel Taylor
- 5th October 2007, 18:39
That averaging routine doesn't work so well with LARGE sample sizes.
Scaling the values up will help some, but it will still suffer on the low end.
A couple years ago, there was another guy that wanted to average 8,000 samples.
I wrote the attached program for him, and like normal, never heard from him again.
Usually that means it worked. :eek:
No guarantees, but you might give it a try...
<br>
BigWumpus
- 5th October 2007, 22:18
Maybe you can use 256 samples.
You only have to add the highbytes of the samples!
(a1+a2+...+a256)/256 is the same as: a1/256+a2/256+...+a256/256
The problem is rounding! I would add the MSB of the low-bytes and divide this sum by 2 and add it to the first result.
Just think a little about it !
($1270+$1280+$1290+...)/256 = $12+$12+$12+...
and: (0+1+1+...)/2=1.0
so you get: $36+1.0= 55 !!!
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.