> You've pointed out the main problems with the simple RC design ... the > exponential ramp, and the inconsistencies in the threshold voltage of the > PIC's input mean that the AN513 A to D can never be very linear, stable, or > precise. A possible solution may be to use a dual opamp, with one section > used to create a constant current source to linearize the charging of the > integrating capacitor, while the other section is used as a comparator. One design I prefer, which I've mentioned a few times but never received feedback about, uses just a comparator and an RC (on the 16C62x it uses three port pins if you use the internal comparator; if you use an external comparator it uses two). The signal to be measured should be fed into one input of the comparator (I'll assume non-inverting for now) and the output of that comparator should feed a port pin. The other port pin should go into an RC filter; the output of that filter should feed the inverting in- put of the comparator. To measure the input, just run the following procedure about 10,000 times/sec or so: static int16 hicount, samples, measurement; { if (input_pin) { output_pin = 1; hicount++; } else output_pin = 0; samples++; if (samples >= 5000) { measurement = hicount; hicount = 0; samples = 0; } } Measurement will hold the current measured value in milivolts (0-5000) and will be updated about twice per second. Note that the measurement procedure must be called at a consistent rate (which should be much faster than the RC rate) and that the measurements will only be as precise as the VDD level. On the other hand, this is a very cheap way of getting fairly precise (but slow) measurements that seems much more stable and noise-resistant than many RC methods; because the software feeds the sampled comparator readings back into the comparator circuit, a false-high reading on one sample will increase the likelihood that the next reading will be low.