Skip to main content

Subsection 6.3.2 Source Resistance and Sampling Time

The ADC does not measure a voltage without drawing anything from it. Inside the converter is a small capacitor that must be charged up to the input voltage before the successive approximation can begin, and it charges through whatever source you have connected, through the potentiometer’s track, or through a sensor’s own output resistance.
That charging happens inside a fixed window: the sampling time, set by SMP1[2:0] in ADC_SMPR and left at its shortest setting throughout this chapter. Note what this does not depend on: how often you take a reading. Sampling once a second rather than a thousand times a second gives the capacitor no extra time on any individual conversion, because each conversion gets the same window. If the source cannot charge the capacitor within that window, every reading comes back low by an amount that does not average away.
The datasheet’s Maximum ADC RAIN table is the lookup, where RAIN is the resistance of whatever you have connected to the pin: it gives the largest source resistance the converter tolerates for a given sampling time and resolution. Read it carefully, since the table is indexed at a 35 MHz ADC clock, so a given number of sampling cycles buys you nearly three times as long at the 12 MHz clock this course runs. A 10 kΩ potentiometer presents its worst case at mid-travel, where the two halves of the track are in parallel: about 2.5 kΩ. That is enough to cost a few counts, which is invisible on a knob you are turning by hand and very visible on a sensor you are trying to trust. The fix is to lengthen the sampling time, not to sample less often.