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

Thread: Teensy4 ADC pin switching speed

  1. #1

    Teensy4 ADC pin switching speed

    I need to collect ADC readings from more than two pins with a Teensy4.
    How fast should I expect to be able to reset which pin to take the ADC reading from and get a reliable reading?

  2. #2
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    626
    Looks to me like zero time. But might be worth some tests to see if there is any effect on the values that could be eliminated with more time.

  3. #3
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    486
    Try this -- connect one input to VDD (3.3 V), and the other to GND. Then run a small sketch that reads alternately between the two inputs -- see how slow you have to go to only (mostly) see codes near 0 and near full scale.

  4. #4
    Senior Member
    Join Date
    Jan 2020
    Location
    Toscana
    Posts
    130
    Quote Originally Posted by kdharbert View Post
    I need to collect ADC readings from more than two pins with a Teensy4.
    How fast should I expect to be able to reset which pin to take the ADC reading from and get a reliable reading?
    Usually a millisecond of delay should do well.
    The timing seems to be not the same on all pins, but with the millisecond it should always be on the safe side.

    When I use the ADC i read twice the same pin with the same ADC and discard the first reading after doing some useless math with it (adding it up on a useless uint32_t and later on checking it for being 0, which will result in setting it to 1). That is to trick the compiler not to omit the first analogRead, because the result never gets used.

    This way I always get useful results from the second analogRead.
    Remember to specify the ADC to be used, or Teensyduino might use another ADC on a rotating basis with the result of new MUX settings.

    I know, it is far from good coding, but this is Arduino.....

  5. #5
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    626
    I did a test and the impact was a small fraction of one count, which is generally lost in the large amounts of noise. I'd wouldn't bother with doing anything.

  6. #6
    Senior Member
    Join Date
    Jul 2020
    Posts
    383
    Quote Originally Posted by kdharbert View Post
    I need to collect ADC readings from more than two pins with a Teensy4.
    How fast should I expect to be able to reset which pin to take the ADC reading from and get a reliable reading?
    It depends mainly on the impedances driving each pin. With low impedance its effectively instant, with something like 100k
    you'd expect settling times measured in 10's of Ás from when the analog multiplexer changes. Typical sample/hold capacitors
    are 10pF of so, hence 100k ohms x 10 pF = 10Ás, roughly.

    analogRead only gets to change the multiplexer immmediately before the reading, so doing two analogReads in a row after
    changing pins can cause dramatic improvement in the crosstalk.

  7. #7
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    626
    Agreed. My test was with about 1K input impedance. NXP suggests < 4K and that input capacitance is 1.3 pF.

Posting Permissions

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