Friday, May 22, 2009

Autorange Capacitance Meter with PIC16F873A

Finally, I managed to persuade myself to make a really powerful capacitance meter. This is an autoranged version, which means one does not need to adjust the range settings. Furthermore, the measuring range is quite large, from 5pF all the way to 2600uF. It is all taken care of by the PIC16F873A inside the circuit.

It is based on a very simple circuit analysis principle of charging and discharging of capacitors in an RC circuit.




Tau = RC, where Tau is the Time constant of any given RC circuit. The voltage at any time t across the capacitor is given as,

Vcap = E[1 - e^ (t/RC)]

Substituting t with Tau = RC,
Vcap = 0.632E or 63.2 % of the charging voltage, for 5V it will be about 3.16V. This will be the reference voltage for the comparator module on board the PIC16F873A.

The other input to the comparator is the actual capacitor's voltage itself.



The capacitance meter begins by discharging the capacitor fully. Then it charges it and waits until the voltage across the capacitor reaches 0.632Vcc. The time is then captured and the capacitance is computed using Tau = RC. A 16 bit division routine written by Andy Warren is used for this project. The result is then displayed on the LCD. The process will then repeat itself every subsequent 0.255s.

The initial tests on the breadboard indicated some small problems. It appears that even the breadboard itself contains stray capacitance which may greatly affect readings, especially the readings on less then 100pF ranges.

To correct for this problem, I implemented 2 push buttons that can help calibrate the capacitance meter. Calibration is a simple task of just pushing the buttons until the capacitance reading reads 00000.00pF when there is not capacitors connected. Also, to prevent calibration at every time the meter is used, I also implemented a button to save the calibration settings on the EEPROM of the PIC16F873A. The PIC loads the setting everytime the device gets powered on.

No comments:

Post a Comment