# Getting 12-bits of Resolution out of your 10-bit A/D - Part 2: Oversampling

Post a comment

**Oversampling Technique**

Recall the moving average algorithm, Equation 3, from Part 1 of this article where

The signal-to-noise ratio (SNR) of y(n) can be written as

which can be reduced to

for an A/D with N bits. Please refer to Appendix A for a more detailed development of the equations presented. Equation 7 defines the SNR, or dynamic range in decibels, that you would expect to get from an A/D due to quantization noise. There is, however, another practical way to view SNR that includes the bandwidth of the input waveform. If we think about signal and noise in the frequency domain, then the RMS of the signal and noise can be calculated in the frequency domain by summing all the power in the signal and dividing it by a sum of all the power in the noise. In practice, this can be tricky to accomplish and could easily be the topic of another article. For now, let's just say that spectral leakage in the Fourier transform makes it difficult to calculate, but by carefully picking a window function, sampling rate, and number of samples in the Fourier transform, the leakage problem can be greatly diminished.

Figure 2 shows some data that was simulated using the Arrow signal processing analysis tool. The input waveform was set to 60Hz with an RMS level of 1 using 10-bit and 12-bit A/D resolutions. The sampling rate was 500Hz and there were 1024 points used in the Fourier transform calculations. For the 10 and 12 bit data shown, the average noise level per frequency component was calculated to be -89db and -110db respectively. A pretty good SNR approximation is to take the mean RMS level, convert it to power, multiply that value by the number of samples in the Fourier transform and then convert back to RMS in db. When you do this, the SNR for the 10 and 12 bit data calculates to 61.9db and 73.1db respectively, very close to what would be predicted by Equation 7.

**Figure 2 Fourier Transform Calculated SNR of a 60Hz Sine Wave using 10 and 12 bit A/D's**

At this point, there are some practical considerations that make oversampling pretty easily understood. If all we consider is quantization noise, then changing the sampling rate will not change the level of quantization noise in the system. In other words, Equation 7 is true regardless of the A/D's sampling rate (Fs). However, what we just demonstrated was that the RMS noise of an A/D can be calculated by summing all of the noise components from DC to the Nyquest frequency (Fn), where Fn is ½ the sampling rate, Fs.

Notice that if we increase the sampling rate, then the same frequency spectrum would be spread over a larger bandwidth and the magnitude of each component will decrease. For example, if we double Fs, the power at each frequency component would have to decrease by a factor of 2 to maintain the same SNR. In general, increasing Fs increases the bandwidth (BW) and as a result decreases the power at each frequency component by a factor equal to the increase in BW.

The previous intuitive analysis can be presented mathematically with Equation 8. For more information on how this equation was derived, see Appendix A.

This equation clearly shows that if we always allow the BW to be equal to the nyquest frequency, Fn, then Equation 8 reduces to Equation 7 and there is no change in the SNR. However, if we band-limit the sampled data, then an increase in Fs will increase the SNR. Let the increase in Fs required to generate additional bits of resolution be called the Oversampling Ratio (OSR). Also, let the additional effective bits (EB) plus the actual number of bits, N, used in the A/D form the ENOB for the processed A/D samples. Equation 9 relates OSR to EB and can be written as

Simply stated, each additional bit of resolution requires that the sampling rate be multiplied by a factor of 4 and the BW be held constant. Equation 10 writes the ENOB as

which leads to

**Sampled Data Bandwidth**

Limiting the bandwidth of the sampled data, y(n), can be accomplished by many methods with digital filters being the most obvious. The Arrow signal processing tool used to generate the sampled data in Figure 2, also enables experimenting with both infinite impulse response (IIR) and finite impulse response (FIR) filters. You can also experiment with Least Mean Squared (LMS) algorithms that increase the SNR of A/D data using adaptive filtering techniques. However, if we draw from the information presented in Part 1 of this article, we can see that simple averaging of A/D samples reduces the total RMS noise level independent of sampling rate and therefore must be limiting the bandwidth of the processed samples.

Equation 12, developed more fully in Appendix A, demonstrates the relationship between bandwidth and number of samples averaged.

At this point, we can see that if we maintain a given sampling rate, then the BW will decrease in direct proportion to the number of samples that we average and the SNR will increase. If, on the other hand, we increase the sampling rate by some factor, say 4, and do an average of 4 samples, then the original bandwidth will not change but there will be an increase in the SNR due to the increase in OSR. This leads to the final result that

where NS is the number of samples averaged in the moving average algorithm, Equation 3 of Part 1, and the bandwidth of the processed data is defined by Equation 12.

**60Hz Example**

Recall our original design example of monitoring a 60Hz signal with 70db of dynamic range. Let's assume in this example that we want to save cost by using a low-cost microcontroller with an onboard 10-bit A/D that has a maximum sampling rate of 20uS or 50KHz. Lets also assume that the 60Hz sine-wave must be sampled at 500Hz in order to capture the desired bandwidth and frequency resolution that is needed. Using Equation 9, the required OSR would be 16 and the number of samples to average, NS, would be 16 to maintain the same bandwidth.

Equation 9 predicts the desired ENOB for an OSR of 16. In addition, Equations 10 and 11 predict a SNR of 74db which is what would be expected for 12 bits. Using an OSR of 16 implies a sampling rate of 8KHz, which is well under the 50KHz maximum. In order to gain some headroom on SNR, we will go to an ENOB of 12.5 bits which implies an OSR of 32. The sampling rate for this would be 32KHz, still under the 50KHz maximum.

The Arrow signal processing analysis tool was used to demonstrate this example. Data was generated with 10-bit resolution at 32KHz and then processed using a 33 tap moving average algorithm. The data was then decimated by a factor of 8 making the effective sampling rate 4.125KHz. Further decimation can be done to reduce the sampling rate to the desired 500Hz in the example. Figure 3 illustrates the response of the moving average filter, SNR ratio of the processed 10-bit data and bandwidth after decimation. The final SNR of the processed data was 75db, just over the 74db requirement for 12 bits. In addition, the final sampling rate was well over the 500Hz requirement.

**Figure 3 10-bit A/D Oversampled and Processed with a 33 Tap Moving Average Algorithm**

**Practical Considerations**

Doing a moving average will improve SNR, however it can be seen that some pretty significant increases in Fs can be required to get significant improvements in SNR. The references discuss LMS algorithms that can achieve better noise cancellation and the Arrow signal processing tool allows you to experiment with LMS algorithms for canceling noise. If you plot the magnitude response of a moving average filter, the response looks like a low order Low-Pass FIR filter. As a result, the increase in SNR is not uniform across the bandwidth, LMS algorithms can help with this as well. The Arrow signal processing tool enables you to simulate data and experiment with moving average as well other filtering algorithms.

In Part 2, we presented a practical understanding of how to use the moving average, oversampling, and decimation to increase the SNR, and therefore ENOB, of an A/D. A generic equation for calculating the best case SNR of an A/D due to quantization noise was presented. In addition, a practical averaging algorithm was discussed that averaged samples to increase SNR and equations were developed for calculating the resulting bandwidth and increase in SNR as a result of the signal processing algorithm. Other algorithms such as LMS for canceling in-band noise were also discussed.

**References**

1. Lam, Harry, "Analog and Digital Filters" (Prentice-Hall), 1979.

2. Oppenheim, Alan and Ronald Schafer, "Digital Signal Processing" (Prentice-Hall), 1975.

3. Hayes, Monson H., "Statistical Digital Signal Processing and Modeling", John Wiley and Sons, Inc. 1996.

post a commentregarding this story.