Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By mamalala
#647
hackrid wrote:seems like the built in adc samples with 8 bit resolution.

some over sampling magic is applied to get 10 bit resolution.


my guess: ADC samples with 4MSamples/s. not certain about that.
Code: Select all    read_sar_dout(sardata);

    for (i = 0; i < 8; i++) {
        sar_dout += sardata[i];
        ADC_DBG("%d, ", sardata[i]);
    }

    tout = (sar_dout + 8) >> 4;   //tout is 10 bits fraction



That isn't oversampling at all. A right-shift by 4 positions equals a division by 16. But only 8 samples are added together in the loop right before that. That's rather strange code. If the result has 10 usable bits, then the ADC must bee 11 bits.

Greetings,

Chris
User avatar
By Squonk
#653 What the "(sar_dout + 8) >> 4" expression does is to first bias before shift, actually rounding the sar_dout value before dropping the 4 decimal places.
User avatar
By mamalala
#655
Squonk wrote:What the "(sar_dout + 8) >> 4" expression does is to first bias before shift, actually rounding the sar_dout value before dropping the 4 decimal places.


Damnit, you are right. Somehow i totally overlooked that +8 one and concentrated only on the shift-by-4 ...

Greetings,

Chris

Edit: That is, it does indeed read the ADC with 10 bits and basically uses a simple averaging to reduce noise, since the result are again 10 bits. That is, of course, if the result does indeed do have 10 bits, didn't play with the ADC part yet.
User avatar
By hansaya
#6959 Did any one tried the Internal I2c ADC? I have a application where i need to measure some analog values in a power efficient way. Of cause i can bit bang a external i2c ADC and get it to work but there is no fun in it and not efficient. :shock: