# Use the oversamplling followed by the "decimation method" to increase the ADC resolution and not normal averaging

To increase the 12-bit resolution of ADC from 12 bit to 14 bit, this can be done through the 'oversampling and decimation method'. An Atmel Application note says that

The higher the number of samples averaged is, the more selective the low-pass filter will be, and the better the interpolation. The extra samples, m, achieved by oversampling the signal are added, just as in normal averaging, but the result are not divided by m as in normal averaging. Instead the result is right shifted by n, where n is the desired extra bit of resolution, to scale the answer correctly. Right shifting a binary number once is equal to dividing the binary number by a factor of 2.

It is important to remember that normal averaging does not increase the resolution of the conversion. Decimation, or Interpolation, is the averaging method, which combined with oversampling, which increases the resolution

This reference clearly says that for the decimation method, the result is right shifted by the desired extra bit of resolution, and not divided by m as in the normal average.

1. So, the question is, why do we need to use the decimation method instead of the normal averaging after the oversampling to increase the ADC resolution?

2. It says above "Right shifting a binary number once is equal to dividing the binary number by a factor of 2", but what if we don't use a binary number? How do we use the decimation method in this case?

• How do you define "normal averaging"? May 11, 2019 at 18:26
• "but what if we don't use a binary number" - all numbers are binary numbers in a microcontroller. May 11, 2019 at 18:32
• @TimWescott: It's "defined" (sort of) in the paper. May 11, 2019 at 18:32
• There's a practical limit to how many extra bits you can get; in my experience you might get 2 bits more. May 12, 2019 at 15:56

I wouldn't take that application note too seriously — it contains many errors, both conceptual1 and typographical.

Adding up a bunch of samples and then scaling the sum by some factor, no matter what you call it, IS averaging. It's also filtering. It is, in fact, just one special case of a finite impulse response (FIR) filter, in which every sample gets its own scale factor and then they get added together to create the result.

So, the question is, why do we need to use decimation method instead of the normal averaging after the oversampling to increase the ADC resolution?

It's all the same thing in the end.

It says above "Right shifting a binary number once is equal to dividing the binary number by a factor of 2", but what if we don't use a binary number, how do we use the decimation method in this case?

Just use ordinary division if the divisor isn't a power of 2.

1 For example, "white" noise is NOT equivalent to "gaussian" noise, although many natural noise sources are both gaussian AND white.

• Although, the distinction that the paper is making (however badly) is that whatever method you use for averaging (or filtering), you need to save the least significant bits. If you average 16 samples, you (roughly) reduce the RMS noise by a factor of 4. If you don't keep the two additional "good" bits one way or another, you lose the advantage. Whether you do that by shifting, or multiplying by floats, or whatever -- it still needs to be done. May 11, 2019 at 18:41
• Averaging reduces the bandwidth when the number of samples averaged exceeds the number of oversamples.
• averaging and decimation increases resolution when the noise is ideally between 1/2 and 2x LSB.
• averaging improves accuracy only if the noise is > 1 LSB
• The noise does not have to be Gaussian or white

This method must be prefiltered to remove noise or if clean add 1 LSB noise to achieve these improvements, which must be controlled by design. The bandwidth reduction is obvious per above. This may not be possible is noise is uncontrollable or nonlinearity exceeds 1/2 LSB.

• added. Sometimes on noise free signals you have to add noise or jitter to either the clock or the signal to get averaging to work with better resolution. This may occur when measuring OCXO’s with a counter using the same frequency and stable OCXO. Thus oversampling might accommodate this with jitter added if the two are synchronous.

So, the question is, why do we need to use decimation method instead of the normal averaging after the oversampling to increase the ADC resolution?

By 'normal' averaging I presume you mean dividing the sum by the number of samples. If you do this the result will have the same number of bits as a single sample, so you lose the extra bits you were trying to get. With decimation you only lose the lowest of the low bits, leaving some of the 'higher' low bits in to contribute to the final result.

It says above "Right shifting a binary number once is equal to dividing the binary number by a factor of 2", but what if we don't use a binary number, how do we use the decimation method in this case?

In the AVR (as in most computers) all numbers are binary, so I assume you just mean a number that is not a power of two. If the number of samples is not a power of two then to increase the resolution by a whole number of bits you must divide the sum by a number that is not a power of two. This may require using fixed point fractions or floating point math.

For example if you oversample x 25 and want exactly two extra bits then you need to divide by 25/4 = 6.25, which is not an integer. 8 bit AVRs don't have hardware floating point or even integer divide instructions, so dividing by fractions has to be done in software which is generally very inefficient. But shift instructions are very fast (as little as one CPU cycle per shift per byte) so it makes sense to choose an oversample rate that is a power of 2.

However there could be situations where you just need enough bits to eg. produce a decimal number with a certain number of digits. In that case it may be easier to directly divide the sum by the factor required to get the resolution you need, and not worry about whether it equates to a whole number of bits. In one case I had a 10 bit ADC and wanted a voltage display of 0.00-51.00V. To do this I oversampled by 64 times to get 1023*64 = 0-65472, then divided by 12.8 (using an optimized divide routine hard-coded to that factor) to get 0-5115. This was then displayed as 00.00-51.15 by simply inserting a decimal point after the second digit on the display.

• It is confusing , some references say that oversampling alone can improve the accuracy of ADC , other say oversampling must be companied with normal averaging , while this reference say that oversampling must be followed by Decimation and, not the normal averaging.
– Ali
May 13, 2019 at 16:42
• Oversampling is just taking several samples within a time period. They produce an average when added together, which also increases resolution because the sum has more bits. But the extra bits have less averaging so they are more noisy, and are not normally considered to be significant because they are below the ADC's resolution. 'Normal' averaging removes all the extra bits to reduce noise while maintaining the original resolution. Decimation removes only the lowest (most noisy) bits, keeping the higher (somewhat averaged and therefore less noisy) extra bits to increase resolution. May 14, 2019 at 1:35
• Thank you for your comment: what do you mean when you said that in the oversampling alone case, the extra bits are not considered to be significant due they are below ADC’s resolution . 2- i did not understand how the decimation can only remove the lowest(most noisy) bits and keep the higher bits (less noisy) , could you please more clarify this point , and list any reference could help for understanding this decimation. Thank you
– Ali
May 14, 2019 at 18:09