__Introduction__

This is a project based on Arduino board which can measure the unknown capacitance value. When the capacitor whose value needs to be measured is plugged into the breadboard of the Capacitance meter, the 16*2 LCD displays the capacitance value. The project uses an Arduino pro mini boardwhose ADC feature is used along with the concept of RC charging circuit to develop this Capacitance meter.

*Fig. 1: Prototype of Arduino based Capacitance Meter*

__Description__

The entire project can be divided into three basic blocks;

1) Capacitance Sensor Unit

2) Processor Unit

3) Display Unit

*Fig. 2: Block Diagram of Arduino based Capacitance Meter*

The Capacitor Sensor Unit allows an input capacitor to charge or discharge through it. The voltage across the capacitor while it charges or discharges appears as the output of the Sensor Unit.

The Processor Unit can take input voltage in the range of 0 to 5V.This unit can make the Sensor unit to charge or discharge the capacitor. This unit takes the Sensor Unit’s output as input voltage and uses the ADC to read that voltage. An Algorithm is then applied to calculate the capacitance value. The unit then sends a 4bit data to the Display Unit to display the capacitance value.

The Display Unit takes the 4bit data from the Processor Unit and produces a 16*2 display for the value of capacitance.

1) __CapacitanceSensor__

The Capacitance sensor in this project is an RC discharging circuit in which the unknown capacitor is discharged through a known resistor. An RC discharging circuit is a circuit in which a capacitor and a resistor are connected in parallel. In a RC discharging circuit the time taken for the capacitor to discharge through the resistor to half the voltage before starts discharging is dependent on the values of resistance and capacitance.

*Fig. 3: Circuit Diagram of Capacitance Sensor*

Consider the capacitor ‘C’ in an RC circuit charges and discharges through a resistor ‘Rc’, and while discharging let ‘T’ be the time taken for the capacitor to drop the voltage across it to half the voltage before it starts discharging, then the capacitance ‘C’ can be calculated using the following equation;

C = T / (0.693 * Rc)

The capacitor in this project is allowed to charge for a while, measure the voltage across it and then allows it to discharge through known resistor ‘Rc’. The time taken ‘T’ till the voltage across it drops to half the voltage is noted and from that we can calculate the capacitance value.

Selecting the value of Rc;

Let us assume the maximum value of capacitance C = 100 uF, that can be measured with a discharge time of T = 10 s, then the discharge resistance Rc can be calculated as,

Rc = T / (0.693 * C)

Rc = 1 / (0.693 * 100 uF) = 144300 ohms, Let us select 100K standard resistor

1) __Processor Unit__

The processor unit in this project is the Arduino board and it uses the ADC module to read the output voltage from the Sensor Unit. The processor unit first charges the capacitor in the sensor unit by applying 5V for a while and then suddenly removes that charging voltage. From that moment the capacitor starts discharging through the resistor Rc. The algorithm in the Processor unit continuously read the voltage Vc from the Sensor Unit using ADC, and takes the difference in time ‘T’ from the moment it starts discharging till the Vc becomes half the voltage that was present across the capacitor before it starts discharging.

In the Arduino board we are using an 8 channel, 10 bit ADC with the reference voltage pin connected to 5 V. The ADC reads the voltage Vc and generates an equivalent value ‘Value_{ADC}‘at the ADC register. From this value the algorithm calculates[H1] the voltages Vc, measures the discharge time ‘T’ and then the Capacitance.

Once the value of discharge time ‘T’is obtained the value of Capacitance is calculated using the known values of Rc = 100K with the help of equation;

C = T / (0.693 * Rc)

The following piece of code measures the discharge time ‘T’, and calculates the Capacitance.

discharge_time_T0 = micros();

discharge_voltage_V1 = discharge_voltage_V0 / 2;

while ( discharge_voltage_V1 <analogRead(A4) );

discharge_time_T1 = micros();

capacitance = (discharge_time_T1 – discharge_time_T0) / 0.693;

capacitance = capacitance / resistance_Cr;

2) __16*2 LCD module__

This is a standard 16*2 LCD on which the Arduino displays the capacitance value. The LCD has been wired in four bit mode to reduce the number of output pins of the Arduino board to be used.

*Fig. 4: Typical Image of Character LCD*

__Circuit Description__

*Fig. 5: Circuit Diagram of Arduino based Capacitance Meter*

__Code Description__

*Fig. 6: Flow Chart of Arduino Code for measurement of capacitance*

The code first charges the capacitor through an output pin 18, and then removes that charging voltage. The capacitor starts discharging and the code copies the system time at that moment. The same pin18 will be selected as ADC channel to monitor the voltage across capacitor, once it drops below half the original voltage, the code again calculates the time elapsed. Using this value of time the code calculates the capacitance value.

The code running in the Arduino uses the library function **micros() **to get the system time in microseconds. The capacitance value is then displayed on the 16*2 LCD. The code running in the Arduino uses the library function analogRead()to obtain the ADC values and lcd.print()to display the 16*2 LCD.

### Project Source Code

###

// include the library code:

#include

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int adc_value = 0;

int voltage_peak_value = 0;

int discharge_voltage_V0 = 0;

int discharge_voltage_V1 = 0;

float voltage_average_value = 0;

float dc_voltage_V0 = 0;

float ac_voltage_V0 = 0;

float dc_voltage_V1 = 0;

float dc_voltage_V2 = 0;

float ac_voltage_V1 = 0;

float dc_current_I0 = 0;

float dc_current_I1 = 0;

float ac_current_I0 = 0;

float dc_power = 0;

float ac_power = 0;

float npn_pnp_hfe = 0;

float capacitance = 0;

unsigned long resistance;

unsigned long sample_count = 0;

unsigned long discharge_time_T0 = 0;

unsigned long discharge_time_T1 = 0;

void setup()

{

// set up the LCD's number of columns and rows:

lcd.begin(16, 2);

// Print a message to the LCD.

lcd.print(" EG LABS ");

pinMode(13, OUTPUT);

}

void loop()

{

//=============================== CAPACITANCE =====================================

pinMode(18, OUTPUT);

digitalWrite(18, HIGH);

delay(1000);

pinMode(18, INPUT);

discharge_voltage_V0 = analogRead(A4);

discharge_time_T0 = micros();

discharge_voltage_V1 = discharge_voltage_V0 / 2;

while ( discharge_voltage_V1 < analogRead(A4) );

discharge_time_T1 = micros();

capacitance = (discharge_time_T1 - discharge_time_T0) / 0.693;

capacitance = capacitance / 100000;

lcd.clear();

lcd.setCursor(0, 0);

lcd.print(capacitance);

lcd.print(" uF");

//=================================================================================

delay(1000);

}

###