Hi, On 1 Mar 99 at 13:27, Adam Bryant wrote: > Does anyone else out there have a drawer full of anonymous capacitors? I > was wondering about the feasibility of modifying the Microchip app note > that does A/D conversion using a resistor and capacitor and using it to > measure the capacitor instead. Using the PIC as a timer it should be Sure - it's possible. Use 1 or more known value resistors to charge the unknown cap and measure the time it takes to trip the PIC input threshold. If you want a reference you can charge a known cap through the same circuit but for just a rough measurement you don't need one. E.g. R1 known resistor from RB0 to CAP+ (lets say 100K 1%, choose to give a reasonable time constant, you can use more than one) RB1 to CAP+ Known cap CAP+ to RB2 (Value in the middle of your measurement range, best precision you can get, you can use more than one ref. cap) i.e. the (-) of the cap connects to RB2 and the (+) to RB1 and resistor. Measured cap CAP+ to RB3 Measurement cycle: 1) Tristate RB1, RB3. 2) Set RB0 to 0. 3) Set RB2 to output 0. 4) Set RB0 to 1. 5) Measure time till RB1 reads 1. (reference capacitance) 6) Set RB0 to 0. 7) Wait measured time + some to discharge ref cap. 8) Tristate RB2. 9) Set RB3 to 0 10) Set RB0 to 1. 11) Measure time till RB1 reads 1. (measured cap) 12) Set RB0 to 0. 13) Wait for discharge. tref = reference time, tmes = measured cap time (in seconds) Cref = reference cap value (In Farads), Cmes = measured cap value tref = a*R*Cref (a is a constant) tmes = a*R*Cmes tref/tmes = Cref/Cmes Cmes = tmes*Cref/tref Check my math and pay attention to the units... You should probably protect the input pin (RB1) with a resistor (1K?). For extra protection put two more resistors, one from Cref(-) to RB2 and the other one from Cmes(-) to RB3. You can use more the one charging resistors to measure across a bigger range of caps quickly. You can also use more than one reference cap. Also, consider the case when the cap is already charged when connected to the PIC (with it's maximal voltage rating...). Have fun... Hope this helps, Guy - mlsirton@inter.net.il