Author Topic: Most accurate way to use a microcontroller to measure capacitance?  (Read 14219 times)

0 Members and 1 Guest are viewing this topic.

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
I been Twin-T'ing around and I find I am having a bit of tweek burnout to get my Twin-T's to tune.
I don't have any fancy equipment, except for a good o'scope and a 3-digit DVM, but the better I can determine the precise value of a sub-uF cap, the more time I can spend at the beach. I got precision 1% resistors and lotsa common opamps, many other ics on hand, a big pile of PCB's to steal parts from, if needed.

What are you ideas of the best way to accurately measure the value of a poly-film or npo/cog or other low delta C/deltaV, low temp coeff. quality capacitor? 

My goal is to capture the C value to .1% but I could settle for a little less, if I get more time on the beach.

I need to measure values from 'bout .2uf down to maybe 50pf or so.

I don't wanna buy any equipment! I need the money to pay for the gas to get to the beach and I could use a new bikini.
« Last Edit: May 08, 2018, 02:08:03 pm by SuzyC »
 

Offline elecman14

  • Supporter
  • ****
  • Posts: 169
  • Country: us
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #1 on: May 08, 2018, 01:25:49 pm »
You could use an RC circuit and measure the rise time. The R value would have to be fairly large for a small value cap. If you want to implement this with a microcontroller you could start injecting the signal, start a timer and then use a comparator to figure out when you reached the desired charge level and shut off the timer.  You also could do this on your scope if you did not want to build anything.
 
The following users thanked this post: SuzyC

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #2 on: May 08, 2018, 01:28:16 pm »
What kind of syringe do I need to inject a signal? What accuracy could I expect? Turns out that making accurate measurements isn't so easy if the effect/precision of measuring equipment adds uncertainty/error to the result. If the values of the resistors are large, then the effect of probing this test setup would also be large, not to mention cleaning syringes, noise, etc.

