Max speed analogRead()

Discussion in 'UDOO NEO' started by Francisco Gómez, Feb 16, 2017.

  1. Francisco Gómez

    Francisco Gómez New Member

    Joined:
    Feb 15, 2017
    Messages:
    2
    Likes Received:
    1
    Hello everyone!

    I write from Spain. This is my first post. My english is very basic, sorry for this inconvenience.

    I am working with the analog inputs and I am trying to know what is the maximum speed capture.
    I have written this basic example to do tests but I just got 3754 measurements in 5 seconds.
    It really is not what I expected. I thougt that the amount would be at least 100 times more.

    Is there any way to speed up sampling?


    This is my basic example test code:

    Code:
    unsigned long time = 5000; // miliseg
    unsigned long save_millis = 0;
    
    
    unsigned long counter = 0; // loop counter
    
      int InA0;
      int InA1;
      int InA2;
      int InA3;
      int InA4;
      int InA5;
    
    
    void setup() {
    
     
      Serial.begin(115200);
      analogReadResolution(12);
      delay(10000);
     
     
    }
    
    void loop() {
    
     
      InA0 = analogRead(A0);
     
      InA1 = analogRead(A1);
      InA2 = analogRead(A2);
        
      InA3 = analogRead(A3);
      InA4 = analogRead(A4);
      InA5 = analogRead(A5);
        
      counter++;
      
    
      if( millis() >= (save_millis + time )){
        Serial.print("counter =");
        Serial.println(counter);
     
        Serial.println(InA0);
     
        Serial.println(InA1);
        Serial.println(InA2);
     
        Serial.println(InA3);
        Serial.println(InA4);
        Serial.println(InA5);
        
        counter = 0;
        save_millis = millis();
      }
     
     
    }
    Thanks in advance.
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Andrea Rovai likes this.
  3. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    When I only read 1 pin I get approx 21000 reads per 5 seconds. Setting the resolution had no influence.
     
  4. Francisco Gómez

    Francisco Gómez New Member

    Joined:
    Feb 15, 2017
    Messages:
    2
    Likes Received:
    1
    Thank you for your replies waltervl.

    I am doing tests with UDOO QUAD and I'm getting 1,754.995 reads per minute with 7 analog inputs ( 146,249 reads in 5 seconds).
    The resolution is 12bits in my test.

    I will use UDOO QUAD for my proyect.
     
    waltervl likes this.
  5. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Just checked the reference manual that can be found here: http://www.udoo.org/docs-neo/Hardware_Reference/Overview.html
    chapter 14
    The sample time can be between 0.7 us and 10 us, it depends on the configuration. So the Neo should be able to sample 10.000 to 100.000 samples a second.
    So it seems that there is a lot of delay on the line.
    Can someone tell or show us the configuration of the ADC?
     
  6. jas-mx

    jas-mx Active Member

    Joined:
    Dec 31, 2013
    Messages:
    407
    Likes Received:
    118
    You need to review the MQX layer to see how the ADC is setup, there are many options for long/short sampling rates depending on resolution, mcu bus frequency, fADCK, compare phase time and sample phase time. Not sure where you got the 0.7-10us range from?
     
  7. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    I got the sample time range from the configuration examples in chapter 14.3.3.6.
    So it are just examples so I wanted to check how the Neo was configured.
    I will dive deeper in the MQX layer.
     

Share This Page