ESP32-C6 ADC1 BitWidth not met. ADC Values Deltas only 1,15,16,17 or multiples of them (or Additions)

User avatar
acmodbios
Posts: 6
Joined: Mon Apr 15, 2024 9:07 am

ESP32-C6 ADC1 BitWidth not met. ADC Values Deltas only 1,15,16,17 or multiples of them (or Additions)

Postby acmodbios » Mon Apr 15, 2024 9:44 am

Hello!

Using latest esp-idf v5.2.1 a little test program which runs either on ESP32-C3 OR ESP32-C6 shows that the ESP32-C6 SAR ADC gives less accurate ADC readings - could we please fix this somehow in esp-idf ? The same problem is existing with the adc-oneshot driver.

attached are two value files of C3 & C6, it is clearly seen that the ADC of the C3 has much more different values than the C6 ADC, resulting in a bitloss on C6 CPU.

The Signal is a Ramp of 1Hz from near 0 to near 3V.

// INCLUDES
#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <driver/adc.h>
#include <esp_log.h>

// TAG
const char TAG[] = "ADC";

// DEFINES
#define ADC_CHANNEL ADC_CHANNEL_2

// MAIN
void app_main(void)
{

// ADC SETUP
if (adc1_config_width(ADC_WIDTH_BIT_12) != ESP_OK)
{
ESP_LOGE (TAG, "WIDTH ERROR");
}
if (adc1_config_channel_atten(ADC_CHANNEL, ADC_ATTEN_DB_12))
{
ESP_LOGE (TAG, "ATTEN ERROR");
}

int xo = 0;
while (1)
{
int x= adc1_get_raw(ADC_CHANNEL);

ESP_LOGI (TAG, "%d, %d", x, x - xo);
xo= x;

vTaskDelay(pdMS_TO_TICKS(0));
}

}
Attachments
esp32-c6-adc.txt
(7.73 KiB) Downloaded 130 times
esp32-c3-adc.txt
(7.85 KiB) Downloaded 137 times

MicroController
Posts: 1725
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP32-C6 ADC1 BitWidth not met. ADC Values Deltas only 1,15,16,17 or multiples of them (or Additions)

Postby MicroController » Tue Apr 16, 2024 9:26 am

ADC gives less accurate ADC readings ...
The Signal is a Ramp of 1Hz...
In this case, the values you'll get from the ADC obviously depend on timing.
With an ideal ADC, no signal noise, and no timing jitter, you would expect every delta to be exactly the same, namely the slope of your voltage ramp.

What's the result when you change the signal to e.g. 0.5Hz?

User avatar
acmodbios
Posts: 6
Joined: Mon Apr 15, 2024 9:07 am

Re: ESP32-C6 ADC1 BitWidth not met. ADC Values Deltas only 1,15,16,17 or multiples of them (or Additions)

Postby acmodbios » Tue Apr 16, 2024 10:21 am

Hello!

1Hz is the slowest i can do with my Function Generator. I get the same ADC jumps of Value also when i sample with ADC Continuous Mode Driver.

There is never any 2,3,4,5,6,7,8,9,10,11,12,13,14 values. Only 1,15,16,17 and combinations of the last ones.

https://docs.espressif.com/projects/esp ... nuous.html

best regards

User avatar
acmodbios
Posts: 6
Joined: Mon Apr 15, 2024 9:07 am

Re: ESP32-C6 ADC1 BitWidth not met. ADC Values Deltas only 1,15,16,17 or multiples of them (or Additions)

Postby acmodbios » Tue Apr 16, 2024 10:25 am

Hello!

I seems not to be from timing. Both CPUs run from 160Mhz. Also if i sample the slope with adc cont. driver with 82kHz i never get any digital delta values (new adc value - last adc value) of 2,3,4,5,6,7,8,9,10,11,12,13,14 - only 1,15,16,17

This seems pur ADC problem.

best regards

MicroController
Posts: 1725
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP32-C6 ADC1 BitWidth not met. ADC Values Deltas only 1,15,16,17 or multiples of them (or Additions)

Postby MicroController » Wed Apr 17, 2024 7:31 am

Btw, your function generator doesn't happen to have an output resolution of 8 bits, does it?

User avatar
acmodbios
Posts: 6
Joined: Mon Apr 15, 2024 9:07 am

Re: ESP32-C6 ADC1 BitWidth not met. ADC Values Deltas only 1,15,16,17 or multiples of them (or Additions)

Postby acmodbios » Wed Apr 17, 2024 8:00 am

No it does not, it is an old analog one - i can also verify it with specific mV values from a super exact Aim-TTi EX354RD presented to the ADC Pin.

Thanx

mnicolas_ter
Posts: 3
Joined: Fri Sep 06, 2024 7:08 am

Re: ESP32-C6 ADC1 BitWidth not met. ADC Values Deltas only 1,15,16,17 or multiples of them (or Additions)

Postby mnicolas_ter » Fri Sep 06, 2024 7:34 am

Hello,

I am experiencing the same issue, did you manage to solve/work around this problem?

I have done some testing with fixed input values and the results do not show the granularity expected from a 12 bit output.
For example, the atatched log is from a fixed signal that is supposed to convert to circa 2000 points. This log is generated using the oneshot api, but continuous mode gives the same results.
The only values present in the log are 2000, 2001, 2016 and 2017. Values in between never appear.
Using the average value of all these readings does not give satisfactory restuls either.

Thanks

User avatar
acmodbios
Posts: 6
Joined: Mon Apr 15, 2024 9:07 am

Re: ESP32-C6 ADC1 BitWidth not met. ADC Values Deltas only 1,15,16,17 or multiples of them (or Additions)

Postby acmodbios » Sat Sep 07, 2024 7:03 am

Hello!

The issue is present up latest esp-idf v5.3, i am still testing new releases. a statement from Espressif would be HELPFUL!
I already contacted their support and never got a response. i am pretty sure they are aware of this bug.

So if anybody can help us fix this issue it would be really apreciated.

best regards

mnicolas_ter
Posts: 3
Joined: Fri Sep 06, 2024 7:08 am

Re: ESP32-C6 ADC1 BitWidth not met. ADC Values Deltas only 1,15,16,17 or multiples of them (or Additions)

Postby mnicolas_ter » Fri Sep 13, 2024 10:07 am

Thanks,

from the tests I have done, it seems that the resolution of this ADC converter is actually 8 bit, which is not sufficient for my application

User avatar
acmodbios
Posts: 6
Joined: Mon Apr 15, 2024 9:07 am

Re: ESP32-C6 ADC1 BitWidth not met. ADC Values Deltas only 1,15,16,17 or multiples of them (or Additions)

Postby acmodbios » Sat Sep 14, 2024 5:29 am

Hello!

Yes 8bit + Pseudo Random Bit Signal of values either 0x00, 0x01, 0x0F. any comment of Espressif Techs would be fine here!

maybe its fixable inside esp-idf adc driver,

br

Who is online

Users browsing this forum: No registered users and 137 guests