Activity Forums Questions & Troubleshooting Software & Firmware Sampling rate for analog input of maxi automation Reply To: Sampling rate for analog input of maxi automation

  • Lukas

    Member
    June 26, 2019 at 4:35 pm

    Hi,

    based on my simple test – just calling analogRead in a loop, you can reach something like 8 kHz.

    Code:

    void loop() {
    // print the results to the Serial Monitor:
    Serial.print(“Millis before:”);
    Serial.println(millis());

    for (int i = 0; i < 1000; i++)
    {
    // read the analog in value:
    sensorValue = analogRead(analogInPin);
    }

    // print the results to the Serial Monitor:
    Serial.print("Millis after:");
    Serial.println(millis());

    }

    If you need to be faster, you have to write your own solution to control the Analog to Digital Converter – please see the ATmega2560 datasheet for more details. ATmega2560 is running at 16 MHz in the CONTROLLINO MAXI Automation.

    Best regards,

    Lukas