Arduino - CapacitanceMeter
Arduino - CapacitanceMeter
CC)
- TC = R * C
- TC = time constant in seconds
- R = resistance in ohms
- C = capacitance in farads (1 microfarad [ufd] = .0000001 farad = 10^-6 farads )
The voltage at 1 Time Constant equals 63.2% of the charging voltage.
Experimental Setup
This sketch works because the Arduino pins can be in one of two states, which are electrically very
different.
- Input State (set with pinMode(pin, INPUT);)
- High Impedance (resistance) - Makes very little demand on the circuit that it is sampling
- Good for reading sensors but not lighting LED's
- Output State (set with pinMode(pin, OUTPUT);)
- Low Impedance - Can provide 40 mA source (positive voltage), or sink (negative voltage)
- Good for lighting LED's, driving other circuits - useless for reading sensors.
Additionally the pins can be HIGH (+5 volts), to charge the capacitor; or LOW (ground) to discharge the
capacitor
Arduino Sketch
/* RCTiming_capacitance_meter
* Paul Badger 2008
* Demonstrates use of RC time constants to measure the value of a capacitor
*
* Theory A capcitor will charge, through a resistor, in one time constant,
defined as T seconds where
* TC = R * C
*
* TC = time constant period in seconds
* R = resistance in ohms
* C = capacitance in farads (1 microfarad (ufd) = .0000001 farad = 10^-6 farads
)
*
* The capacitor's voltage at one time constant is defined as 63.2% of the
charging voltage.
*
* Hardware setup:
* Test Capacitor between common point and ground (positive side of an
electrolytic capacitor to common)
* Test Resistor between chargePin and common point
* 220 ohm resistor between dischargePin and common point
* Wire between common point and analogPin (A/D input)
*/
void setup(){
pinMode(chargePin, OUTPUT); // set chargePin to output
digitalWrite(chargePin, LOW);
void loop(){
digitalWrite(chargePin, HIGH); // set chargePin HIGH and capacitor charging
startTime = millis();
- Substitute in larger resistors if the charging time is too short, smaller resistors if the charging time is
too long.
- Measure capacitors in parallel and in series, check to see if your observations agree with electronic
theory
- Average together a group of readings for more accuracy
- Swap out several charging resistors on different pins to make an "auto-ranging" capacitance meter
- Modify the sketch to have the charging resistor also discharge the capacitor. Note that the reported
value is not twice the value reported when it only charges this capacitor. Explain this. Hint - study
the changing curve on the graph.
Share
NEWSLETTER
(https://www.facebook.com/official.arduino)
(https://twitter.com/arduino)
(https://plus.google.com/+Arduino)
(https://www.instagram.com/arduino.cc/)
(https://github.com/arduino/)
(https://www.flickr.com/photos/arduino_cc)
(https://www.youtube.com/user/arduinoteam)