# Capacitance Meter

Status
Not open for further replies.

#### clunge

##### New Member
Hi all, i have been banging my head against a wall, and was wondering if any of you could throw a few pointers at me regarding the PIC program for the following i am about to describe:

Basically, the circuit is designed so that the 16F84a PIC discharges a capacitor, then once fully discharged, the PIC should detect a low output indicating the capacitor is recharging. At this point a timer should start, and once charged a comparator should output a signal to trigger the PIC to stop counting and output the time constant on a dual 7 segment display.

I have tried a few different methods to get the desired control and output, unfortunately however, no joy and a large headache.

This is an assignment for a uni course, therefore i do not want the answer just a little nudge in the right direction.

#### superfrog

##### New Member
I for one appreciate the quality of your post and the fact that you are honest with the fact that this is an assigment. Thank you for the respect, absence of txt speak.

As I understand you wish to mesure the value of a capacitor by mesuring the time it takes for it to reach a certain voltage from empty.

If I remember well, in a capacitor-resistor in series dipole connected to a supply of potential difference Us, the capacitor voltage evolves in Uc=Us(1-e^(-RCt))

If you start from Uc = 0 (which you should be thinking about as you are most probably not), and trigger the pic at Uc = .95Us, this should take roughly 5RC s to get there, hence, if you count a time Tc on the pic, you should get C = T/(5R). You can then happily display that on the 7 segment.

2 pitfalls i can think about :
- The actual resistance from the chaging leg of the circuit has to encompass the resistance of the charging source of the circuit, including possible current limiting if it is from a mcu pin, ie you should probably use an external mosfet with low OR controlled/well specified on resistance.
- The pic is going to detect low before the capacitor is actually empty, hence you shall wait some more, or possibly use some low resistance path to ground to discharge the capacitor to zero in a short time once low is detected.

#### dougy83

##### Well-Known Member
I have tried a few different methods to get the desired control and output, unfortunately however, no joy and a large headache.
Care to elaborate on what you've tried?

This is an assignment for a uni course, therefore i do not want the answer just a little nudge in the right direction.
From what I can tell from your post, the capacitor is connected to the PIC through a resistor. The cap is also connected to a comparator input; the comparator output is fed back to the PIC. The other comparator input should be connected to some reference voltage - just use a resistor divider between 0 & 5V.

#### Mr RB

##### Well-Known Member
I did something similar in the mid '80s. I used a schmidt inverter IC (actually just one inverter) as a free running oscillator with a feedback resistor and the cap under test connected between the inverter input and ground.

It worked so well and was absolutely linear, I ended up installing it inside my digital frequency meter with a switch. The meter could be set to "period" and with the correct value feedback resistor is read out in actual uF. It worked fine down to a few pF (tiny caps sometimes needed kickstarting with the touch of a finger), and had the full 7 digit readout of the frequency meter.

If I was doing it with a PIC now I would just use one of the PICs comparators as the free running oscillator, then get the PIC to measure frequency.

Status
Not open for further replies.

Replies
3
Views
2K
Replies
7
Views
1K
Replies
19
Views
2K
Replies
12
Views
2K
Replies
4
Views
2K