Introduction: Arduino Capacitor Measurement - Tinkercad Simulation to the Real Circuit

About: DIY my way through life. For me, Instructales is a way of living. It's my making log. My life is counted with the instructables I make. Visit my website and If you need more Arduino Mentoring for your class yo…

In this project if learned many things

How to fix my dish washer

How to isolate capacitor faults

How to measure capacitor with a cheap voltmeter

How to measure capacitor with expensive capacitor


How to build the circuit and simulate it on Tinkercad Simulation first


How to build a physical circuit to measure capacitor with Arduino and measure it


Please visit my website AeroArduino.com


Supplies

Tinkercad Website

Arduino UNO

Capacitor Under Test

10K Ohm Resistor

16x2 LCD Optional

1K Ohm Resistor Optional with LCD


Please visit my website AeroArduino.com

Step 1: Story


I noticed that my dish washer is not working.


I could have taken it to the workshop to fix it, but something inside my head kept telling me to open it and see what's wrong with it.


First, I opened YouTube to get hints about what could go wrong with the dish washer that made it not working at all.


YouTube videos suggested some factors that could cause the fault.


The water pump motor, the relay, the controller or the water pump capacitor.


I opened the dish washer and found all possible causes and how they could be replaced.


I hoped that the fault is in the capacitor.


To be frank with you, the easiest thing to be replaced and the least expensive and the easiest thing to be tested was the capacitor.


So, I've decided to start with that possible cause and work with it.


I found that the capacitor can be tested with expensive voltmeter. Unfortunately I couldn't get that voltmeter that had the capacitor Measurement function.


My engineering sense and passion told me that I could have other ways to test the capacitor but I need to learn them.


Again, YouTube videos could help me with different ways to test the capacitor.


Please visit my website AeroArduino.com


Step 2: Capacitor Measurement and Testing

I learned that capacitor can be tested with:


1- Advanced voltmeter to measure the capacitor directly and get its value directly or determine if it's defective.


2- Cheap Voltmeter to determine if the capacitor is working or defective without measuring its value.


3- Arduino measuring method through charging and discharging cycle of the capacitor and finding the time to determine its value.


Cheap Voltmeter Method:

I learned that the capacitor can be only tested with a cheap voltmeter to determine if the capacitor is working or defective.


I learned that I needed to set the voltmeter to the resistance measuring mode.


The normal capacitor behaves as a short circuit momentarily and then turns to an open circuit.


Also on the buzzer mode, the normal capacitor makes a short buzz indicating a short circuit the stops that buzz indicating an open circuit.


But the defective capacitor doesn't do all of that.


I tested my capacitor and found it to be defective.


But hey, that's not a good way to measure the capacitor.


It only gave me a hint that my capacitor can be defective with 80% probability.


That's why I wanted to make sure and 


Measure The Capacitor With Arduino Method:

I found videos of people making simple Arduino circuit to measure the capacitor without so much components.


I decided that's a good chance to learn something new with Arduino and also fixing my dish washer. My wife would be glad for Arduino.


Please visit my website AeroArduino.com


Step 3: Tinkercad Simulation of Capacitor Measurement With Arduino:

Of course, I try to simulate everything without I actually build it to get a sense about how it's working.


So I wanted to simulate this simple circuit on my favorite Arduino Simulation Platform Autodesk Tinkercad.







Step 4: Circuit

The circuit is very simple, Arduino Uno, the capacitor to be tested and a resistance for the charging and discharging cycle.


Optional LCD can be used to display the capacitor measurement and discharging cycle times.


Also we can use the Arduino Serial Monitor to see all results. I decided to use this option.




Step 5: Arduino Software

The code makes simple steps.


Charging the capacitor.


Discharging the capacitor.


Measuring the time.


Displaying results on LCD and Serial Monitor


#include <LiquidCrystal.h>


const int rs = 12, en = 10, d4 = 6, d5 = 5, d6 = 4, d7 = 3;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);


// Initialize Pins
int analogPin = 0;
int chargePin = 13;
int dischargePin = 11; //speeds up discharging process, not necessary though


// Initialize Resistor
int resistorValue = 10000;


// Initialize Timer
unsigned long startTime;
unsigned long elapsedTime;


// Initialize Capacitance Variables
float microFarads;                
float nanoFarads;


void setup()
{

  lcd.begin(16, 2);  // LCD Initialization 

  lcd.print("Capacitance Mtr");  // Print a text to the LCD.

  pinMode(chargePin, OUTPUT);     
  digitalWrite(chargePin, LOW);  
  Serial.begin(9600); // Print Capacitance on Serial Monitor
}


void loop()
{
  digitalWrite(chargePin, HIGH); // Begins charging the capacitor
  startTime = millis(); // Begins the timer

  while(analogRead(analogPin) < 648)
  {       
    // Does nothing until capacitor reaches 63.2% of total voltage
  }


  elapsedTime= millis() - startTime; // Determines how much time it took to charge capacitor
  microFarads = ((float)elapsedTime / resistorValue) * 1000;
  Serial.print(elapsedTime);       
  Serial.print(" mS    ");         

    lcd.setCursor(0, 1);
    lcd.print(elapsedTime);
    lcd.print(" mS    ");



  if (microFarads > 1) // Determines if units should be micro or nano and prints accordingly
  {
    Serial.print((long)microFarads);       
    Serial.println(" microFarads");   

    lcd.print((long)microFarads);
    lcd.print(" uF");

  }


  else
  {
    nanoFarads = microFarads * 1000.0;      
    Serial.print((long)nanoFarads);         
    Serial.println(" nanoFarads");          

    lcd.print((long)nanoFarads);
    lcd.print(" nF");


    delay(500); 
  }


  digitalWrite(chargePin, LOW); // Stops charging capacitor
  pinMode(dischargePin, OUTPUT); 
  digitalWrite(dischargePin, LOW); // Allows capacitor to discharge    
  while(analogRead(analogPin) > 0)
  {
    // Do nothing until capacitor is discharged      
  }


  pinMode(dischargePin, INPUT); // Prevents capacitor from discharging  




}

Step 6: Tinkercad Simulation

Tinkercad Simulation:

I built the circuit on Tinkercad and made the model ready to simulate.


All steps are carried out and started Simulation.


I used different capacitors and changed values and found the circuit working excellent.








Step 7: Building the Physical Circuit

Building the Physical Circuit:


I don't mind work on something and try it and then it doesn't work as intended.


After I worked on the simulated circuit on Tinkercad and made sure it's working great - I don't want to build something that might not work - I decided to build the real world circuit with real Arduino Uno board.


I tested my capacitor and found that it's defected and doesn't charge.


I bought a new capacitor and tested it with my normal voltmeter and produced the normal capacitor behavior of momentarily charging and short circuit and short buzz.


Then I tested the new capacitor on Arduino circuit and also read the capacitor value written on it.



Step 8: Conclusion

I faced a problem and I knew I could learn new things working on solving this problem.


So I decided to go on and learn new skills With Arduino and Tinkercad.


I also learned new things about capacitors and measurements.


Please visit my website AeroArduino.com