I have been experimenting with the Arduino's ADC, and I have noticed some bizarre behaviour. I am wondering if it is normal, or if this is something specific (and bad) about the Atmel ATMEGA328P that the Uno is based around.
Basically, it would appear that the input value on the ADC is sampled at a lower rate than the ADC is actually returning values for:
In this image you can see the sampled input running at full speed connected to a simple pot. As the pot is swept from full to minimum the input voltage drops. As you can see the returned values from the ADC come in steps, where it returns the same (or similar) value for multiple calls to
analogRead(), before then dropping down sharply.
What is actually going on here? Is the ADC input running at a different speed to the data output? Is the Arduino code reading the ADC wrong?
I have tried playing with the ADC pre-scaler, and no matter what I set it to (apart from 1:2 or 1:4, where it dies completely) it reads in steps like this.
It takes about 32 successive ADC reads for the steps to completely disappear.