0
\$\begingroup\$

I am trying to measure capacitances using an Arduino UNO.

Schematic

The C pin charges the capactitor through a 10K resistor (I have also tried 100K and 220), and the G pin discharges it.

V_A and V_B are measurement points across the 10K resistor.

The program does the following:

discharge_capacitor()
while v_b < 4.0V:
    t1 = get_time()
    pin C = HIGH
    dv_1 = v_b - v_a
    wait_a_bit()
    dv_2 = v_b - v_a
    pin C = LOW
    t2 = get_time()
    t = t2 - t1
    calc. q (q = I*t; I = V/R; V is the avg. of dv1 and dv2)
    total_charge += q
capacitance = total_charge / last_measured__v_b
print(capacitance)

I.e. it calculates the charge that goes into the capacitor.

It can measure capacitances of 1 and 3 uF with pretty high accuracy (for my purposes), but it outputs 0 nF when I'm trying to measure 470 uF caps. What could be the problem? Am I doing everything completely wrong?

\$\endgroup\$
2
  • \$\begingroup\$ The problem turned out to be in software, not hardware. Mostly, because some resistors were up to 20% off, and electrolytic caps are even worse. Everything works fine now, and I only get accurate results with the v_b threshold voltage of 4V or bigger. \$\endgroup\$ Commented Jul 24, 2018 at 13:32
  • \$\begingroup\$ You don't need external FETs for this at all. The problem is solved in demo form on the Arduino site's examples and in fairly productized form in the online docs for the JYE tech kit. \$\endgroup\$ Commented Jul 24, 2018 at 14:54

2 Answers 2

3
\$\begingroup\$

A 470 uF will be likely an electrolytic type and this will have a leakage current in the order of 1 to 10 uA per microfarad, Assuming 1 uA is the figure then the total leakage will be 470 uA and this will cause a volt drop (irrespective of capacitance value) across the 10 kohm resistor of 4.7 volts and your algorithm will probably never really perform properly.

\$\endgroup\$
4
  • \$\begingroup\$ Thanks, this is probably the case. Is this method better? \$\endgroup\$ Commented Jul 24, 2018 at 12:18
  • \$\begingroup\$ I don't know, why not try it? It does appear to assume that there is no leakage so probably not. \$\endgroup\$
    – Andy aka
    Commented Jul 24, 2018 at 12:20
  • \$\begingroup\$ Try while v_b < 2.5V so that Vgs can be >> Vt for low RdsOn \$\endgroup\$
    – D.A.S.
    Commented Jul 24, 2018 at 12:51
  • \$\begingroup\$ @int6h You could modify your code so that it tests for a steady state voltage indicative of high leakage and inform the "operator" of this. Similar to what Tony suggests but for a steady state situation. High leakage can scupper decent capacitance measurements. \$\endgroup\$
    – Andy aka
    Commented Jul 24, 2018 at 14:03
0
\$\begingroup\$

You are testing at v_b < 4V, so I assume you are using an NFET with Vt<1V.

Vt is often defined as the 1mA conduction threshold, when you want the top FET to conduct much faster, its gate voltage should be greater than supply or drop Vd by 2 diode drops and test at a lower threshold.

Or better yet, change statement to test from 0 to 2.5 to 3V

  while v_b < 2.5V:

Use different Rs values for auto scaling to get measurement counts in an appropriate range with selectable CMOS switches.

An automatic auto-scaling method might use a constant dt method by adjusting RdsOn so get a constant d(v_b)/dt by differentiating it to get say dV/dt= 50m~100mV with a closed loop to control Vg using a PFET with a much smaller Rs.

then C=Ic / constant dV/dt then average this.

\$\endgroup\$
6
  • \$\begingroup\$ The fet datasheet claims that Vt is 0.8..3 V with the typical value of 2.1V. It turns out I have actually screwed up with the code and didn't read v_b before the while loop. Thanks for the improvement advice. \$\endgroup\$ Commented Jul 24, 2018 at 13:11
  • \$\begingroup\$ then why v_b<4V? use a Pfet or lower the measurement voltage interval \$\endgroup\$
    – D.A.S.
    Commented Jul 24, 2018 at 13:13
  • \$\begingroup\$ Threshold voltage of less than 4V gives me inaccurate results, off by >50%. \$\endgroup\$ Commented Jul 24, 2018 at 13:34
  • \$\begingroup\$ Print each result and debug. It not the best way. Regardless where measurement time varies with C , bugs with overflow counter? If Vt was 2.1V V_b never reaches 4V \$\endgroup\$
    – D.A.S.
    Commented Jul 24, 2018 at 13:42
  • \$\begingroup\$ External FETs are an entirely unnecessary complication of this task. \$\endgroup\$ Commented Jul 24, 2018 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.