Columnists

The power of moving-average digital filters

By Bonnie Baker -- EDN, 12/16/2005

Many times, ADC users employ averaging algorithms with their controller or processor on the output of several samples from the converter. You can "smooth" a converted signal using this technique (Figure 1), as well as improve the effective resolution of the system by reducing system noise.

You implement the smoothing effect on your converted data by acquiring multiple signals at a constant sample rate, averaging a predetermined group or number of samples, and then continuing this process with several groups over time. As Figure 1 shows, the aggregate of the averaged results produces a smoothed signal. This averaging technique essentially provides a lowpass filter on the converter output data. You can control the effectiveness of your filtering by selecting the appropriate number of samples for the averaged groups. If you use more samples in each group, you will see a higher degree of smoothing. This averaging process eliminates spikes in the raw data as well as reduces the bandwidth of the final signal.

Another by-product of this averaging technique is that the conversion resolution or precision of the data increases. Ideally, an average of four samples (41) of a dc signal will increase the converter's effective resolution by one—a 6-dB increase in the SNR (signal-to-noise ratio). An average of 16 samples (42) will increase your resolution by two and your SNR by 12 dB. Theoretically, a group size of 4N will increase the number of effective bits from your conversion by N, but there are real-world limitations to this theory.

It is possible to increase the number of effective bits with your ADC, as long as you maintain realistic goals and consider nonideal conditions. For instance, improving a 12-bit converted result to 16 bits requires 44 samples for averaging. Four to the fourth is equivalent to 256. The first question you should ask is, "Do I have time to implement the required algorithm in my controller or processor?" If you are trying to achieve a higher resolution than 16, the required sample size increases very quickly. By the way, the lower bits of the 12-bit converter in this discussion should be noisy so that the averaging is effective. This noise should be Gaussian.

Nonideal conditions that can affect the size of your averaging group include drift of the input over time, power-supply variations, voltage-reference changes, and temperature effects on your system. Any of these nonideal conditions can change the output value of your conversion. The sample size for a nonideal system can change from 2000 (with an ideal driftless system) to several hundred samples. If you increase the sample size above a few hundred samples for this nonideal system, the results begin to get noisier again. However, you can use Allan variance methods to compute the optimum number of averages for your data set. Finally, examine your input signal and ensure that you are not trying to convert an analog signal that has a settling-time error or an interfering periodic signal, such as the mains frequency.

There are time-saving ways of implementing averaging algorithms that go beyond the simple, brute-force technique of collecting all of the data and then performing an average. For instance, you could implement a FIFO by adding a new data point and subtracting the first data point accumulated in the group. Additionally, you can select the size of the groups to enable the use of a shift right for the division of the total, such as group values of 4, 8, 16, and so on.


Author Information
Bonnie Baker is the author of A Baker's Dozen: Real Analog Solutions for Digital Designers. You can reach her at bonnie.baker@microchip.com.



ADVERTISEMENT

ADVERTISEMENT

Feedback Loop


Post a CommentPost a Comment

There are no comments posted for this article.

Related Content

 

By This Author


ADVERTISEMENT

Knowledge Center



Technology Quick Links

EDN Marketplace


©1997-2008 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy

Please visit these other Reed Business sites