Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC based high-resolution cap meter

Status
Not open for further replies.
I build meter with 0.2% resistors but results is no good. Condenser K71-7/1000pF/ 1% meter show 1022pF. K71-7/2200pF/1% meter show 2228 pF . This is not true.
 
Lots of people have built the meter and results are very good. :)

A 1000pF 1% cap can have value from 990pF to 1010pF. Please check you zeroed the meter correctly, with the test wires in the same position when you zero it and when you measure the cap. Moving the test wires especially if they are long can cause a few pF difference in the reading.

Also, if you assembled it on breadboard you can expect lots of pF error. Do you have a photo of your assembled PCB, we might be able to help with suggestions on how to improve the layout etc for better accuracy.

Also if you want a very accurate calibration you should use a trimpot in series with one of the resistors, and adjust the trimpot to trim that final <1% accuracy. I think I mentioned that on my web page. :)
 
Thanks for posting the picture, it looks like you are using a general purpose PIC 18pin to LCD PCB? Anyway the PCB should be ok even though it is a bit messy.

I'm not sure i understand your parts; I assume the styro caps make approx 270pF which is the permanent cap. That cap value is NOT ciritcal, you can even use 330pF if you like. That is because the zero button will cancel that cap out completely.

So where is your zero button? How are you attaching the cap under test?

If you want to trim the cap meter to be more accurate than the 1%-2% error you are getting now you need to connect a small trimpot in series with the 10k resistor, to let you adjust it a couple of percent. Or, if your tests are correct and the meter is reading (example) 1% high then just change the 10k resistor for one that is 9.9k (so the resistor is 1% smaller).

But please first check about that zeroing issue, as if you are not zeroing the capmeter properly it will read high as the permanent cap is added onto the test cap! :)
 
Last edited:
Thank you for replay. Buton is in on back side. Now i use 9.75k resistor and results looks good. I will buy from ebay 0,3% capacitors and will check again.

Sorry for my bad english.
 
I'm glad to be of help. Your English is quite good and communication was 100% functional (I believe). :)

Thank you for posting the photo and details about your build.
 
Hey Roman, i know this is a older post but i wanted to ask you if it would be possible, since there is no source code available, it would be awesome if you alter the code to also send out the cap value via UART. This way if we want to use something like a PC or Graphic LCD we can and wouldnt need your source at all. Please consider it and get back to me. Thanks
 
Hi Atom. :) I'm very busy with a few important jobs at the moment but I'll put that on my hobby jobs list.

However I can offer a suggestion that if you need the cap measuring in your own project you could just use the "precision period measuring" section from my capmeter page. It outlines the process of adding multiple periods from the capture port. Basically you just add lots of periods from the oscillator, and divide it by a scaling factor and the number of periods, and you get a very high resolution cap measurement (as the period must be proportional to the capacitance).

I know you're an experienced programmer so that might be a better option to just put that process in your code than to use a second PIC that outputs serial data? That seems a bit wasteful.
 
You wanted to use your PC as "the display" for capacitor measuring? :eek:

I thought you were the resident expert here on using lots of cool LCDs etc? ;)

To me the cool part of the project is that it's a little handheld cap meter that I can grab and carry off to test caps on the workbench or going through a junkbox or testing the capacitance of something in the field (even a cable etc).
 
I did but now you made me feel like i have to use a LCD. I have about 4 LCDs here and no time tho :)
I too have tons of work and projects. Ive been so busy lately. Then add a family with 2 kids... its hectic sometimes.

Im no good with CCP modules... they scare me. Also math in my brain sucks. But i guess ill give it another shot as you are also busy :)

Thanks for the work and awesome site Roman!

You wanted to use your PC as "the display" for capacitor measuring? :eek:

I thought you were the resident expert here on using lots of cool LCDs etc? ;)

To me the cool part of the project is that it's a little handheld cap meter that I can grab and carry off to test caps on the workbench or going through a junkbox or testing the capacitance of something in the field (even a cable etc).
 
Everyone seems busy lately! :)

Don't be scared of the PIC CCP1 module it've very easy! Basically every time it receives an input pulse it just "captures" the 16bit value from TMR1 into a special register (actually two 8bit registers). At the same time it sets an interrupt flag to let you know it captured a pulse.

Then you get elapsed time period by;
period = (capture_new - capture_last);

And for my "high resolution" capture code all it does is add up lots of captured periods one after the other. That TOTAL gives the high resolution count (after some simple math) for displaying. :)
 
