Averaging 16 bit values without using 32 bit math

# Thread: Averaging 16 bit values without using 32 bit math

1. ## Averaging 16 bit values without using 32 bit math

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)

Regards..

2. 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.

No guarantees, but you might give it a try...
<br>

3. 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 !!!

#### Members who have read this thread : 1

You do not have permission to view the list of names.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts