Averaging AtoD samples


Closed Thread
Results 1 to 40 of 40

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Plcguy View Post
    Mabe I'm missing part of your challenge.
    How many samples will you throw before deciding it's a real change?
    If you look at the filter I added you can set the # of samples to skip as well as the % above and % below to determine what level of input is out of range.

    I would prob work on the spurious signal issue. good data acquisition is critical if the program is to be robust. That routine I added is really for a failed sensor check, rather than a continuous filter.
    The challenge is that when detecting frequency using the internal PIC comparators......the resulkting count appears to be jittery. By that I mean for say 1Khz, you get 'counts' arriving like thus...

    5000, 4999, 5000,4999, 5001, 5000, 4999,5001,3479, 5000,4999,5001


    now for the life of me I can't get to the bottom of why the spurious count arrives! (which would be the preferred option), so I'm faced with getting rid of it in software. What Melanie's number sort routine does, is sort an array of samples into numerical order (which will put the spurious count at the beginning), and then averages only the middle of the array. It gets rid of the spurious count completely.

    If the frequency changes, then the middle of the array (after sorting) should reflect the count.

    So my challenge if you like, is to get rid of spurious counts (ie not 'average' with them at all) ...and also to do this as quickly as possible.

    As I say Melanie's routine works....but I'm always open to other methods to rid spurious readings from the equation.
    Last edited by HankMcSpank; - 15th October 2010 at 17:09.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Have you tried Darrel's routine with values set high enough?

    Ioannis

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    Have you tried Darrel's routine with values set high enough?

    Ioannis
    I tried Darrel's averaging when I wanted to smooth out rapidly changing AtoD values (the output of a peak detect - whose level is proprtional to ac signal amplitude...and moves about a lot) - it worked very well in that situation.

    But for this situation - I really don't want the spurious compartor counts to be handled at all - I want them rejected...so no, I haven't used it in this instance....unless I've missed the point, I don't think it's what I need here?

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    As long as the values don't hit the edges your are fine.

    Give it a chance.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    I think the Fast Average section might be modified so that instead of jumping to the spurious noise point, it will reject the sample entirely.

    That should only take commenting 1 line from the original code.
    DT

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    I think the Fast Average section might be modified so that instead of jumping to the spurious noise point, it will reject the sample entirely.

    That should only take commenting 1 line from the original code.
    I've broke the breadboard circuit up ....so can't test right yet. But this sounds cool.

    How does the averging code decide whether what's coming in is spurious...or in fact the beginning of a new stream of samples (eg a new frequency arriving, which will generate a different comparator count - with it's own spurious counts).

    I guess what I really need issome form of 'trigger' (or 'change' threshold) so that my program then knows that a new frequency is coming in (& is not just a spurious reading)...

    For example, red test below is spurious count, blue is new frequency arriving (therefore count changes and starts coming in at around that new level)

    5000,4999,5000,5001, 3956,5000,5001,5000,4999,5000,3789, 2570,2571,2569,2570,2571,18912569,2571....
    Last edited by HankMcSpank; - 20th October 2010 at 23:00.

  7. #7
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Hank, It seems to me you need to set some rules, or rather conditions. something like this:

    1) samples must be +- 10 of a target number to be included in the average
    2) numbers outside the +- 10 will need to have 2 more samples within the new samples range to be considered a good sample.

    That seems like it would weed out the rouge numbers. Now of course I have chosen random numbers. The 10 and 3. I don't really know what the numbers represent (I assume gutiar notes). Nor do I have a feel for how long a note will last. thats what drives the 10 number.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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. ADC Averaging
    By Sach_1979 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st September 2009, 06:53
  3. Atod Digital Filter
    By GeoJoe in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd April 2008, 17:04
  4. Microchip free samples in UK?
    By zoki008 in forum Off Topic
    Replies: 1
    Last Post: - 21st March 2006, 16:06
  5. Averaging & 16 maths
    By paul.mcallister in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd May 2005, 18:17

Members who have read this thread : 0

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