Arduino Capacitance Meter

firepinto

Arduino Capacitance Meter
« on January 23rd, 2014, 06:13 AM »Last edited on January 23rd, 2014, 06:16 AM by firepinto
This looks interesting:

http://hackaday.com/2014/01/22/capacitance-measurement-with-the-arduino-uno/#more-113173

http://wordpress.codewrite.co.uk/pic/2014/01/21/cap-meter-with-arduino-uno/

http://wordpress.codewrite.co.uk/pic/2014/01/21/arduino-cap-meter-res/

Wonder if this would work for measuring a WFC?


Here is the Arduino code:
Code: [Select]

const int OUT_PIN = A2;
const int IN_PIN = A0;

//Capacitance between IN_PIN and Ground
//Stray capacitance is always present. Extra capacitance can be added to
//allow higher capacitance to be measured.
const float IN_STRAY_CAP_TO_GND = 24.48; //initially this was 30.00
const float IN_EXTRA_CAP_TO_GND = 0.0;
const float IN_CAP_TO_GND  = IN_STRAY_CAP_TO_GND + IN_EXTRA_CAP_TO_GND;
const int MAX_ADC_VALUE = 1023;

void setup()
{
  pinMode(OUT_PIN, OUTPUT);
  //digitalWrite(OUT_PIN, LOW);  //This is the default state for outputs
  pinMode(IN_PIN, OUTPUT);
  //digitalWrite(IN_PIN, LOW);

  Serial.begin(115200);
}

void loop()
{
  while (1)
  {
    //Capacitor under test between OUT_PIN and IN_PIN
    //Rising high edge on OUT_PIN
    pinMode(IN_PIN, INPUT);
    digitalWrite(OUT_PIN, HIGH);
    int val = analogRead(IN_PIN);

    //Clear everything for next measurement
    digitalWrite(OUT_PIN, LOW);
    pinMode(IN_PIN, OUTPUT);

    //Calculate and print result

    float capacitance = (float)val * IN_CAP_TO_GND / (float)(MAX_ADC_VALUE - val);

    Serial.print(F("Capacitance Value = "));
    Serial.print(capacitance, 3);
    Serial.print(F(" pF ("));
    Serial.print(val);
    Serial.println(F(") "));

    while (millis() % 500 != 0)
      ;    
  }
}



Nate

Matt Watts

RE: Arduino Capacitance Meter
« Reply #1, on January 23rd, 2014, 11:25 AM »Last edited on January 23rd, 2014, 11:28 AM by Matt Watts
Quote from firepinto on January 23rd, 2014, 06:13 AM
Wonder if this would work for measuring a WFC?
I would think you could do a much better job with a scope and a box of resistors.  Even so, you still need to find the capacitance at high voltage, high frequency, low duty cycle for the value to be of much use.

Something you might be able to do though is substitute the water for oil.  Once you find the value with oil, you know the physical dimensions of the cell won't change, so then with a simple matter of changing the dielectric constant, you can calculate what the cell should be when you put water into it.  Funny I never heard anyone mention this before.  Maybe I just wasn't listening.