Hi Mr.RB and All.
I build the high res cap meter in breadboard. It worked fine but cap values are 15-30% hi. I build it again on Melab prototype pcb which is much professional finish. The same things happen cap meter read 15% for small cap and 20%-30% for larger cap. ( 22pf reads 28pf 1u reads 1.2u). 10 k resistor is chosen to be 10.01K as read by DVM.Can some body please suggest a solution?. Capacitors measured are 5%.

Obaid
 
Hi Mr.RB and All.
I build the high res cap meter in breadboard. It worked fine but cap values are 15-30% hi. I build it again on Melab prototype pcb which is much professional finish. The same things happen cap meter read 15% for small cap and 20%-30% for larger cap. ( 22pf reads 28pf 1u reads 1.2u). 10 k resistor is chosen to be 10.01K as read by DVM.Can some body please suggest a solution?. Capacitors measured are 5%.

Obaid

Are you touching the capacitors while measuring them? Is your oscillator accurate 16 Mhz?
 
Last edited:
Abofar; please check the values of the 1k5 resistors too, they need to be reasonably accurate. Normally 5% resistors there will get you very close.

Please note if the 1uF cap is an electro cap it is quite likely it really is 1.2uF, they tend to be high in capacitance compared to their markings.

Otherwise MisterT has a good point, are you using a proper xtal or just a resonator? And please check config fuses, ie check the PIC xtal mode is HS. These config fuses are in the HEX file I supplied but some programmers allow you to over-ride config fuses in the programmer screen so please check that.
 
Thank you all for your quick response. I did not touch the leads when I was testing ( I know that one ). 1k5 resistors are 5%. I did not measure them. I know I always put Xtal to XT not RC or HS when I program my pic and using xtal osc. Could that be the problem?. Do I need to program it again?. unfortunately pic is soldered to the board I did not use IC socket. The xtalal freq is 16MHz marked on the component , did not tested it

Obaid
 
Last edited:
Thank you MisterT and Mr RB. I found the problem. It is the xtal, it was 20mhz. I used the correct xtal 16mhz, now 22pf cap reads 23.46pf and 1uF reads 1.0838uf. Where can I find standard capacitor to to verify accuracy of this circuit?. I think this circuit is great circuit. Thank you again RB for allowing me using it.

Obaid
 
Last edited:
Firstly, you should always use HS oscillator mode with XTALs over 8MHz.

Second, congrats on finding the problem and getting the capmeter working! :)

Third, special caps like 1% and 0.5% tolerance caps can be found on Farnell or Digikey websites, their "parts locator" has details of cap tolerance so it should be enabled in their search menu.
 
Hi Roman,

Thanks for posting your excellent article on measuring capacitance. The way I was doing it required different ranges (from 1k to 1M resistors) depending on the capacitor inserted. I do have some questions though. I am trying to use your schematic as much as possible, but I am using a 3.3v pic, 3x 2.21k 1% resistors, 10k 1% resistor and a graphical LCD. I am also using an external 24Mhz crystal. (this is all stuff I already have).

I am confused because the way I used to do it I would use 2 resistors which gave me about 67% of the voltage and I would measure the time it took to go from 0 volts to 67% of VDD to calculate the capacitance. Your way gives much better resolution, speed and probably accuracy since you take hundreds of readings and average them. The time it takes to go from 0v to 67% of VDD was 1 time constant, but oscillating between .333% and .666% is waaay less, and I am having trouble figuring out the time constant and converting your math to work with my setup.

For example;
"10nF" cap, oscillates about 435Hz
218 consecutive periods are captured, a total of 2004597 counts
Math; (2004597*1000)/218 = 2004597000/218 = 9195399
(so the average period is 9195.399 counts)

A second process is used to convert that result to picofarads;
(9195399*100)/scale = 919539900/919 = 1000587
1000587 is then displayed as; 10005.87 pF


I don't understand what "scale" means, or why you multiply 9195399 * 100. What does the 100 represent? I was also wondering where you take into account the 10k resistor? What if I used a different value resistor, like a 1% 7k resistor. What changes in your code would I need to make to use the 7k resistor instead of the 10k? I actually have a 1.024k resistor and was thinking of ranging between 1.024k and 10k so I could measure very large capacitors. If you could shed any light on these issues I am having, that would be great. Otherwise I will eventually figure it out. Keep on posting your projects if you would. I notice your website is not update quite as often as it used to be. Do you just not have many new projects going or not have the time to update your website with them?

Thanks,
James
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top