0

Is there a blocking analog read and what is sample rate?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Is there a blocking analog read and what is sample rate?

by kevinjwalters on Tue Oct 09, 2018 9:56 am

Is there a blocking analogue read or some other technique to ensure you get a fresh value from the ADC inputs on boards like the Circuit Playground Express? The behaviour of value property isn't documented wrt new samples in analogio.AnalogIn.

I did a quick test and can do 100 reads * 7 pins in ~90ms in CircuitPython. What is the maximum sample rate for analogue reads for CPX board? Is the ADC rate far higher than the time taken to read and loop in Python? I see a few references to what might be a 6 cycle process at 2.1 MHz yielding an absolute maximum rate of 350ksps?

kevinjwalters
 
Posts: 975
Joined: Sun Oct 01, 2017 3:15 pm

Re: Is there a blocking analog read and what is sample rate?

by tannewt on Tue Oct 09, 2018 2:15 pm

AnalogIn.value does a fresh read every time its read. The source is here: https://github.com/adafruit/circuitpyth ... ogIn.c#L90

The ADC limit on the M0 is 350ksps but we do more in the value so the max from CircuitPython is probably much less.

I do want to add audioio.AudioIn that samples into a buffer but I haven't gotten there yet.

tannewt
 
Posts: 2571
Joined: Thu Oct 06, 2016 8:48 pm

Re: Is there a blocking analog read and what is sample rate?

by kevinjwalters on Sun Nov 18, 2018 10:31 am

If fast sampling into a buffer is implemented then might be worth mentioning why A0 is a bit different in the documentation - see Can the 0.1uF capacitor on CPX A0 affect input?.

kevinjwalters
 
Posts: 975
Joined: Sun Oct 01, 2017 3:15 pm

Please be positive and constructive with your questions and comments.