Two channels fast ADC sampling

EhudV_ShekelScales
Posts: 1
Joined: Tue Jan 26, 2021 2:46 pm

Two channels fast ADC sampling

Postby EhudV_ShekelScales » Tue Jan 26, 2021 3:09 pm

Hello friends

I have an ESP32 dev board (DEVKIT V1). I'm pretty new to the espressif framework. I've looked into the examples but I could not find an example that will suffic my needs.

What I'm trying to do:
establish two PWM signals at 4KHz, and at each PWM cycle i need an interrupt to be raised where two ADC values from two separate ADC channels will be aquired (the two ADC conversions must start and end within the same PWM cycle that triggered the conversion).
After the ADC values were aquired, a very efficient code will be executed to manipute the PWM duty cycle by those ADC values.
This cycle goes on forever.

Where I'm at:
Two PWM signals generated at about 4KHz -> Done
Use capture module (CAP0) to raise interrupts on each PWM cycle, by connecting the PWM signal to the pin that is config'ed for CAP0. -> Done.

What i'm struggling with:
Having a fast ADC conversion of two channels. this should occur as parallel as possible (i.e. the two conversions should take place as close together as possible). The sampling resolution must be at least 12bits.

I don't understand, this seems to be fairly a simple thing to do.
I tried the slow ADC conversions but it is, well slow, which means i need the DMA module to help me.
I tried using the I2S ADC DMA example to maybe do something similar to what i require. I just let it sample at about 8000KHz, keeping only the last values in global variables, and access those when i need to. This was only successful with sampling a single channel and I don't know how to sample two channels or more at once.

Please assist..
Thanks in advance!

Who is online

Users browsing this forum: Bing [Bot] and 279 guests