Skip to content

Input Linearity Curve for the DAC

Miguel Tomas Silva edited this page Feb 21, 2023 · 11 revisions

The DAC of the ESP32 microcontroller is not an exact linear response curve, especially at the ends of its operating range (around 0V and 3.3V). To address this, a lookup table is used to correct non-linearities.

When setting up an experimental setup is required to generate a lookup table before stating any experimental data measurements.


Things need to know before using a lookup table [1]

It is recommended to read the ESP32 Analog to Digital Converter before using the lookup table approach for solving the ESP32 linearity issue. According to documentation, ESP32 chips(ESP32-D0WD and ESP32-D0WDQ6) that were manufactured after 1st week of 2018 have been individual measurements and burned with the eFuse Vref value onto the chip. The eFuse Vref can be read using the function call read_efuse_vref(void) which you can find the source code at esp_adc_cal.c.

There is a function calculate_voltage_linear() in the same library which uses a polynomial formula to correct the linearity.


How to generate the lookup table?

The custom OEM firmware already has the code to generate a lookup table of values used to do DAC calibration. To run calibration, one is required to send the corresponding GBRL command to the smart DAQ. See the GBRL commands page, on this WIKI to learn more.

The code is based on original work from Helmut Weber that he first described at ESP32 discussion forum, but modified with bug-fixed by Henry Cheung.


References & Sources

[1] https://github.com/e-tinkers



Clone this wiki locally