Post topics, source code that relate to the Arduino Platform

User avatar
By mpeg42
#29152 The analog input of the ESP8266 ist absolute non-linear.
Now i look for a little programm to correct this.

Here are my measurements:

0.0V - 5
0.1V - 195
0.2V - 338
0.3V - 463
0.4V - 555
0.5V - 643
0.6V - 714
0.7V - 782
0.8V - 842
0.9V - 900
1.0V - 952

thanks for your tips.
User avatar
By pvvx
#29173 Your measurements are not true.

SDK is not a linear ADC
Espressif uses primitive correction:

Correction adders z - 21:

Code: Select allvoid read_sar_dout(uint16 * buf)
{
   volatile uint32 * sar_regs = &SAR_BASE[32]; // 8 regs 0x60000D80...
   int i;
   for(i = 0; i < 8; i++) {
      int x = ~(*sar_regs++);
      int z = (x & 0xFF) - 21;
      x &= 0x700;
      if(z > 0) x = ((z * 279) >> 8) + x;
      buf[i] = x;
   }
}



The sum of eight values:

Code: Select alluint16 sar_dout, tout, sardata[8];

   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

Image
Riso, Сiso ?
User avatar
By martinayotte
#29182
pvvx wrote:Your measurements are not true.


@pvvx, no problems, it is not my measurements, it is a graph provided in the Wiki, link provided...
(Personally, I didn't experiment the ESP internal ADC at all ... ;) )
Last edited by martinayotte on Wed Sep 16, 2015 12:08 pm, edited 1 time in total.