Quote:
The resistance is measured by timing the discharge of a capacitor through the resistor (typically 5K to 50K). Scale is used to adjust for varying RC constants. For larger RC constants, Scale should be set low (a minimum value of one). For smaller RC constants, Scale should be set to its maximum value (255). If Scale is set correctly, Var should be zero near minimum resistance and 255 near maximum resistance.
Unfortunately, Scale must be determined experimentally. To do so, set the device under measure to maximum resistance and read it with Scale set to 127. Adjust Scale until the Pot command returns 254. If 255, decrease the scale. If 253 or lower, increase the scale.
Whats happening here is that your not measuring the voltage and then converting that analogue voltage into a digital value as per A to D convertion. The resistor charges the capacitor, which then discharges, which results in a negative going pulse on the pin. The frequency of this pulse determins the value of being stored in the variable (D in my example above). Here are some traces showing the pulse rate when D was 0, around 20 and at 255.