EKMallon:
I'd like to play around with some DIY capacitor sensors, and in my background reading I've come accros this apparently simple method to measure capacitors with an arduino:
Capacitance measurement with the Arduino Uno
Capacitance measurement with the Arduino Uno | PIC Tutorials
Capacitance Meter Mk II (for larger value capacitors)
Capacitance Meter Mk II | PIC Tutorials
What I don't understand about the method is why the charge & discharge cycles don't kill the Arduino pins? This was even posted on hackaday, and no one there said anything about hurting the IO pins, but it looks to me like a recipe for inrush and discharge currents that exceed the 40ma limit for IO pins...?
What am I missing?
It tries.
The success of this circuit depends on the robustness of the output stages in the AVR chip. Without some current limit, the current flow is equal to the output resistance. The output transistors usually fail when they overheat. Heat is IIR.
The Output pins are rated at 40mA continuous. With a total package dissipation of 200mA thru (GND +VCC).
an Amp is a coulomb/second.
an Farad is a coulomb/volt.
so a 100_nf or(0.1_uf) at 5_V will store: coulomb=VF, or 50.0000001 coulomb or 5x10^-7_C.
So, with 40_mA of capacity what is the shortest time we can discharge this energy?
40_mA = (5E-7_C)/X_sec
0.040A/5E-7_C= 1/X_sec
X_sec = 5E-7_C/4E-2_A
X_sec = 1.25E-5_sec or 12.5us
From that link, he is only measuring caps from 15_pF to 1300_pF or 15E-12_F to 1.3E-9_F
If I use his largest capacitor the X_sec becomes 32.5E-9_sec or 32.5_ns.
The article states:
... capacitor voltage will settle to within 1% of it's final value in 30_ns.
I question this statement: Unless he was using superconductors, more time is needed.
Based on the small capacitance and only cycling every 1/2 second, the output stage in the chip doesn't have enough time to heat up to catastrophic levels.
His design for the larger capacitors 1_uF to 1000_uF limits the current using the internal pullup resistors. This 30k to 50k resistance limits the charge currents to between 166.7E-3_mA and 100E-3_mA.
BUT, when he starts his tests, he first treats the cap as if it were a pF value, discharges/Charges with digitalWrite(OUT_PIN,HIGH); digitalWrite(OUT_PIN,LOW);
If this test fails, he tries the pullup resistor test.
This is unsafe.
The only reason the AVR chip survives, is that there is some internal resistance in the pin circuit.
Chuck.