```School is finally over (I teach Electronics and Computer
Technology), and I have had a little time to finish
up one of the projects I began earlier in the year. It is
a Capacitance Meter that measures from fractions of a

I use a PIC 16F84 as a controller, and have a 16x2 LCD
readout for displaying results and messages. The unit
allows for both AutoRange and Manual Modes of operation.
A special Comparison Mode is also provided for.

I use an analog front-end that pumps a constant current
into (and out of) the capacitor under test. The resultant
voltage is then compared with a reference and used to
switch the polarity of the constant current. This results
in two signals. One of these is a triangle wave, and
derived from this (via the comparator section) is a nice
clean square wave whose PERIOD is directly proportional
to the capacitance being measured.

I use a sneaky trick to help eliminate error due to
any changes in the bi-polar voltage reference. In fact,
the technique works so well I use a normal red LED as
my voltage reference. For those who want to eke an
extra digit of precision out of the circuit, you can
substitute the LED with a Zener.

The accuracy of the circuit is dependant on several factors:

1) The type of quad Operational Amplifier used. I chose
to use a TL084CN opamp because it gave me a decent
performance/price ratio. This is an industry standard
pinout device, so you can substitute a better version
opamp if desired. The limiting factors as regards the
opamp are its slew rate, input bias current, and
available output current.

2) The accuracy of the resistors used in the
voltage-to-current section of the circuit. I chose to
use .1% precision resistors for the two resistors that
determine the current for the lowest scales. I used
1% resistors and trimmer pots for the remaining
scales so that I could nullify some of the errors that
creep in at the higher scales. Note that I used
*two* .1% resistors so that I could get the desired
250k value using standard precision resistor values
(249k + 1k)

3) the accuracy of the resistors used in the comparator
section. I used .1% precision units.

4) The accuracy of the clock. I used a 4.000 Mhz crystal
rather than my more usual 4.00 Mhz ceramic resonator.

5) The error due to the difference between the number of
cycles that occur between the time a period begins
and ends, and the number of instruction cycles it takes
before the count is accumulated.

6) The error due to stray capacitance in the internal
wiring and also any external stray capacitance caused

I attempt to eliminate most of the error coming from #5
and #6 by initially accumulating a count when there is
no external capacitor attached, and then subtracting
that value from subsequent readings. These initial "zero"
values are measured whenever a reset or power-up
condition occurs. They are retained until the next
reset, or they may be re-acquired at any time by pushing
the ZERO button.

Pushing the ZERO button causes the unit to enter Manual
Mode and causes the unit to acquire a reading and place
this value in the current subtraction register set.

So, if you happen to have, say, a .1 uf capacitor on the
leads and you push the ZERO button, then the display goes
to zero. If you were to remove the .1 ufd capacitor, the
display would now read negative .1 ufd to indicate the
DIFFERENCE between the current capacitance and the value
that was in effect when the ZERO button was pushed. This
Compare Mode is quite useful for "matching" capacitors,
or for tracking the *changes* in capacitance that may
be occuring.

An UP and a DOWN button are available which cause the unit
to enter Manual Mode (if not already in that mode), and
move to the Next or Previous range. The buttons are
"sticky" in that they go to the limit and stay there.
They do NOT "wrap around".

There are indicators on the display that show when the unit
is waiting for synchronization, when it is accumulating a
count, and when it has updated the numerical display. In
addition there are indicators for +/- for Comparison
Mode, and an Auto/Manual Mode indicator.

Messages are displayed when there are Over-Range values
in Manual Mode, and when the unit is AutoRanging from
one range to another in Auto Mode. There is also a
message displayed when the unit has exceeded the 16
million count limit.

AutoRange mode has hysteresis, so that small changes don't
cause the circuitry to constantly change range. The
upper limit for switching ranges in AutoRange Mode is
approximately a 500,000 counts. The lower limit is
approximately 400,000 counts. The exceptions are the
highest range, which goes up to the maximum count of
approximately 16,000,000   and the lowest range, which
can go down to .00 picofarads.

The counts are displayed on the upper line of the LCD,
and the unit designators are displayed on the second
line of the LCD. Typical displays would look something
like this:

+  15,123.456 XX    15,123.456 uf AutoMode New Count
uf  nfA**

-      23,321.54    23,321.54 pf Manual Mode
uf  nf  pfM X    <-> means Below Reference Value
Blinking X means Count In Progress.

Leading zeroes are suppressed up to the decimal point.
Commas, decimal point, and space are used to separate
number groups. Thus the last example can be easily
seen to also be equal to 23.32154 nf.

Unit was

```