-->
Page 1 of 3

Measuring capacitance

PostPosted: Fri Feb 24, 2017 2:36 am
by ardhuru
I wonder if there's a way to measure an external capacitance of a few 10s of pf by indulging in some I/O manipulation trickery?

I'm hoping there is, because on the pics, using the Picbasicpro compiler, there's a 'POT' command that reads the value of an external resistance *or* capacitor using any single digital pin.

Alternately, I could pop the capacitor into an astable 555 and measure its frequency, but I'm hoping to achieve this without the 555. I dont need super-accurate results.

Best Regards,

Anand

Re: Measuring capacitance

PostPosted: Sun Feb 26, 2017 6:48 am
by PhilTilson
Not sure how one would do this with one pin, but there might be a way with two!

Pin1 (output) connects to capacitor to be measured via a resistor. Pin 2 (A/D input) connects to top of capacitor.

Pin 1 goes high and charges capacitor via resistor. Pin 2 measures fully charged voltage. Pin 1 then goes low, discharging capacitor via resistor. Pin 2 detects when Vcap drops to 0.69 of original fully charged value. Then capacitor value can be found from t = 0.69CR.

Only problem is, with the kinds of value you mention, a 40pF capacitor with a 1Meg resistor would take around 28uS to discharge to that level, and I don't know any way of measuring periods that short using ESPbasic.

Which brings me to a general point for MM: the TIMER function is very useful, but only has a resolution of milliseconds. Is there any chance of getting a similar function for microseconds?

Re: Measuring capacitance

PostPosted: Sun Feb 26, 2017 11:00 am
by danbicks
PhilTilson wrote:Not sure how one would do this with one pin, but there might be a way with two!

Pin1 (output) connects to capacitor to be measured via a resistor. Pin 2 (A/D input) connects to top of capacitor.

Pin 1 goes high and charges capacitor via resistor. Pin 2 measures fully charged voltage. Pin 1 then goes low, discharging capacitor via resistor. Pin 2 detects when Vcap drops to 0.69 of original fully charged value. Then capacitor value can be found from t = 0.69CR.

Only problem is, with the kinds of value you mention, a 40pF capacitor with a 1Meg resistor would take around 28uS to discharge to that level, and I don't know any way of measuring periods that short using ESPbasic.

Which brings me to a general point for MM: the TIMER function is very useful, but only has a resolution of milliseconds. Is there any chance of getting a similar function for microseconds?


Phil should it not be 0.63 which is one time constant as opposed to 0.69 ?

Dans

Re: Measuring capacitance

PostPosted: Mon Feb 27, 2017 12:57 pm
by PhilTilson
Phil should it not be 0.63 which is one time constant as opposed to 0.69 ?

So it seems! :oops:

Funny how you have something in the back of your mind from years ago and it turns out to be wrong! Let's be nit-picky - 0.63212 !! :mrgreen:

I'm not even sure that the method would work, but it's worth a try.

Phil