Hi Roman,
Thanks for posting your excellent article on measuring capacitance. The way I was doing it required different ranges (from 1k to 1M resistors) depending on the capacitor inserted. I do have some questions though. I am trying to use your schematic as much as possible, but I am using a 3.3v pic, 3x 2.21k 1% resistors, 10k 1% resistor and a graphical LCD. I am also using an external 24Mhz crystal. (this is all stuff I already have).
I am confused because the way I used to do it I would use 2 resistors which gave me about 67% of the voltage and I would measure the time it took to go from 0 volts to 67% of VDD to calculate the capacitance. Your way gives much better resolution, speed and probably accuracy since you take hundreds of readings and average them. The time it takes to go from 0v to 67% of VDD was 1 time constant, but oscillating between .333% and .666% is waaay less, and I am having trouble figuring out the time constant and converting your math to work with my setup.
For example;
"10nF" cap, oscillates about 435Hz
218 consecutive periods are captured, a total of 2004597 counts
Math; (2004597*1000)/218 = 2004597000/218 = 9195399
(so the average period is 9195.399 counts)
A second process is used to convert that result to picofarads;
(9195399*100)/scale = 919539900/919 = 1000587
1000587 is then displayed as; 10005.87 pF
I don't understand what "scale" means, or why you multiply 9195399 * 100. What does the 100 represent? I was also wondering where you take into account the 10k resistor? What if I used a different value resistor, like a 1% 7k resistor. What changes in your code would I need to make to use the 7k resistor instead of the 10k? I actually have a 1.024k resistor and was thinking of ranging between 1.024k and 10k so I could measure very large capacitors. If you could shed any light on these issues I am having, that would be great. Otherwise I will eventually figure it out. Keep on posting your projects if you would. I notice your website is not update quite as often as it used to be. Do you just not have many new projects going or not have the time to update your website with them?
Thanks,
James