This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

About Oversampling ADC12

Hi guys, I've found some oversampling code on below webpage:

http://focus.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=slaa323


I'm trying to get 16 bit from a ADC12. I can't get a 16 bit result using below coding:

   movingAVG -= AVGBuffer[AVGpnt];
      movingAVG += ADC12MEM0;
      AVGBuffer[AVGpnt++] = ADC12MEM0;
      if (AVGpnt == 256)
     AVGpnt = 0;

      ADCresult = movingAVG >> 4;


But I can get the 16 bit result using below coding:

   movingAVG += ADC12MEM0;
   AVGpnt++;
   
   if (AVGpnt == 256)
   {
      AVGpnt = 0;
         ADCresult = movingAVG >> 4;
         movingAVG = 0;
   }


Aren't this two codes have the same function? Why is it the first one can't?

 

  • Steven Gan Teck Yik said:
    I can't get a 16 bit result using below coding

    Why not?

    What result do you get?

  • Andy Neil said:

    Why not?

    What result do you get?

    I always got just 13 bit for the first coding.

    But I get 16 bit for the second coding. Aren't the result for both coding are suppose to be the same? But mine is different.

  • One big difference: the first code does the >>4 shift on every iteration.

    However, the second is no moving avg. YOu only get a result on every 256th sample.

    But independent of that, just doign oversamplign doesn't reall increase resolution. Since each individual sample is quantized to 12 bit, adding and dividing doesn't give increased resolution.
    Proof: Real value is 1.05, quantization is 0.1. Every conversion results in 1.00. And 256*1 / 16 only gives 16.0 and not 16.8.

    Oversampling requires adding a symmtrical signal to the input voltage of the size >1LSB. Else oversampling just acts as a low-pass filter (e.g. noise suppression)  and does not increase the resolution.

    The oversamplign on a Delta-Sigma converter (like the SD16) is a completely other thing since a Delta-Sigma works by a completely different principle as the successive approximation converters like the ADC12

  • Jens-Michael Gross said:

    But independent of that, just doign oversamplign doesn't reall increase resolution. Since each individual sample is quantized to 12 bit, adding and dividing doesn't give increased resolution.
    Proof: Real value is 1.05, quantization is 0.1. Every conversion results in 1.00. And 256*1 / 16 only gives 16.0 and not 16.8.

    Oversampling requires adding a symmtrical signal to the input voltage of the size >1LSB. Else oversampling just acts as a low-pass filter (e.g. noise suppression)  and does not increase the resolution.

    Which code are you referring to that does not increase resolution? Is it the first coding? Is the first coding act as a low-pass filter?

    How bout the second coding? Is it correct as oversampling? Because I can get increase in resolution to 16 bit.

  • Steven Gan Teck Yik said:
    Which code are you referring to that does not increase resolution

    No specific code, but in general.

    If you read 1000 times teh same truncated value form the ADC, you don't even get half a bit of additional resolution. You just get a multiple of the truncated value.

    Oversampling for higher resolution requires a changing signal where the change is cyclic and not part of the signal one wants to measure.

    The trick with oversampling is as follows: If you add a small sine wave to the original signal, it will shift the original signal up and down. When you now sample the signal with a high frequency, there will be times when the total signal will pass the border from one ADC value to the next. Dependign on how many samples are detecting the increased value, the original signal was more or less close to the point where the ADC had sampled one digit more. When you average the samples, you'll get this way a higher resolution.

    Example:

    Signal is 1.05V, 'overlay' is a sawtooth wave of 0.1Vpp. Resolutiojn is 0.1V.
    Now you start samloing,. The first sample is 1.05V and reads as 1.00. next is 1.075V, reads as 1.0V. Next is 1.1V, reads as 1.1V. then 1.125, 1.15, 1.125, 1.1, 1.075.

    So what did you read after 8 samples? 8.4V, not 8.0. When you now divide it by 8, you'll get 1.05, and not 1.0. Resolution has increased. However, taking twice as many samples willl not increase resolution, unless I also double the sampling frequency.

    Reading just 8 times 1.0 when the real value would have been 1.05 would result in, right, 1.0 again. No resolution increase.

    The trick is to see how much a statistically zero small periodic change will change the reading.

    Without this, you'll just averaging the readings. This is not a resolution increase. Or more precisely, it is an increase of average signal resolution paid for by a significant decrease of time resolution. And is usually used to eliminate noise form the signal. But chances are that the real signal was never on the 'oversampled' value at all.

    Example: you have a square wave signal that is from 0V to 1V. You (over)sample it 100 times. You get 50 times 1V and 50 times 0V. After the shift, you'll get 0.5V with an apparent increase of resolution, but the signal never ever was really 0.5V, no matter whether you get 0.5V or 0.50V or 0.500V 'high precision' result. Your oversampled result is as far off form the real values as it can get. Maybe with more significant digits in the wrong result :)

     

**Attention** This is a public forum