ESP32-S3 : Is it possible de create many Adc Continuous Driver instances ?

ThomasESP32
Posts: 191
Joined: Thu Jul 14, 2022 5:15 am

ESP32-S3 : Is it possible de create many Adc Continuous Driver instances ?

Postby ThomasESP32 » Mon May 29, 2023 1:14 pm

Good afternoon,

I am working on an Esp32-S3 microcontroller (Using Esp32-S3-DevKit-C-1).
Moreover, I am using an Adc Continuous Mode driver instance in order to sample a signal on ADC1 channel 0 with
a frequency 64000Hz and asking something like 4000 samples.

Is it possible to create another Adc Continuous Mode driver instance in order to sample another signal on ADC1 but on channel 6 for example using another frequency and another amount of samples ?
Best regards,

Thomas TRUILHE

lukilukeskywalker
Posts: 21
Joined: Wed Feb 22, 2023 4:25 pm

Re: ESP32-S3 : Is it possible de create many Adc Continuous Driver instances ?

Postby lukilukeskywalker » Mon May 29, 2023 9:20 pm

If I remember correctly, you can, when setting the continuous adc configuration set more than one channel, for the adc and dma to read from. Then when when you read the buffer, you get a struct that tells you which sample is from where. The only thing is, the sampling frecuency gets divided by all the channels you read from, so If you want to keep the sampling frecuency per channel, then you need to increase the overall sampling frecuency of the adc

Also, I think you can only use one adc, as there is only one dma allocated for them (?)(not sure though)

lukilukeskywalker
Posts: 21
Joined: Wed Feb 22, 2023 4:25 pm

Re: ESP32-S3 : Is it possible de create many Adc Continuous Driver instances ?

Postby lukilukeskywalker » Mon May 29, 2023 9:22 pm

So, reanswering your question, for you to sample at another frecuency, I guess you would need to do that with software, performing a decimation, or sampling cut, deleting samples you dont need

ThomasESP32
Posts: 191
Joined: Thu Jul 14, 2022 5:15 am

Re: ESP32-S3 : Is it possible de create many Adc Continuous Driver instances ?

Postby ThomasESP32 » Tue May 30, 2023 2:01 pm

Do you mean I cannot instantiate a first ADC instance with a frequency 10000Hz
and another ADC instance with a frequency 500Hz running together on two tasks ?

Best regards,

Thomas TRUILHE

ThomasESP32
Posts: 191
Joined: Thu Jul 14, 2022 5:15 am

Re: ESP32-S3 : Is it possible de create many Adc Continuous Driver instances ?

Postby ThomasESP32 » Wed May 31, 2023 9:36 am

So according to your recommandation, I am using only one Adc Continuous driver in
order to sample 3 channels. However, I am facing another problem :

Using a 16000Hz per channel => Total 48000Hz.
I would like to record 2048 samples per channel => Total = 6144 samples = 24 576 bytes.

Unfortunately, it seems that when I use more than 4000 bytes (Total), for example 5000 bytes
during Adc initialisation and when I call the function adc_continuous_read using 5000 bytes,
the function always return in error...

Do you know why ??
Best regards,

ThomasESP32
Posts: 191
Joined: Thu Jul 14, 2022 5:15 am

Re: ESP32-S3 : Is it possible de create many Adc Continuous Driver instances ?

Postby ThomasESP32 » Wed May 31, 2023 9:39 am

The error is always Timeout.

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

Re: ESP32-S3 : Is it possible de create many Adc Continuous Driver instances ?

Postby MicroController » Wed May 31, 2023 10:36 am

ThomasESP32 wrote:
Wed May 31, 2023 9:39 am
The error is always Timeout.
So, what is the timeout value you pass to adc_continuous_read?
Notice that adc_continuous_read needs the timeout to be specified in milli-seconds, not FreeRTOS ticks; it internally converts the ms to ticks, so a timeout_ms value < portTICK_PERIOD_MS becomes 0 ticks and may cause issues.

lukilukeskywalker
Posts: 21
Joined: Wed Feb 22, 2023 4:25 pm

Re: ESP32-S3 : Is it possible de create many Adc Continuous Driver instances ?

Postby lukilukeskywalker » Thu Jun 01, 2023 8:40 am

well, if i remember correctly, adc_continuous_read has a Timebase_t parameter. What you usually do is wait for a frame to be completed. You wait for that frame , using some kind of Taskblocker, like ulTaskNotifyTake or xTaskNotifyWair (Look in Freertos docs), and you set the bits needed for the task to unblock in a ISR, that you previously handled to the adc_continuous component.
You obviously can do it by calling adc_continuous_read, and setting a portMAX_DELAY in the Timebase_t parameter, in that case the function will be waiting until in its buffer it has the requested samples you asked for

Still, I don't think it is the right way to aproach it, you should aim to get out of the function at a time where the sampling should have already finished, so that in case the component fails, your task doesnt get suck waiting for ever. 7

By the way, have you started the component with: adc_continuous_start? (No idea if the adc_continuous_read, tests if it is the right state, I guess it does, espressif components are quite robust)

Hope it helps your further

Who is online

Users browsing this forum: DrMickeyLauer, sangk82 and 68 guests