loading

This project comprises the design and construction of a simple capacitance meter capable of measuring capacitors in the range of about 20 picoF to hundreds of microF.

This can be a very useful tool when checking our capacitors and it will also make us feel the satisfaction of having built it ourselves.

In a previous instructable (https://www.instructables.com/id/Capacitance-meter-with-arduino-and-555-timer/), I presented a similar project of a Capacitance meter using the Arduino One and the 555 timer. That project had an excellent performance, measuring with great accuracy capacitors in the range of 1 nanoF to hundreds of microF.

For this project I used the Arduino One again but now with an external circuit based on the popular 741 op-amp configured as a comparator.

The function of the 741 in this project is to inform the Arduino the exact moment when the charge of the capacitor under measurement has reached a known voltage level.

With this information provided through a pin attached to an interrupt, the Arduino is responsible for determining the time elapsed from the start of the charging process until the reference voltage is reached.

Once the time T has been calculated, it is possible to determine the unknown capacitance using the equations governing the charge and discharge of a capacitor through a resistor.

Step 1: THE 741 OP-AMP AND THE COMPARATOR CIRCUIT

The principle of operation of this meter is based on the determination of the time T that it takes to charge an unknown capacitor C through a known resistor R from 0V to a voltage reference level (Vref) which is determined by a simple voltage divider formed by R1 and R2.

I chose R1 = R2 so that Vref = VCC / 2 making the calculations easier.

VCC for the comparator circuit is provided by the Arduino, therefore VCC = 5V.

The reference voltage is applied to the inverting input A1 of the 741 so the output will be HIGH when the voltage at the noninverting input A2 is greater than A1 and LOW when it is less than A1 (hence the name "Comparator" for this configuration).

The non-inverting input A2 is conected to the junction of R and C.

The common schema for the comparator is shown in the schematic above; the capacitor charged with a voltage of VCC makes the voltage at A2 to be greater than A1 and therefore puts the output pin in the HIGH state which in the case of the 741 has a value of VCC - 2V = 3V.

However, in this project, the capacitor will be discharged most of the time since the VCC voltage applied to the R-C circuit will be controlled by us through the pin 11 of the Arduino. Actually VCC will only be applied when the charging has to be initiated.

Therefore, the output will be LOW most of the time too and will only switch to HIGH when the charge in the capacitor reaches Vref at A1.

Step 2: STARTING THE MEASUREMENT

The measurement process starts with the push of a switch that sends pin 10 to ground. This pin was maintained to VCC through the pull-up resistor R3 of 10 kohm.

In the loop() function an if block detects the voltage change on pin 10 and then, afterprocessing the "debouncing" of the push button, executes the code within the block according to the following sequence:

1 - Pin 9 is changed from INPUT mode to OUTPUT mode as to allow us to send it to ground (LOW).

2 - A 100 ms delay is produced to ensure a complete discharge.

3 - We change again pin 9 to INPUT mode (high impedance state) which is equivalent to putting on this pin a resistance of about 10 Mohm in series with R5, which is seen by the R-C circuit as an open circuit and therefore without any influence in the measurement.

4 - We put pin 11 in the HIGH state so as to power the R-C circuit with VCC and therefore start charging C through R.

5 - We store in a variable (t_start) the time returned by micros() which marks the beginning of the charging. To visually flag the charging process, an LED connected to pin 12 is turned on.

Step 3: ENDING THE MEASUREMENT (the Charge Reached Vref)

The capacitor charging occurs through the resistor R whose value is chosen depending on the range of capacitances that we want to measure. These are the advisable resistors:

1. 20 pF < C <= 10 nF => R = 1 Mohm

2. 10 nF < C <= 300 uF => R = 10 kohm

3. 300 uF < C => R = 1 kohm

The charge on the capacitor increases exponentially from 0 to VCC.

At the precise instant when the voltage at A2 exceeds the level Vref at A1, the 741 output switches abruptly to the HIGH state.

The output of the 741 (pin 6) is connected to pin 3 of the arduino, which is linked to the interrupt 1 in the setup() block of our code.

Here we establish that the interrupt will be triggered when the pin 3 detects the rising edge produced by the 741 when the charge of the capacitor has reached Vref. When the interrupt is fired the code in the stop() function must be inmediately executed, suspending any other action the Arduino was carrying out at that moment.

When the voltage in the capacitor C reaches Vref and the interrupt is triggered, the code in the stop() function simply saves in the variable t_stop the time returned by micros() marking the end of the measurement.

Step 4: DETERMINING THE UNKNOWN CAPACITANCE

After the variable t_stop has been assigned during the interrupt, the Arduino is now able to perform the calculations to determine the unknown capacitance.

In the loop() function, there is a second if block that is entered only if the following three conditions are met simultaneously:

1. t_stop > 0

2. t_start > 0

3. (t_stop - t_start) > 0

At first sight one would think that the first condition should have been enough, but it wasn't, as the noise at the output of the 741 caused the triggering of the interrupt randomly when the voltage at A1 and A2 became equal. This produced false readings besides the correct one.

By including the conditions 2 and 3, I was able to eliminate the false readings and get only one clean and precise reading.

The sequence of operations inside the if block is the following:

The time elapsed from the start of the charging until Vref is reached, is calculated:

T = t_stop - t_start

The time constant RC of the circuit is calculated from the general equation of the charging of capacitors.

RC = -T / log((Vref - VCC) / (V0 - VCC))

V0 = 0 because the capacitor is initially discharged.

Finally, the capacitance is determined:

C = RC/R

Step 5: DISPLAYING THE RESULTS AND RESETTING THE VARIABLES

The found capacitance is displayed on the serial monitor. Its value is expressed in microF, nanoF, and picoF.

When expressing the capacitance in picoF, I subtract a value representing the stray capacitance of the circuit which was obtained experimentally by taking readings with no capacitor installed. So if someone plans to build this project, must make her own estimates concerning this value.

Finally we reassign 0 to variables t_start and t_stop, set the pin 11 to ground which removes VCC from the R-C circuit and our capacitance meter is ready for a new measurement.

Step 6: BUILDING THE PROJECT

In the image above you can appreciate a protoboard mounting diagram, the wiring and the components values.

As you can see, mounting the project doesn't imply any difficulty and can be done in very short time.

You can download the source code clicking the corresponding link.

Well, my friends, this concludes this instructable, hoping it can be of some usefulness for someone or perhaps as a sort of inspiration for the Arduino enthusiasts in the finding of new and creative ways of utilizing this amazing device.

Until the next instructable.

<p>I have built the circuit according to the breadboard wiring diagram showed above, but it did not work. I changed the placement and orientation of the pushbutton and now it works perfectly. In my opinion, there must be something wrong with the pushbutton in the diagram.</p>
I tried to build the circuit but it did not work. There's no output in the serial monitor
<p>Did it work now.If it did,help me too!!!</p>
<p>No output in serial monitor.Help!!!</p>
<p>EXCELENT!!!!!!!!!!!!</p>
<p>wonderful job, and thank you for posting it in multiple languages! Thanks for being part of the Instructables community! </p>
<p>So many projects have junky, code. Yours is great, nice job, nice comments.</p>

About This Instructable

10,467views

29favorites

License:

More by ramtonio:Medidor de capacitancia con el arduino y el op-amp 741 Capacitance meter with arduino and 741 op-amp Capacitance meter with arduino and 555 timer 
Add instructable to: