DIY Capacitance Meter

Categories :

DIY Capacitance Meter

Hi all, Today article, I am going to discuss about how to make capacitance meter by your self. I use arduino platform and very few electronic components to make this meter.

 

What do you Need

 

What are the components that we need to make our meter.

  • Arduino Uno Board (If you think about cost about your meter, I recommend use Arduino nano board)
  • 220 ohm and 10K resistors.
  • 2 IC Bases for connect capacitors to the meter.
  • Vero Board
  • Soldering components
  • Jumper wires and connecting wires

 

This is the circuit diagram for the meter.

Solder external electronic components according to above diagram and connect those wires to your arduino board via jumper wires for take inputs and outputs.

This is arduino code 


int Selectingswitch=7;
int charge = 8;
int discharge = 9;
int analogPin = A0;
unsigned long start_timer=0;
unsigned long stop_timer=0;
unsigned long duration=0;
////////////////////////////////
float voltage=3;
float answer=0.0;
int measure (void);
/////////////////////////////////
///// for nf range /////
const int analog_charge = A2;
const int analogPin2 = A1;
float ck=24.42;
int voltage2;
float cu;
////////////////////////////

void setup()
{
Serial.begin(9600);

Serial.println("RANGE 1uF to 4700uF and 20pF<to>1000nF ");

Serial.println("place capacitors ");
pinMode(Selectingswitch,INPUT);

pinMode(discharge,INPUT);
pinMode(charge,OUTPUT);
digitalWrite(charge,HIGH);
pinMode(analogPin2,OUTPUT);
pinMode(analog_charge,OUTPUT);
}
//1021 1022 1023
void loop()
{
//largeCap();
//smallCap();
if (digitalRead(Selectingswitch)==HIGH){
Serial.println("RANGE 20pF<to>1000nF ");
smallCap();
delay(10);
}else {

largeCap();
delay(10);
}

}
////////////////////// for large caps////////////////////
void largeCap(){
Serial.println("place capacitor 1uf to 4700uf ");

while(measure()>=1010 && measure()<=1030){

if (digitalRead(Selectingswitch) ==HIGH){
break;
}
Serial.print("-");
delay(200);
}

delay(2000);

Serial.println(" ");
while(1){
if (digitalRead(Selectingswitch)==HIGH){
break;
}
//////////////////////////////////////////////discharging
pinMode(charge,INPUT);
pinMode(discharge,OUTPUT);
digitalWrite(discharge,LOW);

Serial.print("Discharging-");//12
while(voltage>2.0)
{
voltage=measure();
delay(100);

answer=voltage * (99.0 / 1023.0);
Serial.print((99-answer),0);

Serial.println("%");
}


Serial.println(" ");
delay(1000);

Serial.println("charging-");//9

Serial.print("%");

//////////////////////////////////////////////charging
pinMode(discharge,INPUT);
pinMode(charge,OUTPUT);
digitalWrite(charge,HIGH);
start_timer=micros();

while(measure()<648)
{

Serial.println(measure()*(100.0/1023.0),1);
}

stop_timer=micros();
duration=stop_timer-start_timer;
answer=duration/10000;

// lcd.setCursor(0,1);

// lcd.print(" ");

Serial.print("value ");
Serial.print(answer);
Serial.print(" uF");
delay(3000);
while(1)
{

Serial.println("reset measure");
delay(200);

Serial.print(" ");
delay(200);
}

}
}

int measure (void)
{
int value;
value=analogRead(analogPin);
return value;
}

/////////// for small cap ///////////////

void smallCap (){

abc:
pinMode(analogPin2,INPUT);
digitalWrite(analog_charge,HIGH);
voltage2=analogRead(analogPin2);
digitalWrite(analog_charge,LOW);

pinMode(analogPin2,OUTPUT);
if(voltage2<1000)
{
cu=((ck*voltage2)/(1024.0-voltage2));
if(cu>20.0)
{

Serial.print(cu,2);
Serial.println(" pF");
}
else
{

Serial.print("-");
delay(200);

if (digitalRead(Selectingswitch)==LOW){
Serial.println("Change Mode to Uf range");
largeCap();
}
goto abc;
}
}
else
{
voltage2=0;
pinMode(analogPin2,OUTPUT);
delay(1);
pinMode(analog_charge,INPUT_PULLUP);
unsigned long start_time = micros();
unsigned long final_time=0;

while((voltage2 < 1) && (final_time < 400000L))
{
voltage2 = digitalRead(analog_charge);
unsigned long stop_time = micros();
final_time = stop_time > start_time ? stop_time - start_time : start_time - stop_time;
}

pinMode(analog_charge, INPUT);
voltage2 = analogRead(analog_charge);
digitalWrite(analogPin2, HIGH);
int delay_T = (int)(final_time / 1000L) * 5;
delay(delay_T);
pinMode(analog_charge, OUTPUT);
digitalWrite(analog_charge, LOW);
digitalWrite(analogPin2, LOW);

cu = -(float)final_time / 34.8 ;
cu /= log(1.0 - (float)voltage2 / (float)1023);
if(cu < 1000.0)
{
Serial.print(cu,2);
Serial.println(" nF ");
}
else
{
Serial.println(" **Outange** ");
}
}
delay(1000);
}

Copy and paste this code in to your Arduino IDE and upload it to your Arduno Uno Board. After that Your meter is ready to measure capacitance of your capacitor.

How Operate the meter

step1.

First select Selection switch to right range (left to 1uf to 4700uf range and right to 1nf to 1uf range )

step 2 :

Place capacitor in right IC base according to your capacitor

step 3:

We use Serial Monitor As display of the meter So connect Arduino USB to Your Computer by OTG cable and Open any Serial Communication software (or bullet in serial monitor on Arduino IDE) / If you don’t have computer then use your mobile phone with Serial monitor App

Step 4:

Click Reset Button on Your arduno Board and see on serial monitor and you will see capacitance of your capacitor.

Conclusions

 

Building your own capacitance meter can be a fun and rewarding project that can help you learn more about electronics and programming.

With just a few electronic components and an Arduino board, you can create a functional and accurate capacitance meter that can measure capacitance values up to a 4700 Micro Farads. The sample code provided above can be customized to suit your needs and can be used as a starting point for more advanced projects.

With some creativity and experimentation, you can build more complex circuits and instruments using the knowledge gained from building a capacitance meter.

Overall, making your own electronic devices can be an enjoyable and educational hobby that can lead to many exciting possibilities. And also don’t forget to share your project with us. Thank you all.

Read about Arduino : click here

 

Leave a Reply

Your email address will not be published. Required fields are marked *