Software Filter Boosts Signal-Measurement Stability, Precision

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

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.

Sponsored Recommendations

Near- and Far-Field Measurements

April 16, 2024
In this comprehensive application note, we delve into the methods of measuring the transmission (or reception) pattern, a key determinant of antenna gain, using a vector network...

DigiKey Factory Tomorrow Season 3: Sustainable Manufacturing

April 16, 2024
Industry 4.0 is helping manufacturers develop and integrate technologies such as AI, edge computing and connectivity for the factories of tomorrow. Learn more at DigiKey today...

Connectivity – The Backbone of Sustainable Automation

April 16, 2024
Advanced interfaces for signals, data, and electrical power are essential. They help save resources and costs when networking production equipment.

Empowered by Cutting-Edge Automation Technology: The Sustainable Journey

April 16, 2024
Advanced automation is key to efficient production and is a powerful tool for optimizing infrastructure and processes in terms of sustainability.

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!