The Power of Moving-Average Digital Filters
by Bonnie C. Baker, Microchip Technology Inc.
Often, analogue-to-digital converter users employ averaging algorithms with their controller or processor on the output of several samples from the converter. A converted signal can be smoothed by using this technique (see Figure 1), and the effective resolution can be improved by reducing system noise.
Smoothing converted data
The smoothing effect on the converted data is implemented by acquiring multiple signals at a constant sample rate, averaging a predetermined group or number of the 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 low-pass filter on the converter output data. The effectiveness of the filtering can be controlled by selecting the appropriate number of samples for the averaged groups. If using more samples in each group, there will be a higher degree of smoothing. This averaging process eliminates spikes in the raw data as well as reducing 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. This is an increase in the Signal-to-Noise Ratio (SNR) of 6 dB. Sixteen averaged samples (42) will increase resolution by two and SNR by 12 dB. Theoretically, a group size of 4N will increase the number of effective bits from the conversion by N, but there are real-world limitations to this theory.
Real-world digital filtering
It is possible to increase the number of effective bits with an analogue-to-digital converter, as long as realistic goals are maintained and consideration is given to non-ideal 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 that should be asked is; “Is there sufficient time to implement the required algorithm in the controller or processor?”. If the goal is a resolution higher than 16, the required sample size increases very quickly. Incidentally, the 12-bit converter in this discussion should have a few bits of noisy output to ensure that the averaging is effective. This noise should be gaussian in nature.
Non-ideal conditions that can affect the size of an averaging group include drift of the input over time, power-supply variations, voltage-reference changes, and temperature effects on the system. Any of these non-ideal conditions can change the output value of the conversion. The sample size for a non-ideal system can change from 2000 (with an ideal driftless system) to several hundred samples. If the sample size for this non-ideal system is increased, the results begin to become noisy. However, using Allan variance methods can be used to compute the optimum number of averages for the data set. Finally, the input signal should be examined to ensure that the conversion is not being attempted on an analogue 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, a First In First Out (FIFO) can be implemented by adding in a new data point and subtracting the first data point accumulated in the group. Additionally, the size of the groups can be selected to enable the use of a shift right for the division of the total, such as group values of 4, 8, 16 or more.
Whether using simple techniques or more time-saving methods, moving-average digital filters can effectively smooth converted signals and improve resolution by reducing system noise.
LATEST issue 4/2022
In a special interview for the magazine arch. Lyubomir Stanislavov, CEO and Member of the Board of Directors of Automotive Cluster Bulgaria, comments the current technology trends in the automotive sector and the role of Bulgaria-based electronic component manufacturers for the regional and global automotive industry. The whole interview you can read online here...
Endrich Bauelemente Vertriebs introduced its new IoT device - the so called cityBox device, which represents an air quality detection system - at this year’s edition of the International Technical Fair in Plovdiv. The company describes its participation ath the event as a real success. Learn more about it here...
Comet Electronics offers development services from the idea to the complete product, according to customer’s needs. The company’s design department works in close cooperation with its manufacturing units and the products it designs have optimized manufacturability. Read more here...
The production of automotive components is one of the fastest growing sectors of the Bulgarian economy in recent years. According to the Bulgarian Investment Agency, 80% of all sensors and over 90% of airbag sensors in European cars are produced in Bulgaria. More on the topic - in the cover story of the latest issue 4/2022...