Good afternoon,
I am working with an Esp32S3 and at the moment, I am using the ADC1 module in continuous mode in order to read samples on one channel only (Channel 7).
The configuration is the following :
esp_err_t AdMeasureInit;
adc_continuous_handle_t AdcHandle;
adc_channel_t channel[1] = {ADC_CHANNEL_7};
adc_continuous_handle_cfg_t AdcHandleConfig = {
.max_store_buf_size = 4000,
.conv_frame_size = 4000};
AdMeasureInit = adc_continuous_new_handle(&AdcHandleConfig, &AdcHandle);
if (AdMeasureInit == ESP_OK)
{
/* On configure l'ADC : */
adc_continuous_config_t AdcConfig = {
.sample_freq_hz = 64000,
.conv_mode = ADC_CONV_SINGLE_UNIT_1, // On utilise uniquement l'ADC1.
.format = ADC_DIGI_OUTPUT_FORMAT_TYPE2, // On utilise le type 2. Pris dans l'exemple.
};
adc_digi_pattern_config_t adc_pattern[SOC_ADC_PATT_LEN_MAX] = {0};
AdcConfig.pattern_num = 1;
for (int ii = 0; ii < 1; ii++)
{
uint8_t unit = ADC_UNIT_1;
uint8_t ch = channel[ii] & 0x7;
adc_pattern[ii].atten = ADC_ATTEN_DB_12;
adc_pattern[ii].channel = ch;
adc_pattern[ii].unit = unit;
adc_pattern[ii].bit_width = 12;
}
AdcConfig.adc_pattern = adc_pattern;
AdMeasureInit = adc_continuous_config(AdcHandle, &AdcConfig);
}
On the ADC1, channel 7, I am sampling 4000 samples at 64000Hz.
Now, I would like to add a second channel (In order to have two channels at the same time) on the ADC1.
And I would like to have the same amount of samples (4000) and the same sampling frequency (64000) on the two channels.
In the configuration above, if I add a channel in adc_channel_t channel, for example :
adc_channel_t channel[2] = {ADC_CHANNEL_2, ADC_CHANNEL_7};
1) Do I have to double the number of samples in :
adc_continuous_handle_cfg_t AdcHandleConfig = {
.max_store_buf_size = 4000,
.conv_frame_size = 4000};
So 8000 instead of 4000 ?
2) The same thing, do I have to double the frequency in :
adc_continuous_config_t AdcConfig = {
.sample_freq_hz = 64000,
.conv_mode = ADC_CONV_SINGLE_UNIT_1, // On utilise uniquement l'ADC1.
.format = ADC_DIGI_OUTPUT_FORMAT_TYPE2, // On utilise le type 2. Pris dans l'exemple.
};
So 128000 instead of 64000 ?
In the case where I have to double the number of samples and the sampling frequency, do you think that the values 8000 samples and 128000Hz can be accepted by the driver ?
Thank you for your help on the subject,
Have a good day,
Best regards
Thomas TRUILHE
ESP-IDF : How to configure the ADC in continuous mode for 2 channels please ?
-
- Posts: 214
- Joined: Thu Jul 14, 2022 5:15 am
-
- Posts: 214
- Joined: Thu Jul 14, 2022 5:15 am
Re: ESP-IDF : How to configure the ADC in continuous mode for 2 channels please ?
Moreover, in this configuration, how are organized the samples/bytes in the output buffer when
we are calling the adc_continuous_read method.
Because we have 2 channels, are the bytes interlaced in the output buffer ??
Best regards,
we are calling the adc_continuous_read method.
Because we have 2 channels, are the bytes interlaced in the output buffer ??
Best regards,
Who is online
Users browsing this forum: No registered users and 116 guests