1. 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.
    Dismiss Notice

PIC based high-resolution cap meter

Discussion in 'Microcontrollers' started by Mr RB, Jun 27, 2011.

  1. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    Excellent! :)

    To Throbscottle; You can measure and match the resistors if you like.

    If you are after higher accuracy then you can replace the 10k with one fractionally less in value (like a low 10k 5% resistor ie 9.8k) and a small trimpot in series (500 ohm?). Then calibrate compared to known value caps.
     
  2. throbscottle

    throbscottle Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,808
    Likes:
    113
    Location:
    Nuneaton, Warwickshire, UK
    Waiting for PIC to arrive in post from China now. Will be first test of homebrew PIC programmer. Photo's of top and bottom of board. The SMD's on the bottom are decoupling cap for the PIC and the 10K resistor. SMD resistor was cheaper since I decided to use 0.1%. Cap is board pull. Other caps also board pulls. The big black thing is a buck module I used instead of a 7805. The headers with the wires I pulled out of an old monitor or something. Had to chop them up a bit. Didn't have a 270pF cap so used 220pF - hope is ok.

    I put the 22pF caps too close to the crystal and had to re-drill. Pity. It's because Design Spark's standard xtal case is smaller than the real one. Anyway, it's my first proper toner-transfer pcb. It's just about acceptable.

    Soldering looks rough because I'm waiting for a new element for my soldering iron, so I used a home-made blowlamp-heated one. Drilling is a bit off because I'm waiting for collet chucks for home-made pcb drill so did it by hand. Switch is a long way from front panel, but I'm getting quite good at making little button extension type thingies out of plastic tube from hand-soap bottles now....
     

    Attached Files:

    Last edited: Jul 21, 2013
  3. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    That PCB looks pretty good for a "first proper toner transfer PCB". :)

    The 220pF/270pF cap swap should not matter, because it is zeroed out later anyway.

    Why the two trimpots? I assume the 10k is for the LCD contrast, but the 100k trimpot? Is that something to do with the PSU buck converter module?

    Anyway congrats it looks like it should be nice and functional, those little cosmetic issues (soldering drilling etc) should not affect operation.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. throbscottle

    throbscottle Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,808
    Likes:
    113
    Location:
    Nuneaton, Warwickshire, UK

    Buck converter voltage setting - exactly that. The module is set for 3.3v, but has an adjust pin. I'll put a blob of paint or something on the preset after final setting.
     
  6. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    Will it adjust to 5v or are you going to run on 3.3v (or as high as it adjusts)?

    The LCD needs 5v, they do not work well below 5v. I'm not sure about the PIC, it might work fine on <5v but I have not tested the comparator oscillator (the capacitor based osc) for accuracy under 5v.
     
  7. picbits

    picbits Well-Known Member

    Joined:
    Jan 29, 2007
    Messages:
    2,007
    Likes:
    95
    Location:
    Northants, United Kingdom
    Hey throbscottle - was that some of the PCB you bought off me ?
     
  8. throbscottle

    throbscottle Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,808
    Likes:
    113
    Location:
    Nuneaton, Warwickshire, UK
    Mr RB - the adjustment works really well, goes to nearly the supply voltage, so I'll set it to 5v and run it off a 9v battery. Works with input down to a volt above output voltage too.

    Hi picbits - yes it is :) I finally got round to using it after all this time :D
     
  9. throbscottle

    throbscottle Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,808
    Likes:
    113
    Location:
    Nuneaton, Warwickshire, UK
    I finally built a PicKit 2 clone with some help from friends on here, so was able to finish the cap meter. You can see in the photo how a backlit LCD looks without the backlight, too...

    BUT, I tested it with a fairly ancient 1% 39nF cap, the meter reads it as 35.8somehing nF, way out of tolerance, even though I used a 0.1% resistor for the 10K. I suppose it's possible I've cooked the resistor, but I don't think so. I tried some other caps as well, all read low. What else could be upsetting the reading?

    (edit: actually, maybe I should crank the voltage up a little - it's set for exactly 5v, maybe it needs closer to 5.5v)
     

    Attached Files:

    Last edited: Aug 24, 2013
  10. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    Congrats on getting it up and running. :)

    Hmm, I'm not sure about why the calibration is out, reading 36nF on a 39nF cap is a fair size error. The osc is running about 7-8% fast. I assume you zeroed the meter before testing?

    I would leave the Vdd voltage at 5.0v, but add a decent sized tantalum (>=10uF) under the PIC on the bottom of the PCB right between the Vdd and Vss pins. If the PIC is not decoupled well with a cap then the Vdd might be pulled down as the comparator oscillator switches which could affect the 1/3 and 2/3 threshold points the comparator oscillates between. What tolerance are your 1k5 resistors?

    Otherwise if none of that helps it is no big deal, you just need to change the 10k resistor until you are happy it is right. As the oscillator period is linear to the cap value, changing the resistor to be correct at 39nF will make it pretty accurate across the whole range.

    Since your osc is running fast, all you need to do is add a 500 ohm or 1k trimpot in series with the 10k resistor (ie needs >10k), and adjust the trimpot until the meter reads exact. :)
     
  11. throbscottle

    throbscottle Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,808
    Likes:
    113
    Location:
    Nuneaton, Warwickshire, UK
    There's a 0.1uF SMD ceramic cap under the PIC, but I'll try stuffing a tantalum (or bigger ceramic) one under there. The 1k5 resistors are 1%. The crystal was in a pack of 2 - if better decoupling doesn't work maybe I should try the other one? Actually now I read a little, is it possible I have series cut crystal? The Microchip doc on oscillators says it must be parallel cut or the frequency might be off. I just got the cheapest ones, from here: http://www.ebay.co.uk/itm/111073542...eName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649 This is the datasheet: http://www.electro-tech-online.com/custompdfs/2013/08/hc49slf.pdf. Can't actually tell which I have.

    Of course it's possible I copied the schematic over to DesignSpark wrongly...

    Edit: since it's reading low, it it possible this is because I put a 220pF instead of the 270pF? Going to try 330 after I've had another hunt for a 270. Hey I now have a nearly working cap meter to help find one!
     
    Last edited: Aug 25, 2013
  12. throbscottle

    throbscottle Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,808
    Likes:
    113
    Location:
    Nuneaton, Warwickshire, UK
    Mystery solved. I cut and rerouted the track leading to the test lead pads after I realised it passed close to the oscillator, also added an extra decoupling cap to the vcc end of the top 1k5 divider resistor. So doing those increased the reading by 400pF - shows what a difference board layout can make!

    The biggest difference appeared when I tested some 2.5% and 5% caps which measured ok. Seems my 1% cap is out of tolerance. Duh. Suppose I should get a new one to test...

    Going to make a case for it now.

    Picture attached of the probe I made - someone might find it useful. The handle is cut from a piece of pipe from a household cleaner spray bottle.

    Oh yes, thanks for a great project, Roman :D
     

    Attached Files:

  13. killivolt

    killivolt Well-Known Member

    Joined:
    Mar 12, 2008
    Messages:
    3,213
    Likes:
    121
    Location:
    U.S.
    This ones going into my (Project list)

    Thanks, Roman.

    Good job, Throbs.
     
  14. throbscottle

    throbscottle Well-Known Member

    Joined:
    Feb 1, 2012
    Messages:
    1,808
    Likes:
    113
    Location:
    Nuneaton, Warwickshire, UK
    I mounted the pcb and display on a chassis, then made a box for it out of an old scanner lid. The zero button is from a biro, it pushes the tactile switch via a mis-align-able push rod. I made a test pad so it can be used for smd caps... See photos (I am very pleased with it!)

    (had to re-upload photos since they got lost with the site change)
     

    Attached Files:

    Last edited: Oct 24, 2013
  15. Sam007

    Sam007 New Member

    Joined:
    Oct 19, 2013
    Messages:
    2
    Likes:
    0
    Hi Roman, Your cap meter sounds great based on the reviews I've read! tried to simulate it with proteus but failed. was wondering if u ever tested it with proteus simulator ?
    my goal, is to build a capacitive fluid meter which requires a resolution of about 100pf.full schematics and source codes will be posted.
    Also, i'll re-write the firmware for your cap meter in C code and post it if you don't mind
    thank you and great job
     
  16. misterT

    misterT Well-Known Member Most Helpful Member

    Joined:
    Apr 19, 2010
    Messages:
    2,697
    Likes:
    368
    Location:
    Finland
    Failed how? That kind of application is very hard to simulate. If the simulator assumes perfect capacitor with no resistance, it will charge up instantly etc. I don't think that the simulation (interaction) between code and analog signals is very accurate in proteus.

    Your fluid meter project sounds interesting. I hope it goes well and that you post the results.
     
  17. Sam007

    Sam007 New Member

    Joined:
    Oct 19, 2013
    Messages:
    2
    Likes:
    0
    well it seems like what u v said. proteus is unable to simulate tricky things in analog mode. the lcd is always displaying error, large cap. the PIC opamp simulation is not working at all with proteus.
    regarding the fluid meter, all schemas and code will be posted online once done
     
  18. Neimocol

    Neimocol New Member

    Joined:
    Dec 7, 2013
    Messages:
    8
    Likes:
    1
    ..
     
    Last edited: Feb 5, 2014
  19. Neimocol

    Neimocol New Member

    Joined:
    Dec 7, 2013
    Messages:
    8
    Likes:
    1
    ....
     
    Last edited: Feb 5, 2014
  20. Neimocol

    Neimocol New Member

    Joined:
    Dec 7, 2013
    Messages:
    8
    Likes:
    1
    ....
     
    Last edited: Feb 5, 2014
  21. Neimocol

    Neimocol New Member

    Joined:
    Dec 7, 2013
    Messages:
    8
    Likes:
    1
    Does anyone know how to contact RomanBlack?

    I've been trying to locate an email-even on your web page without finding in http://www.romanblack.com/

    Thanks
     

Share This Page