Photon 2 ADC conversion time

I’ve looked through the reference documents and haven’t found information specifically for the Photon2. I might have just missed it.

Apparently, the setADCSampleTime() instruction is NOT available for the Photon2 or other Gen3 devices. One location in the reference manual states Gen3 devices have sample times of 10us…however it doesn’t mention the Photon2.

In addition, it is NOT clear whether the Gen3 devices and the Photon2 take multiple samples (5 on previous generations) and average them to obtain a single ADC conversion result.

So just wondering what the execution time of the analogRead() operation on the Photon2 is. Sorry, I haven’t started working with the device yet…still doing some pre-planning.

I tested the Photon 2 ADC with this code:

void loop() {
    unsigned long start = millis();
    for(int count = 0; count < 10000; count++) {
    unsigned long elapsed = millis() - start;"elapsed=%d", (int)elapsed);

The output is pretty consistently around this:

0000012987 [app] INFO: elapsed=3300
0000021245 [app] INFO: elapsed=3247
0000029503 [app] INFO: elapsed=3249

In other words, 10,000 calls takes 3300 milliseconds, so each call takes 0.33 milliseconds, or 330 µsec. That is much slower than I would have expected, and likely is related to slow digital GPIO.

The ADC can sample much faster in audio mode with DMA (96000 samples/sec) so that might be an option, though I don't have sample code to do it.


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.