analogSetCycles, analogSetSamples

Brain Scientist
Posts: 4
Joined: Thu Aug 15, 2019 10:15 pm

analogSetCycles, analogSetSamples

Postby Brain Scientist » Fri Aug 16, 2019 1:58 pm

Can someone provide detailed descriptions of analogSetCycles() and analogSetSamples()? Please don't say "sets the number of samples in the range" or "sets the number of cycles per sample". I have looked at the Arduino source code, but that led to a dead end trying to use the ESP32 documentation. My best guess is that analogSetSamples() does some sort of repeated sampling of a single channel (oversampling) to effectively increase the number of bits of resolution. I can't guess at analogSetCycles(). Clock cycles? Perhaps these both have to do with redundantly listing a channel in the DIG SAR ADC scan table. Note, you cannot search the forums for these functions because there are too many hits. Apparently, these function are in everyone's ADC code. Thanks.

noweare
Posts: 74
Joined: Tue Jul 02, 2019 11:35 am

Re: analogSetCycles, analogSetSamples

Postby noweare » Sun Aug 02, 2020 3:01 am

Set cycles refers to sampling time i.e. how long to to sample the input in clock cycles.

Set Samples, should be to take a number of samples and average the result but I don't really know.

One thing I know is if I use analogSetSamples in my code my adc return widely varying values.
For,example if I slowly move the potentiometer to lower values I get higher and lower values back from the
adc. I should be consistanly smaller values. When I take that line out, things work like they are supposed to.

BobESP32
Posts: 1
Joined: Fri Nov 27, 2020 1:03 pm

Re: analogSetCycles, analogSetSamples

Postby BobESP32 » Fri Nov 27, 2020 4:36 pm

Did anyone get to the bottom of this? I'd be really interested to know what these really do and when to use them, especially analogSetSamples(). Is there any way to request input from a mod/expert/Espressif on this? Do we know if they change something in the hardware or if they are just software-implemented?

As stated above, the description of "Set number of samples in the range, default is 1, it has an effect on sensitivity has been multiplied" doesn't make sense in English. It's anyone's guess as to what this is meant to mean.

And after we find out what it means, someone with power to do so needs to update the official documentation.

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: analogSetCycles, analogSetSamples

Postby lbernstone » Fri Nov 27, 2020 9:26 pm

Noweare's description is correct. These functions were holdovers from before esp-idf had an adc driver. They will be removed in v1.0.5, so you will need to do oversampling on your own.

Who is online

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