For instance, a CMOS 555 timer can vary 1% in freq (that's the spec.) with supply voltages changing from 5 to 15V.

I would need to calibrate this kinda thing.
« Last Edit: May 08, 2018, 02:05:43 pm by SuzyC »
 

Offline oldway

  • Super Contributor
  • ***
  • !
  • Posts: 2172
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #3 on: May 08, 2018, 02:20:13 pm »
Lower cost without buying any equipment ?

Start with the simplest oscillator using a Cmos version of 555.

http://ramon-electronica.blogspot.be/p/555.html

C1 is the capacitor you want to measure.
R1 is a high stability resistor choosen so the 555 max frequency of oscillation is about 200Khz with the lowest value of C1 you want measure.

You use your µc to measure the frequency of oscillation and you calculate de value of C1.

You make a calibration with a high precision capacitor of known value.

It's very important that the square voltage applied to R1 goes very near of Vdd and of GND.

You can't use output pin 3 of 555 directly....use the 6 buffers of a 4050B in parallel.

Power supply does not need to be a very high stability one.

Preferred Vdd voltage for 555 and 4050B : 12V
 
The following users thanked this post: SuzyC

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #4 on: May 08, 2018, 03:08:44 pm »
555 timers? LOL   :-DD

Note that quite decent LCR meters like 1700 series of Keysight have 0.2% capacitance accuracy and low frequency (< 10 KHz) models goes down to only 200pF.
 
The following users thanked this post: SuzyC

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14367
  • Country: de
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #5 on: May 08, 2018, 03:14:36 pm »
There are some projects around to use the sound card interface of a PC to use it as a kind of low frequency component tester to measure LCR. It does not need much hardware (mainly a few resistors, diodes for protection), but quite a bit of software.  So if one can find a free software version of this, that works with an existing PC, this would be a cheap and surprisingly accurate way. However not all sound-cards are compatible with all such software.

In principle one could build a similar way system around an µC: create a sine or triangular wave and measure the response of resistor and DUT in series with the usual µC internal ADC. Not as high resolution as the soundcard, but possible. Still quite some software to write.

The timer/ oscillator version usually need a capacitor for calibration. The resolution can be very good, but accuracy may be limited, as the usual design equations are often of limited accuracy and parasitic effects can change with a variable frequency.
 
The following users thanked this post: SuzyC

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #6 on: May 08, 2018, 03:32:48 pm »
Ogden, you gotta realize that sometimes even the supposedly best in the biz don't do their best! No big money ins selling cap testers.

Kleinstein, I donno, seems kinda iffy to work at all.

I have a bunch of 2200pF +/- 2.5% (quan 6) 3300pf 2.5% (quan 2) and 20000pf 2% (quan35+)

Even when I search Mouser, precision caps are mostly in the 0-20pF range and intended to work in the GHz range, larger valued precision caps are few and far between, with 2% the best precision available.  Besides, would take some days to get them.

Calibration is everything. I have not a capacitor that is without some large blemish of precision compared to the .1% target goal.

What Ifs:
 I have many different values 1% resistors and a CMOS 555 running with a tightly regulated 5V supply, would I then be able to measure the 555 output astable freq. by counting 62.5nS timer ticks on a MCU to determine the freq to calc value of the DUT cap to 1%???

What would Mike Faraday do. He developed his knowledge about capacitance without little more than a Lyden Jar, a tall stack of Volta  voltage cells, and a galvanometer to work with.

Common guys..we should be able to do better than this!



« Last Edit: May 10, 2018, 02:04:29 am by SuzyC »
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #7 on: May 08, 2018, 04:08:57 pm »
At least somebody can do it!

Can do .01%
« Last Edit: May 08, 2018, 04:14:53 pm by SuzyC »
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #8 on: May 08, 2018, 04:16:17 pm »
Ogden, you gotta realize that sometimes even the supposedly best in the biz don't do their best! No big money ins selling cap testers.

Oh come on. There's huge money in industrial equipment. How do you think capacitors are manufactured?

You can check yourself. No 555 timer here:

 
The following users thanked this post: SuzyC

Offline phenol

  • Regular Contributor
  • *
  • Posts: 146
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14667
  • Country: fr
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #10 on: May 08, 2018, 05:07:21 pm »
Ouch, measuring such a wide range of capacitance with an error of only 0.1%, and this with just a few cheap parts and no specialized equipment? You seem to like the beach a bit too much.  :-DD

A simple RC oscillator structure will not cut it. Unless maybe you can calibrate it properly AND very frequently (like between each measurement), because it will drift over time and temperature.

You could be a little better off with a very good signal generator (meaning very low distortion), generating a sine and make a simple RC filter with your unknown cap and a reference resistor, and then calculate the capacitance based on the attenuation between input and output, this with a precision multimeter in AC (don't use a scope for precise amplitude measurements, it's not the right tool for this at all).
A good sound card for the signal generation would work fairly well with frequencies in the audio range. Still, with a low or middle-end multimeter, you probably won't get enough precision in AC mode to get the precision you require on the capacitance evaluation.

One approach that may get you something in the 1% error range (maybe a bit lower if you can measure precisely the reference current source and the reference voltages) could be with a current source as attached. You'd measure the charging time between two known reference thresholds (which allows you not to worry about amplitude measurement precision, again a scope would not cut it for that). The time elapsed between the rising edges of the 2 comparators outputs (Tr2- Tr1) will allow you to compute the capacitance, and can be measured with a scope (which is an accurate instrument for time measurements) or a microcontroller. You need two fast and low offset comparators, the LT1720 would work. For discharging the cap, a manual switch with very low parasitic capacitance will work. A MOSFET would add parasitic capacitance and should be avoided. The TI REF200 current source ref. is great and not too expensive.

May look convoluted, but it's still simple and would be cheapish to build, need only a few parts and IMO be much more accurate than oscillator-based setups.
 

Offline Conrad Hoffman

  • Super Contributor
  • ***
  • Posts: 1944
  • Country: us
    • The Messy Basement
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #11 on: May 08, 2018, 05:24:10 pm »
All you kids need a uP to accomplish anything! If you can get one capacitor measured, a traditional bridge will do the trick. People are scared of them, but it's just a handful of parts and can be built in a couple hours. A couple minutes if you cobble things together with jumpers and alligator clips. See- http://www.conradhoffman.com/cap_bridge.pdf

Since you're doing films, dissipation factor will be too low to bother with, so you can eliminate that pot if you want.
 
The following users thanked this post: SuzyC, Wimberleytech

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 7547
  • Country: 00
  • +++ ATH1
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #12 on: May 08, 2018, 06:10:24 pm »
My goal is to capture the C value to .1% but I could settle for a little less, if I get more time on the beach.

I need to measure values from 'bout .2uf down to maybe 50pf or so.

I don't wanna buy any equipment! I need the money to pay for the gas to get to the beach and I could use a new bikini.

All your very demanding requirements need less bikini & beach and more time on brain.

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 7547
  • Country: 00
  • +++ ATH1
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #13 on: May 08, 2018, 06:12:09 pm »

Calibration is everything. I have not a capacitor that is without some large blemish of precision compared to the .1% target goal.

What Ifs:
 I have many different values 1% resistors and a CMOS 555 running with a tightly regulated 5V supply, would I then be able to measure the 555 output astable freq. by counting 82.5nS timer ticks on a MCU to determine the freq to calc value of the DUT cap to 1%???

How do you know that your 82.5ns there is accurate down to 0.1% ?

May be its only 75ns or even 95ns ?

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 7547
  • Country: 00
  • +++ ATH1
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #14 on: May 08, 2018, 06:14:43 pm »
At least somebody can do it!

Can do .01%

For sure they are not done using few cheap 555 ic and few bucks of component in hand to able to make that kind of capacitor.

Probably they sacrificed lots of their beach time and bikini time too to able to make that kind of stuff, have you ever thought of that ?

Offline kripton2035

  • Super Contributor
  • ***
  • Posts: 2627
  • Country: fr
    • kripton2035 schematics repository
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #15 on: May 08, 2018, 07:14:31 pm »
here on my repository you can get some schematics of various C meters.
http://kripton2035.free.fr/lcr-repository.html
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16772
  • Country: us
  • DavidH
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #16 on: May 08, 2018, 08:02:00 pm »
For accuracy, I would avoid any design which involves a fixed reset or commutation period within the frequency control loop which includes all common 555 designs.  This fixed period produces a non-linearity in the measurement due to its finite delay and inconsistent capacitor reset.  Well designed analog function generators which use compensation to ameliorate this problem do not achieve the kind of open loop linearity required for this level of accuracy.

Charge balancing voltage-to-frequency converters can get down to the 0.0005% linearity or better so they are a candidate but measuring up to 0.2uF could be a problem; they typically use a 1000pF for their reference which implies measurements up to 0.01uF.

What I would probably try given the constraints is using the capacitor in an integrating circuit where the microcontroller either makes time measurements between two voltage thresholds or sampled voltage measurements.  Either will allow calculation of the slope and then dI/C = dV/dT and multiple measurements can be used to average out noise.  With some care, I think 1 part in 20,000 is possible so 50pF parts could be measured to 0.1% using a 1000pF range.  This duplicates how the CTMU (charge/time measurement unit) on some Microchip PIC microcontrollers works.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #17 on: May 08, 2018, 09:20:25 pm »
A cap is an RLC really. And if you dig even deeper then this could be a nonlinear device where C depends on the frequency. So it is a matter what is the purpose of that measurement.
If your design needs 0.1% tolerance cap then it is most likely a poor design. Redesign it so that there is no need for such tight tolerance.



 
The following users thanked this post: SuzyC

Offline hugo

  • Regular Contributor
  • *
  • Posts: 167
  • Country: ca
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #18 on: May 09, 2018, 01:32:03 am »
Not exactly what you've asked but close enough ...  ;)

https://www.romanblack.com/onesec/CapMeter.htm

This is a high resolution (0.01pF), PIC based, cheap capacitance meter (0pF to 50uF range).
 
The following users thanked this post: jneudorf

Offline Conrad Hoffman

  • Super Contributor
  • ***
  • Posts: 1944
  • Country: us
    • The Messy Basement
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #19 on: May 09, 2018, 03:26:11 am »
With small cap values you need to understand the difference between two and three terminal measurements. A GR standards bridge will measure small fractions of a pF, but to get any sensible results you need the capacitor mounted in a shield and set up for a three terminal measurement. Up to 100 pF or so you have to worry about that stuff. There are lots of references, but this one seems as good as any- http://nla.org.za/webfiles/conferences/2015/T+M%202015%20Presentations/Tuesday,%2013%20October/T205%20Capacitance%20and%20inductance%20measurements%20using%20an%20LCR%20meter.pdf
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #20 on: May 09, 2018, 11:48:31 am »
Oldway: I don't quite understand why all the extra buffers. Are you suggesting to buffer the output of the simple astable 555 circuit that feeds the squarewave output back to the the capacitor connected directly to the 555?

Seems like a good idea to remove the load from the timer's output to prevent this influence on the internal comparators that determine the frequency of astable oscillation.

But in every case, dealing with cap vals from .2 to 50pF, using the largest resistor would lower the output frequency to give a longest period to measure with the most resolution  when using a MCU internal timer peripheral counting 62.5nSec internal timer ticks.
So, in this case, having to buffer the output of the 555 seems to be useless.

I am assuming here using a MCU that operates its HFINTOSC of 64MHz which corresponds to 16mSec instruction clock, although the internal peripheral timer clock can be the 64MHz clock.

Using any MCU means there will be jitter in measurements due to inherent IRQ and HFINTOSC  jitter, but it is certainly possible for this jitter be averaged out to minimize this source of error. The final measurement value would be obtained by averaging many measuring results.

With a 16-bit timer, the resolution of a raw max period measurement of  555 osc. could be as good a very tolerable one count ambiguity of 62.5nsec.  Assuming the 555 oscillates using a precision resistor and the DUT for timer, it means the largest valued resistor would be chosen to max out the counter resolution of the internal MCU timer.

Why wouldn't this idea work?

Why wouldn't the CMOS 555 timer, with a tightly regulated supply voltage, well bypassed,  be well suited to do a very good job here?

What is the problem the using a CMOS 555? What would be compromising in its design to be capable of introducing error?

As with any precision capacitance measuring device, whether its made by Gen Radio, Agilent or by using a 555, calibration and comparison with a known standard would be a must.

The only problem I have would be to make a few of my own "calibration standard" capacitors values using the timing resistor's precision itself to determine its value to better than  .1%.  I can fairly easily find .02% or better timing resistors.
« Last Edit: May 09, 2018, 12:09:25 pm by SuzyC »
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #21 on: May 09, 2018, 12:08:11 pm »
BravoV:  I know the exact freq. because it is derived from the very precise crystal connected to external clock input  of the MCU and this precise system clock is used by the MCU for its timer peripherals.


 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #22 on: May 09, 2018, 12:13:08 pm »
Brutte:

In a Twn-T circuit, stresses on a capacitor are minimal. The parasitic properties of the film capacitors to be measured and use would not be significant in sub-kHZ notch filter design.
« Last Edit: May 09, 2018, 12:50:08 pm by SuzyC »
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #23 on: May 09, 2018, 12:16:10 pm »
ogden: I am sure Signalent is not doing its best work here, .2% is almost laughable as a  measurement limit. Look what Gen Radio and others can do.
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Most accurate way to use a microcontroller to measure capacitance?
« Reply #24 on: May 09, 2018, 12:22:42 pm »
SiliconWizard:  Thank you for your help, but in MHO, this approach seems very inappropriate to solve this measurement problem since it involves so much complexity that can introduce measurement errors and this method requires very expensive lab equipment to precisely measure attenuation.

Adding cost and complexity doesn't necessarily ensure the outcome of best results or that a solution to the problem cannot be achieved in a very much simpler, less costly manner.
« Last Edit: May 09, 2018, 12:28:49 pm by SuzyC »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf