+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2007
    Location
    Brazil
    Posts
    108

    Default 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)

    Thanks in advance!

    Regards..
    Sylvio,

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    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>
    Attached Files Attached Files
    DT

  3. #3
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289

    Talking

    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 !!!
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

Similar Threads

  1. Darrel's latest 16 bit averaging routine?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 17th October 2009, 01:57
  2. Funny PULSIN values: what is going on???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th April 2008, 08:02
  3. 32 bit math
    By fnovau in forum General
    Replies: 4
    Last Post: - 12th February 2008, 23:55
  4. PIC18Fxx math 24 & 32 bit
    By ronsimpson in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd December 2006, 12:52
  5. 32 bit math
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 28th August 2006, 13:34

Members who have read this thread : 2

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