Teensy 4.1 Analog Input Internal Resistance

Status
Not open for further replies.

Gnav

New member
When I try to measure the voltage on a 10k potentiometer (with analogRead) I find the reading misses some values around the half-way mark.

eg. If the pot is slowly turned up the readings suddenly jump from around 522 to 546. Then when turning the pot down the readings jump from 526 to 502.

There seems to be a hysteresis effect going on.

Further investigation showed that the internal resistance of the input changes at around half-scale.

If a good quality bench power supply is used in place of the 10k potentiometer the missing values effect does not happen.

Introducing a series resistance to the bench power supply feed shows that any resistance of more than about 250ohms produces a noticable jump in reading getting worse with increasing resistance.

The effect occurs on at least A0, A1, A2 & A3 and is a genuine drop in voltage as it can be measured with a DVM on the Teensy input pin.

Does anybody else notice this? Is there a way around it? (I can't change the potentiometer to a lower resistance type as it is built-in to my project.)



// LISTING:


int analogPin = A0; // potentiometer wiper to analog input pin
// outside leads to GND and 3V3
long val = 0; // variable to store the value read

void setup() {
}

void loop() {
val = analogRead(analogPin); // read the input pin
Serial.println(val);
delay (200);
}


CCT.jpg
 

Attachments

  • CCT.jpg
    CCT.jpg
    69.6 KB · Views: 27
There was a recent thread about this. Try pinMode (analogPin, INPUT) in your setup() and see if that
turns off the hysteresis circuit on the pin.
 
Status
Not open for further replies.
Back
Top