Charging time indicates capacitor value
A comparator changes state when capacitor voltages are equal during rise and fall, which triggers a time measurement.
Vlad Bande and Ioan Ciascai, Technical University of Cluj-Napoca, Cluj-Napoca, Romania; Edited by Martin Rowe and Fran Granville -- EDN, August 11, 2011
A recent research project using a capacitive sensor to
measure water levels comprises two PCB (printed-circuit-board) plates placed one in front of the other at a controlled
distance. Every plate divides into eight equal copper
zones, resulting in eight equivalent parallel-plate capacitors
(Figure 1). Every capacitor has a plate area of 25 cm2. To
measure the water’s total height, the project uses a special
hydro-insulated layer to avoid short circuits. Knowing the layer
thickness and the electrical permittivity of the hydro-insulated
substance allows you to express the distance between every two
plates and the dielectric’s
electrical permittivity.The capacitance of every two overlapped copper zones can vary only when the electrical permittivity changes because all other parameters—the plate’s area and the distance between the plates—are constant, as the following equation shows: CX=(ε0εRA)/D, where ε0=(8.854×10−12)F/m, the void electrical permittivity, εR is the dielectric’s relative electrical permittivity, D is the total dielectric thickness, CX is the capacitance of the measured capacitor, and A is every plate’s surface. The relative electrical permittivity strictly depends on which and how many materials are between the capacitor plates. This application uses four kinds of εR: air, air-hydro-insulated varnish, water-hydro-insulated varnish, and air-water-hydro-insulated varnish. At this point, you must consider the capacity of the capacitors at the surface-separation line between air and water.
To measure capacitance and thus measure the water level, a
measurement system employs a 20-MHz ATTiny 2313 microcontroller
and a fast LT1016 analog comparator (Figure 2).
The measurement algorithm uses the microcontroller’s OC1A
and OC1B output-comparator signals. The ATTiny 2313 sets
both pins at once but to opposite values. When OC1A is 5V,
you can simultaneously set OC1B using assembly-language
code. The same situation occurs when OC1B is 5V; OC1A is
then 0V. In the first case, the quantity of the charge rises on
the first plate and lowers on the other plate. Reversing the
polarity causes the second plate to acquire more charge, and
its potential rises. When both plates have the same potential,
the LT1016 comparator enables the ICP pin on the microcontroller,
saving the number in the internal timer counter
and sending it through the serial port for further processing.
When the voltages on both plates are equal, the voltage on the
capacitor is halfway from the input signal’s amplitude, VCC/2.
| Read More Design Ideas |

The charging equation in the transient region is:

You can then extract the capacitance using the following equation:
Talkback






















