The routines described here read the position of a potentiometer by a ratio technique. The measured value is scaled to a value between 0 and max, using a successive approximation technique.
The two halves of the pot are measured and the two measured values are added togther to get the range. These values vary due to component tolerences and variation in supply voltage. However these are greatly nullified by the scaling routine.
Starting with the measured value of range, it is itterated down to the measured value of B. The same itteration decisions are applied to Max value, resulting in value so that:
value = MaxValue * B / range
Tests show that the ratio: ( value / position of Pot ) can be much more accurate than the component tolerences would suggest. The values of A and B are measured by the circuit here.
After discharging the capacitor by making RTCC/RA4 a low output, the capacitor is then charged by making RTCC/RA4 an input and either RA2 or RA3 is made an output set to logic 1, ( The other pins are made inputs. ) A counter is started and when RTCC / RA4 gets to logic 1, the counter is sampled.
The RTCC or RA4 is an input with threshold of 0.8Vdd, so gives the longest count for a given Time constant.
http://www.btinternet.com/~doug.h.rice/vtmr/read_pot.htm