Teensy4 ADC pin switching speed

Status
Not open for further replies.

kdharbert

Well-known member
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?
 
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.
 
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.
 
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.....
 
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.
 
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.
 
Agreed. My test was with about 1K input impedance. NXP suggests < 4K and that input capacitance is 1.3 pF.
 
Status
Not open for further replies.
Back
Top