Page 1 of 1

ADC Feature request.

Posted: Sat Dec 17, 2016 6:31 am
by MackPI
In addition to the way the ADC works now, I would like a new way to use the ADC.

I would like to request an ADC sample, The system would wait until the modem is ready to sleep, starts a fast read.
Then when the result is ready I would like a callback that will pass on the results.

I don't know if this is possible, but I think it could reduce a lot of overhead when sampling the ADC often.
Also by taking advantage of the modem sleep cycle, maybe the values could be more accurate.

I am currently using the NON-OS SDK version 2.0.0

Thank you.

Re: ADC Feature request.

Posted: Fri Jan 13, 2017 2:55 pm
by pratik
I think the best way to sample the ADC with minimum CPU overhead is to force modem sleep... then allow some time for system to enter modem sleep. This time can be set by using a timer callback to call after some time so that you can check if the system is in sleep. And then use the fast ADC read and call wakeup.
This process will reduce overhead for CPU but will not be effective for low latency ADC sampling, i.e. the time between you decide to measure a sample and the time when you actually read the ADC will be in micro-seconds. Long lag! But ok for tasks like regular sampling.

If you need to sample the ADC when the system enters automatic sleep mode between Wi-Fi activity, you can create an idle task hook in the RTOS SDK and use that for ADC sampling. I have not tested this but the ESP8266 enters modem sleep when idle task is executed. So that is where you go for the ADC!
Let me know that helps (should work on RTOS SDK).

Re: ADC Feature request.

Posted: Sat Jan 14, 2017 4:37 pm
by MackPI
Thank you Pratik,

I would like to stay on the NON OS SDK. Also, I would like to maintain a WiFi connection while reading the ADC. I have tried forcing modem sleep for power savings, I was automatically disconnected from the access point every time. Your post got me thinking about this in a new way.

Since I am asking for a feature, I don't expect this change to be high priority. It would be nice if Espressif developers would consider this request.

I am used to working with 8 bit microcontrollers that generates an interrupt when the ADC finishes an acquisition. I think the ADC is used by the modem when connected to an access point. This would make it risky to control the ADC directly. That is why I am requesting a callback function.

Thank you

Re: ADC Feature request.

Posted: Fri Jan 20, 2017 1:20 pm
by pratik
Definitely sounds like a useful feature to me. I will keep you posted on this!