Electronic Design

  
Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?


[Ideas For Design]
Software Filter Boosts Signal-Measurement Stability, Precision

Bob Dvorak  |   ED Online ID #2875  |   February 3, 2003


Small or embedded systems often require a delicate measurement in the presence of high noise or interference. Without fancy filtering hardware, high-speed processing, or digital signal processing, it can be difficult to extract a stable signal of useful precision and/or stability. This article presents a simple software filter with which inexpensive embedded control systems can dramatically improve the stability of precision measurements.

The following algorithm was originally developed to detect microampere changes in milliampere signals and has since been used in a variety of applications. Traditional measurement methods in simple systems involve multiple-sample averaging or continuous integration. The problem is that the scattering of data points may be too great to provide a repeatable answer, and certain types of interference (most particularly, switching-power-supply interference) will induce error in an integrated answer. Alternatively, true statistical analyses can overwhelm the resources of an embedded processor.

The algorithm assumes the ability to perform a number of sequential measurements (such as might be available from a successive-approximation analog-to-digital converter, or ADC) that would ordinarily be averaged to provide a final answer. A small amount of interleaved processing (while awaiting the next ADC result) and a small amount of post-processing provide an answer that's weighted toward most of the individual answers.

A memory array is allocated to retain each of the individual results for post-processing. The number of samples may be varied according to individual needs and resources. Following the last sample, the arithmetic mean of the samples is calculated. Each sample (array element) is compared to the mean. The direction (> or <) is accumulated, as well as the cumulative magnitude of the deviation in one direction (which, by definition of the mean, equals that of the other direction). The results are applied to the mean according to the following formula:

where A is the corrected answer, M is the arithmetic mean of the results (average), P is the number of samples greater than M, N is the number of samples less than M, TD is the total deviation from mean (absolute value and one direction only), and n is the number of samples.

For example, consider a simple system taking 10 samples and yielding results of 10, 10, 10, 10, 10, 20, 10, 10, 10, and 10. Ignoring the fact that a human will discard the obvious erroneous answer, process the following. The mean is 11. The total number of samples positive is 1, and the total number of samples negative is 9 (so P − N = −8). Total deviation in either direction from mean is 9 (1 times 9 samples low, or 9 times 1 sample high). The deviation factor is −72, which divided by n squared (100) provides a correction of −0.72, for a derived answer of 10.28.

The algorithm works well for random scattering, and reasonably well for spurious interference, such as in the previous example. Note that sinusoidal error will result in P − N of zero, or no deviation from average. An interesting homework assignment for the mathematician in the crowd is to calculate the rejection ratio for various types of interference at different values of n.

Go to www.elecdesign.com for an M68000 assembly-language subroutine sample implementation. It assumes a 12-bit ADC and 32-bit registers.

To download a listing, click Download the Code at the top of the page.


Reprints   Printer-Friendly  Email this Article  RSS    Font Size   What's This?


  • Automating Analog IP Process Migration
  • C Tools Accelerate HDV Development On Xilinx FPGAs
  • A New Design Inflection Point
  • Forecasting Industry Growth For 2009 And Beyond
  • EDA Retools To Exploit Multicore Architectures
  • Design And Verification Move Up In Abstraction
  • EDA Retools To Exploit Multicore Architectures
  • A New Design Inflection Point
    1) Transportation Guidelines For Lithium Batteries Get Updated
    (261 views today)
    2) Build A Smart Battery Charger Using A Single-Transistor Circuit
    (236 views today)
    3) The Field Of Energy Harvesting Begins To Ripen
    (112 views today)
    4) Easily Convert Decimal Numbers To Their Binary And BCD Formats
    (104 views today)
    5) 2008 BEST Electronic Design Winners
    (100 views today)
    ALL TOP 20



    Reader Comments

    This is simply great.

    scorpion -June 14, 2007

    Great Algorithm. I implemented a weight indicator with MSC1211 from TI.

    Viktor Bucher -October 31, 2003

    This is a marvelous filter. It yields results that are comparable to my previous best efforts, and is much, much faster.

    David Matthews -August 04, 2003

    POST YOUR COMMENTS HERE
    Name:

    Email:
    Your Comments:

    Enter the text from the image below


    Please refresh the page if you have trouble reading this text.

    Search Electronic Design
         
      
     
    Email Newsletter
    Sponsored By:
    Electronic Design UPDATE provides readers with late-breaking news, opinions from industry experts, and timely technology stories. It's a unique opportunity to get your product message in front of engineers, engineering managers, and corporate managers while they're reading about critical information online.

    Enter Email to Subscribe
      

    Electronic Design Europe Electronic Design China EEPN Power Electronics Auto Electronics Microwaves & RF
    Mobile Dev & Design Schematics Find Power Products Military Electronics EE Events Related Resources