0
\$\begingroup\$

I need to read multiple analog inputs as fast as possible on a ESP32. With as fast as possible, i mean that ideally all inputs are read simultaneously.

Currently I simply read them one after the other with consecutive AnalogREAD() calls in my code, but it happens that I read a value on a Input where no current is applied. I have read somewhere some months ago that in these cases it is good to put a pause between Read calls to give it the time to switch to the proper input.

Is this true? What is a reasonable amount of time to put in there, keeping in mind that I would need to read tehm all (5 inputs) as quick as possible?

All inputs are on the ADC 1.

\$\endgroup\$
2
  • \$\begingroup\$ Depends on the type of ADC. If it's a capacitive sample-and-hold then it indeed might be wise to have a pause after switching to a diffirent input to allow the capacitor to settle at the new input voltage. How long this takes depends on the impedances involved. \$\endgroup\$ Jul 21, 2021 at 6:46
  • \$\begingroup\$ @Unimportant Usually the analog input pin is disconnected and only connected to the sampling capacitor during the sampling period after starting the conversion. And it is the job of ADC to reset the sampling capacitor when it is done. Therefore, as the sampling period is always the same, there is no difference if there is a delay or not. If a delay helps, it means the ADC may be running too fast anyway or source impedance is too high for the sampling time. \$\endgroup\$
    – Justme
    Jul 21, 2021 at 9:56

1 Answer 1

1
\$\begingroup\$

The fastest way would be to use two different ADCs so you can simultaneously sample and convert two analog inputs.

The second fastest way (according to the reference manual) would be to tell the ADC a list of channels which to sample and tell it to go sample the channels in the list, writes results to memory using DMA, and reports with a scan complete interrupt when it is done going through the list.

There is little benefit of delaying between taking ADC conversions, if it helps then it is a sign of the sampled signals having too high impedances to get a stable result, which could be also a sign of the ADC being incorrectly configured for the expected signal impedances, and just longer sampling period (or slower ADC clock) might fix it. Usually the switch between channels is done when the analog sampling circuit is not connected to the analog pin.

\$\endgroup\$
1
  • \$\begingroup\$ thank you very much! Ill check the list-version of your solution. \$\endgroup\$ Jul 21, 2021 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.