I am getting unexpected jumps in ADC data when varying the input voltage using a potentiometer (data is pictured). I have tested with two teensy 3.1 boards and several potentiometers and other voltage sources and all show the same behavior. The analog value jumps at the same time the digital value of the pin would change (confirmed later, below). What do I have to do to get the ADC to act like a normal analog input and vary smoothly, without the gaps?
Data:
Zoomed in:
Hardware:
Teensy 3.1 (The mask revision is 2N36B which does have ADC related errata (pdf) but nothing like this error)
10k potentiometer from AGND to 3V, with the wiper measured on A9 (pin 23)
Software: Arduino 1.0.5, Teensyduino 1.19, Windows 8.1
Code:
Procedure:
Move the potentiometer around a few times and then plot the data.
Expected result:
The data should vary smoothly from end to end.
Actual Result:
There are jumps in the data at certain values based on whether the data is rising or falling.
---
Reading the pin as a digital input confirms that the jumps happen when the digital value changes.
When the data is plotted the digital transitions align with the analog jumps.
Blue is the analog read value (0-1023) and green is the digital value shifted vertically and scaled to be visible. The analog jump matches the transition, or the next reading occasionally, as expected for both the rising and falling transitions.
Data:
Zoomed in:
Hardware:
Teensy 3.1 (The mask revision is 2N36B which does have ADC related errata (pdf) but nothing like this error)
10k potentiometer from AGND to 3V, with the wiper measured on A9 (pin 23)
Software: Arduino 1.0.5, Teensyduino 1.19, Windows 8.1
Code:
Code:
const int readPin = A9;
void setup()
{
pinMode(readPin, INPUT);
Serial.begin(9600);
}
void loop()
{
Serial.println(analogRead(readPin), DEC);
Serial.send_now();
delay(1);
}
Procedure:
Move the potentiometer around a few times and then plot the data.
Expected result:
The data should vary smoothly from end to end.
Actual Result:
There are jumps in the data at certain values based on whether the data is rising or falling.
---
Reading the pin as a digital input confirms that the jumps happen when the digital value changes.
Code:
const int readPin = A9;
void setup()
{
pinMode(readPin, INPUT);
Serial.begin(9600);
}
void loop()
{
Serial.print(analogRead(readPin), DEC);
Serial.print(", ");
Serial.print(digitalRead(readPin), DEC);
Serial.println("");
Serial.send_now();
delay(1);
}
When the data is plotted the digital transitions align with the analog jumps.
Blue is the analog read value (0-1023) and green is the digital value shifted vertically and scaled to be visible. The analog jump matches the transition, or the next reading occasionally, as expected for both the rising and falling transitions.