Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Fastest way to read 12 analog channels

  1. #1
    Junior Member
    Join Date
    Mar 2019

    Fastest way to read 12 analog channels


    I love my Teensy 3.6 I can't wait for Teensy 4.

    I'm trying to read a lot of analog channels. 12 for now, but maybe more. Most examples use the ADC library and continuous mode or DRM to get fast analog speeds. But they never use more than 4 channels. I know the hardware is sort of configured for 4 simultaneous reads, but what if we need more?

    What's the fastest way to read 12 channels?

    Right now i'm using the code below. It can read about 12x channels at ~10k samples a second. If I reduce the resolution to 8bits, then it goes to ~15k samples a second.

    This is actually an ok sampling speed for my project, but when I add the rest of my project code then the total performance is too slow. If there is a way to read all 12 channels through some kind of interrupt or hardware function that would be best. I could easily live with 12x 1k samples per second if I had the majority of the time back on the main thread.

    void setup() {
      for (int i=0; i < 12; ++i)
    long fpsTime = 0;
    long fpsCounter = 0;
    const unsigned long cUS = 1000000;
    void loop() {
      unsigned long currentTime = micros();
      if (currentTime - fpsTime > cUS)
        fpsCounter = 0;
        fpsTime = currentTime;
      float analogSignals[12];
      for (int i = 0; i < 12; ++i)
        analogSignals[i] = analogRead(i);
    CPU Speed: 180Mhz
    Optimization: Fastest + Pure Code + LTO
    Arduino 1.8.8
    Teensyduino 1.45

  2. #2
    Junior Member
    Join Date
    Mar 2019
    Would it be possible to use the threading library to do these analog reads on a background "thread"?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts