Hello Jackabo,
Firstly, I suggest that this thread is really a continuation of the earlier thread about your A/D problems, and might have been better handled as such. The following link is to the earlier thread.
What I did say then was, that a reduction of the input voltage range (to the comparator) would result in much improved linearity and resolution. This is not quite the same as accuracy.
The use of the lookup table, within the AN3266 code example, is to compensate for the non-linearity of the voltage-time characteristic of the CR circuit. Refering to the contents of the table, you will see that the first steps are 0, 5, 10 ... At the end of the table there are ten entries with the value 253. This represents substantial non-linearity, and with the initial steps of 5, this gives a resolution of 5/255 (less than 6-bits) for low input voltages, where high resolution is most important.
As previously outlined, the non-linearity can be reduced, and the resolution significantly increased by reducing the maximum voltage applied to the comparator input. However, to achieve this the time constant will need to be increased, as previously discussed, and the lookup table values would need to be re-calculated to cater for the reduced non-linearity over the new input voltage range.
To cater for higher measured voltages (perhaps in the vicinity of Vdd, or even higher), you would need a voltage divider to reduce the input range down to the comparator input requirement. The scaling of the divider will directly affect the calibration of the measurement.
Note that this method uses Vdd as a "reference", so you cannot actually directly measure Vdd voltage (it is assumed that Vdd would be fed from a regulator). For cases where Vdd is supplied from an unregulated battery source, a different strategy would be required.
An alternative scenario - if the capacitor were to be fed from an accurately controlled, external constant current source, rather than a resistor, the voltage-time characteristic would be linear, and the lookup table would not be necessary. If the constant current were to be independent of Vdd, you could actually measure the Vdd voltage (still using an appropriate input voltage divider).
Regards,
Mac
Message Edited by bigmac on 2007-04-1203:36 PM