Saturday, 20 July 2013

Arduino LC Meter Shield

A short distraction from the Signal Generator project to make an LC Meter Shield!

It has been a considerable time since I posted.  Blogging does not come naturally for me and I often prefer to just do things rather than write about them.  I still haven't finished the Signal Generator although to be honest it is close....I am lacking motivation.  I have pushed that project down a route which is no longer palatable... 

Instead I have decided I will write about a small project that I made recently which works well and was great fun (for me) to make and build.  I always need test equipment....it's a strange thing with Engineers...they need toys to make bigger toys!

In order to measure Capacitance and Inductance a piece of test equipment is often used called an LC Meter.  This is a device which measures the amount of Henries an inductor has (Henries is the unit of inductance) or the amount of Farads in a capacitor (Farads is the unit of capacitance).

Inductor - an electronic component that stores energy for a short period of time by generating a magnetic field - normally made by making a coil of wire around a former.  Sometimes special cores are used to improve the inductor's frequency response.  Inductors are sometimes called chokes!

http://en.wikipedia.org/wiki/Inductors

Capacitor - an electronic component that stores energy for a short period of time by producing an electrostatic field on two metal plates.  The size of the plates and the distance between the plates changes the amount the of capacitance the component will have.  The dielectric material between the plates also has an effect of the amount of capacitance.

http://en.wikipedia.org/wiki/Capacitor

I needed a way of verifying that the electronic components I bought or made are within the specifications I require!  Component manufacturers print the nominal level of what the inductor or capacitor is but this varies considerably between batches and is often considerably off.  Every good engineer needs a way of checking that parts are what they say they are...

There are plenty of hobbyist projects available on making an LC meter.  This is my interpretation.  If you do a search in google for 'LC meter circuit' several pages will be sourced immediatly.

I was directly inspired by Kerry Wong's blog post -

Kerry Wong's Blog about an LC Meter

There was also an article in Everyday Practical Electronics issue in March 2010 using a PIC Microcontroller.

I decided to make an LC Meter which uses the arduino shield form factor and is easy to make and use.  I'm hoping people will like it and use it...although most electronics hobbyists I know nowadays are all digital and no analogue - ho hum!

Most LC meter instruments use a free running oscillator at a known frequency.  When the user inserts the component in question in parallel with the oscilllator  the frequency changes. By comparing the new frequency with the old frequency and using some mathematics the value for the component can be obtained.

So....how do we make an oscillator?  There are several methods and I have discussed this in previous blog posts.  This project uses a comparator to make a square wave oscillator.  The circuit is below:



The oscillator section is made up of the 100uH inductor and the 4.7nF Capacitor.  These two components decide the frequency of oscillation.  All the other components are to make the oscillator work and to provide a method of making measurements.

The formula for calculating the frequency of oscillation and the other formulae used in the project are below:



lets calculate the frequency of our oscillator:

L = 100 uH or 100 * 10^-6 H
C = 4.7 nF or 4.7 * 10^-9 F
PI = 3.142..

Therefore F = 1 / 6.284 * SQRT (100*10^-6 * 4.7*10^-9)

F = 232.121 kHz

lets say 232 kHz.

So our oscillator will free run at 232 kHz using the above inductor and capacitor.  If we then introduce another component into the oscillation this frequency will change and we can use the original frequency and information about the oscillator components to calculate what value the new component has.

Here is a short simulation video showing how the measurement stage works:



Now that we have a method of measuring the components we need a way of controlling the circuit and displaying the information.

To this end I am going to use the popular arduino platform because its a great piece of hardware for rapid prototyping!  Here is the rest of the circuit:



The circuit is fairly boiler plate electronics.  The frequency of the oscillator is measured by the arduino on pin 5.  The firmware uses a special arduino frequency counter library - more on this later.  The type of measurement is controlled by a switch selecting which type of component is being measured and then we also have two buttons for displaying the current frequency of oscillation or measurement function (which controls a relay) and a calibration / zero button.  We finally have an 16x2 LCD display being controlled by the arduino to display the information.

Once I had prototyped the circuit and checked it worked - briefly I laid out a PCB and etched a circuit board.  Here is the layout:
Top Layer with component placement
PCB Bottom Layer

I then etched and drilled the PCB and populated it with components.  I was so excited I plugged it onto my arduino and tried to get it working straight away...It didn't but that's not surprising.  If a project works first time nobody learns anything!  Sometimes though I do wish projects would work first time - particularly at work!

The problems were minor and have been fixed in the layout so if I decide to make another version it will work first time - Here is a link to the Eagle files and other associated information:

Google Drive link to LC Meter Eagle project - LM339 version

Once I had checked that the oscillator was working with an oscilloscope I got on with writing the source code.  I'm not the best programmer in the world so I used a lot of other people's work to get this circuit to work as intended.  Kudos to Kerry Wong and his version of this project!

The reason this project is viable is because of the frequency counter library made and maintained by Peter Welter-Platz

http://interface.khm.de/index.php/lab/experiments/arduino-frequency-counter-library/

Its a great library and it makes it very easy for people to measure frequency of signals with their arduino.  Basically I believe the library works by comparing the frequency to be measured with one of the internal microcontroller timers.  The result is then stored and available for interrogation.

Here is the code...it's not perfect but it does work:

/*
  Langster's LC Meter Code - 19-07-2013
  Uses the LCD library, Frequency Library 
  Button libary and various other bits and pieces
  
  V1.0 
  
  This code borrows from Kerry Wongs LC Meter
  code!
  
  To Calibrate press both the Frequency and 
  Calibrate buttons together!
  
  To measure frequency press the frequency
  button
  
  Enjoy!
   
 */

// Include the Frequency counter library
#include <FreqCounter.h>

// Include the Button Library
#include <Button.h>

//part of the switch position check
enum meterMode {
    L,
    C,
    F
};

unsigned long indFreq = 23896;   //rough frequency from oscilloscope measurements
unsigned long capFreq = 23885;   //rough frequency from oscilloscope measurements

long measureComponentFreq = 0;   //variable to store component measurement frequency

float cMeasured;                 //Th measured capacitance
double lMeasured;                //The measured inductance

float cMeasuredZero;             //The zero factor for capacitance
double lMeasuredZero;            //The zero factor for inductance

//Some temporary variables for calculations

long temp1;
long temp2;
double temp3;

const float Cth = 4.7 * 1e-9;    //measured 4.7nF - calibration capacitor value
const float Lth = 91.14 * 1e-6;  //measured 91.14uH - calibration inductor value

int i=0;                         // count variable
int switchState;                 // variable for storing the state of the switch

unsigned long frq;               //The frequency measurement
long capFreqArray[10];           //An array for storing frequencies
long indFreqArray[10];           //An array for storing frequencies

long frqAverage = 0;             //An variable for averaging
long average = 0;                

const int frequencyButtonPin = 16;     // the number of the pushbutton pin
const int calibrateButtonPin = 15;     // the number of the pushbutton pin
const int relayPin = 14;               // the number of the relay pin
const int componentSelectPin = 2;      // the number of the component select pin
const float pi2=6.283185307;

Button calibrationButton = Button(15);  //Calibration button on pin 15 or A1
Button frequencyButton = Button(16);    //Frequency button on pin 16 or A2

meterMode currentMode;                  //check which mode the switch is in

// include the LCD display library:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

//Check the switch position

void checkLCMode() {  
    
    switchState = digitalRead(componentSelectPin);
    
    if (switchState==LOW) {
        currentMode = L;
        lcd.setCursor(0, 0);
        lcd.print("Mode: L    ");
        measureInductance();
        
    } else {
        currentMode = C;
        lcd.setCursor(0, 0);
        lcd.print("Mode: C    ");
        measureCapacitance();
    }

}

//setup the arduino

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);

  pinMode(relayPin, OUTPUT);
  
  pinMode(calibrateButtonPin, INPUT);
  pinMode(frequencyButtonPin, INPUT);
  pinMode(componentSelectPin, INPUT);
  
  digitalWrite(componentSelectPin, HIGH);
  
  Serial.begin(57600);        // connect to the serial port
  digitalWrite(relayPin, HIGH); 

  lcd.setCursor(0, 0);
  lcd.print(" ** LC Meter ** ");
  
  //measureCalibrationCapacitance();
  //measureCalibrationInductance();
    
  delay(2000); 
  
  lcd.clear();
   
}  

void loop()
{
  //check if calibration is required
  
  if(calibrationButton.isPressed() && frequencyButton.isPressed())
  {
    switchState = digitalRead(componentSelectPin);
    
    if (switchState==LOW) 
      {
          currentMode = L;
          lcd.setCursor(0, 0);
          lcd.print("Short Terminals");
          lcd.setCursor(0, 1);
          lcd.print("Press Cal Button");
          
          if(calibrationButton.isPressed())
            {
              measureCalibrationInductance();
            }
  
      } 
    
    if (switchState==HIGH) 
  
      {
          currentMode = C;
          lcd.setCursor(0, 0);
          lcd.print("Clear Terminals");
          lcd.setCursor(0, 1);
          lcd.print("Press Cal Button");
          
          if(calibrationButton.isPressed())
            {
              measureCalibrationCapacitance();
            }
      }
      
  }
  
  //check if frequency measurement is required
  
  if(frequencyButton.isPressed())
      {
        measureFrequency();
        digitalWrite(relayPin, HIGH);
      }

checkLCMode();    //check switch position
  
  
}

//Measure the frequency

void measureFrequency()
{

    digitalWrite(relayPin, LOW);
  
    FreqCounter::f_comp=10;   // Cal Value / Calibrate with professional Freq Counter
    FreqCounter::start(100);  // 100 ms Gate Time
    while (FreqCounter::f_ready == 0) 
    frq=FreqCounter::f_freq;   
    
    lcd.setCursor(0, 0);
    lcd.print("Frequency ");
    
    lcd.setCursor(0, 1);
    lcd.print("F: ");
    lcd.print(frq);
    lcd.print("      ");
     
    delay(4000);
    
}

//Calibrate for inductance measurements

void measureCalibrationInductance(){

    for (int i=0; i<100; i++)
        
        {
          FreqCounter::f_comp=10;   // Cal Value / Calibrate with professional Freq Counter
          FreqCounter::start(100);  // 100 ms Gate Time
          while (FreqCounter::f_ready == 0) 
          frq=FreqCounter::f_freq;
          indFreq=frq;
          
          temp1 = sq(indFreq);
          temp2 = sq(measureComponentFreq);
          temp3 = float(temp1)/float(temp2);
          lMeasured = Lth*(temp3-1);
          lMeasuredZero = lMeasured;
          i++;
          
        }
      
      lcd.setCursor(0, 0); 
      lcd.print("Calibration     ");
      lcd.setCursor(0, 1);
      lcd.print("Complete        ");
      delay(4000);
      
      lcd.clear();
    
}

//Measure the inductance

void measureInductance()

{
      FreqCounter::f_comp=10;   // Cal Value / Calibrate with professional Freq Counter
      FreqCounter::start(100);  // 100 ms Gate Time
      while (FreqCounter::f_ready == 0) 
      frq=FreqCounter::f_freq;
      measureComponentFreq=frq;
      
      delay(200);
      
      calcIndData();

}



//Calculate and Display the Inductance

void calcIndData(){
    
    temp1 = sq(indFreq);
    temp2 = sq(measureComponentFreq);
    temp3 = float(temp1)/float(temp2);
    lMeasured = Lth*(temp3-1) - lMeasuredZero;
    
    lcd.setCursor(0, 1);
    lcd.print("L: ");    
        
     if (lMeasured >= 1e-9 && lMeasured < 1e-6) 
            {
                lMeasured = lMeasured * 1e9; // nano
                lcd.print(lMeasured);
                lcd.print(" ");
                lcd.print("nH");
                lcd.print("        ");
            } 
            
            if (lMeasured > 1e-6 && lMeasured < 1e-3) 
         
            {
                lMeasured = lMeasured * 1e6; // micro
                lcd.print(lMeasured);
                lcd.print(" ");
                lcd.print("uH");
                lcd.print("        ");
            }
            
            
            if (lMeasured > 1e-3) 
            
            {
                lMeasured = lMeasured * 1e3; // milli
                lcd.print(lMeasured);
                lcd.print(" ");
                lcd.print("mH");
                lcd.print("        ");
            }
  
}  

//Measure the Calibration Capacitance

void measureCalibrationCapacitance()
{
  for (int i=0; i<100; i++)
        {
          FreqCounter::f_comp=10;   // Cal Value / Calibrate with professional Freq Counter
          FreqCounter::start(100);  // 100 ms Gate Time
          while (FreqCounter::f_ready == 0) 
          frq=FreqCounter::f_freq;
          capFreq=frq;
          
          temp1 = sq(capFreq);
          temp2 = sq(measureComponentFreq);
          temp3 = float(temp1)/float(temp2);
          cMeasured = Cth *(temp3-1);
          cMeasuredZero = cMeasured;
          i++;
        }
     
     lcd.setCursor(0, 0); 
     lcd.print("Calibration     ");
     lcd.setCursor(0, 1);
     lcd.print("Complete        ");
     delay(4000);
     
     lcd.clear();
     
}


//Measure the capacitance

void measureCapacitance(){
    
      FreqCounter::f_comp=10;   // Cal Value / Calibrate with professional Freq Counter
      FreqCounter::start(100);  // 100 ms Gate Time
      while (FreqCounter::f_ready == 0) 
      frq=FreqCounter::f_freq;
      measureComponentFreq=frq;
      
      delay(200);
      
      calcCapData();
    
}

//Calculate and display the capacitance
  
void calcCapData(){
    
    temp1 = sq(capFreq);
    temp2 = sq(measureComponentFreq);
    
    temp3 = float(temp1)/float(temp2);
    cMeasured = Cth*(temp3-1)-cMeasuredZero;
    
    Serial.print("Capacitor Oscillator Frequency: ");
    Serial.print(capFreq);
    Serial.println();
    Serial.print("Component Oscillator Frequency: ");
    Serial.print(measureComponentFreq);
    Serial.println();
    Serial.print("Cap Osc Squared: ");
    Serial.print(temp1);
    Serial.println();
    Serial.print("Msr Osc Squared: ");
    Serial.print(temp2);
    Serial.println();
    Serial.print("Division       : ");
    Serial.print(temp3);
    Serial.println();
    Serial.print("Component Value: ");
    Serial.print(cMeasured);
    Serial.println();
    
       
    lcd.setCursor(0, 1);
    lcd.print("C: ");
        
     if (cMeasured < 1e-9) 
            {
                cMeasured = cMeasured * 1e12; // pico
                lcd.print(cMeasured);
                lcd.print(" ");
                lcd.print("pF");
                lcd.print("       ");
            } 
            
     if (cMeasured >= 1e-9 && cMeasured < 1e-6) 
            
            {
                cMeasured = cMeasured * 1e9; // n
                lcd.print(cMeasured);
                lcd.print(" ");
                lcd.print("nF");
                lcd.print("       ");
            }  
            
      if (cMeasured > 1e-6)      
            {
                lcd.print("Out of Range");
                lcd.print("        ");
            } 
    
} 

It's long and it isn't pretty but it should be fairly simple to understand.  The program sets up the libraries, variables and the buttons and LCD display.  It then looks at which position the user component select switch is in and then performs the required measurement.  If the user presses the frequency button the current frequency of the oscillator is displayed.  If the user presses and holds both buttons and then follows the on screen instructions the unit calibrates.  In order to calibrate the L mode the input terminals have to be shorted together.  For capacitance mode the terminals must be open and not connected to anything.

Here is a video of the completed unit running on my arduino Uno in use.



There are things about the LC meter that I would do differently - there always are!  I would prefer the device to have a larger measurement range - Inductors are ok but the capacitance range of up to 1 µF is not helpful.  I often like to measure electrolytic capacitors and this unit can't do that.  In order to achieve that I need to implement a frequency divider circuit on the measurement frequency pin so that I can then use a smaller measurement capacitor which increases the range.  I would also like to add another relay which automatically shorts the measurement terminals so that when calibrating the inductor range the user doesn't have to short the terminals.  All told though this came out very well! 

Update: I got some valuable feedback from a reader who asked if it would be possible to implement the analogue section using a dual comparator.  It is possible and I have selected the LM393 dual comparator to do this.  Here is the full schematic:



I hope this helps people make their own versions of the circuit!  Here is a link to the LM311 Eagle Files:

LC Meter - LM311 Version Eagle Files

Further Updates:

I have had some feedback from quite a few people regarding this post...my most popular project yet! I have decided to help out by giving the bill of materials:


All of the part numbers are for Farnell Electronics.  I suggest people shop around for various parts as they can be found cheaper elsewhere - particularly the 16x2 LCD display and the Arduino.

Here is some 3D renders of the circuit I made using Eagle and Sketchup! I also made a case which can be 3D printed.







Update - A lot of people have been building this project (which is great!) but are sometimes struggling to check things are working as intended. If you have access to an oscilloscope you can measure the oscillation frequency by connecting the oscilloscope probe ground lead to any 0V reference on the circuit (I use the ground plane normally) and then connect the probe tip to pin 2 of the LM339 or pin 3 of an LM311.  Ensure that the measurement terminals are open (nothing is connected to them and the unit is in capacitance mode.  If the same 100 uH inductor and 4.7 nF capacitor have been used it should be possible to see the following waveform:

LC Meter Oscillator on Pin 2 with terminals open
If you want you can then short the terminals together and change the select switch and you should see exactly the same waveform!

The oscilloscope was set to 5 volts / division on the Y axis and the time base was set to 2 micro-seconds per division for the X axis.  The trigger level was set to 1 Volt and the channel was set to measure a DC signal.  Good Luck!

31 comments :

  1. Awesome job... however some top view pictures of the real board would help some of us readers.. just a thought Also I am going to attempt to put this in a protoshield...

    ReplyDelete
    Replies
    1. Hi thanks for commenting. I struggled to get this to fit all on one protoshield. If you used surface mount components it might be possible. It could be done on two protoshields stacked with through hole components. I should have thought of this before. I will add some pictures of the populated PCB as requested. - Thanks for looking at my blog!

      Delete
  2. Hi! Very good job. I have a question for you.
    LM339N is Quad single Supply Comparator. I see from schematics that you use only 2 comparators.
    Can I replace this component with a simple double comparator? If so, which component would you recommend?
    Thanks.
    (Sorry for my bad english!)

    ReplyDelete
    Replies
    1. Hi, you could replace the quad comparator with a dual comparator. I can redraw the schematic for you if you like. I quickly looked up on google for a dual comparator and came up with the LM393 from Texas Instruments. I have put a link to the datasheet below. You will need to lay out your own PCB or use veroboard to construct the circuit. I would 'breadboard' the analogue comparator section first to make sure this works ok.

      http://www.ti.com/lit/ds/symlink/lm393-n.pdf

      Best of Luck and thanks for reading my blog - Alex

      Delete
    2. Thanks for the reply!! I'll wait for you to do the tests.
      God Bless You!

      Delete
    3. Nio....I have redrawn the schematic for you using the LM393 comparator. I haven't time to breadboard the circuit myself but I know it will work. I have simulated it and it works perfectly..I hop this helps!

      Delete
    4. This comment has been removed by the author.

      Delete
    5. Langster, wonderfull!!
      I still need your help.
      1) Capacitor C1 is 10nF or 100nF?
      2) What features should have the components? (tolerance, stability, etc.)
      3) It seems that the initial wiring diagrams are different from the last diagram regarding the switching of the relay .. I do not understand the switching of the relay. But maybe I'm wrong ... Could you help me?
      I still want to thank you for your time and for your kindness!
      God Bless you!

      Delete
    6. Nio,

      Fair questions!

      I changed the C1 value to 10nF. It can be any value you like below 100nF. The lower the value the higher the frequency the free running oscillator will have.

      All resistors must be their stated value and 0.25W power rated with a 5% tolerance
      The inductor must be it's stated value and a 5% tolerance and 0.25W power rated
      All capacitors must be voltage rated for use at 5V - most are 50V tolerant for ceramic types
      Electrolytic capacitors these days are 25V or 50V rated.

      The schematic is slightly different. I put the relay on the same sheet as the analogue section. It makes all of the same connections to the arduino. I will draw the entire schematic on one sheet for you. I haven't time to lay out another PCB. If you want I will make the eagle schematic file available to you so you can use it to make your own PCB

      Delete
    7. Hi,
      Thank you for all, now everything is clear!!
      God Bless You!

      Delete
  3. Hi Langster,
    I have build circuit on breadboard but there is something wrong.
    The oscillator seems crazy and fails to be stable. Its value is about 137kHz. I can not measure anything.
    I tried to make the connections as short as possible and I redid the circuit at least 10 times. What could have happened? Please could you draw the circuit diagram with eagle when you have some time? Thank you again.
    God Bless You!
    Antonio.

    ReplyDelete
    Replies
    1. Hi Antonio,

      I have added the full schematic for you as requested. I also am going to build the analogue section on a breadboard. That way I can be sure the oscillator works as intended. I will add a video once I have it set up. Sorry for the delay, I'm a busy man!

      Alex

      Delete
    2. Antonio, I have also added a Youtube video showing my breadboarded analogue section using the LM393. Hope this helps....don't give up it does work!

      https://www.youtube.com/watch?v=v3fyIyBD2RU

      Cheers

      Alex

      Delete
  4. Hi Alex!!
    I've rebuild my circuit. I've found the problem!
    To measure the frequency of the output of the comparator (IC1A), I had used the entry of IC1B. But the LM393 has an "open collector" output, and I had to put a pullup resistor (1,5K) between pin 7 and 5V. Now everything works fine!!!

    I need to know sometingh about the code.
    If I want to change L's and C's values wich line of the code i must change?
    I think surely these:
    const float Cth = 4.7 * 1e-9; //measured 4.7nF - calibration capacitor value
    const float Lth = 91.14 * 1e-6; //measured 91.14uH - calibration inductor value.

    But what is the meaning of these lines?:
    unsigned long indFreq = 23896; //rough frequency from oscilloscope measurements
    unsigned long capFreq = 23885; //rough frequency from oscilloscope measurements
    I need to change these lines too?
    What else should I change?

    Alex, I want to thank you for all the time you are spending for me!
    God bless you!
    Antonio





    ReplyDelete
    Replies
    1. Antonio, Apologies for the delay in response.

      If you change the value of the L1 Inductor then the line below must be changed to suit that value:

      const float Lth = 91.14 * 1e-6; //measured 91.14uH - calibration inductor value.

      the same must also be done if you change the value of C1:

      const float Cth = 4.7 * 1e-9; //measured 4.7nF - calibration capacitor value

      The line

      unsigned long indFreq = 23896; //rough frequency from oscilloscope measurements

      Is a long variable which holds a measurement I made of my circuit. I got an oscilloscope and measured the frequency of the oscillator with the inputs shorted together. I stored this value in the code although it isn't used anywhere it was just a note for me!

      The same is true for this line:

      unsigned long capFreq = 23885; //rough frequency from oscilloscope measurements

      You don't need to put them in the code at all and can comment them out.

      Best of Luck

      Alex

      Delete
    2. This comment has been removed by the author.

      Delete
    3. This comment has been removed by the author.

      Delete
    4. Mac, i have had a look at the code and I was wrong to say that you can comment out the lines:

      unsigned long indFreq = 23896; //rough frequency from oscilloscope measurements
      unsigned long capFreq = 23885; //rough frequency from oscilloscope measurements

      You can set these to zero. I would change the lines to the following:

      unsigned long indFreq = 0; //variable for storing oscillator frequency when in L mode
      unsigned long capFreq = 0; //variable for storing oscillator frequency when in C mode

      The numbers stored in the variables are then set at the moment the circuit is switched on depend on external factors that I can't control. What the user should then do is calibrate the circuit before performing measurements by holding down the two buttons in either the L or the C mode. If in the L mode then the terminals must be shorted together. The firmware then records the value of indFreq or capFreq and uses them in the later calculations.

      I'm guessing as you have deleted your comments I'm guessing you worked this out for yourself. Best of Luck - Langster

      Delete
    5. Thank You!. Yes I have deleted the comments bcos I was able to debug the code and set those variables to zero and it works.

      Delete
    6. Mac,

      Glad to hear you have it working. I am in the process of designing a 3d printed case for this project. I might do a blog post of that when I have time. It's always nice to completely finish something off. Send me a picture of your circuit working sometime?

      Cheers

      Langster

      Delete
    7. I will send u the circuit. I have some problem though. The inductance measurement is OK but the capacitance measurement is not stable and have higher error margins. I am undertaking some troubleshooting on the circuit and program.
      But I'll be glad if U could help answer the following question;
      -> Why is the frequency change for a newly added capacitor not stable. I know the frequency counter automatically updates every second but the change in frequency should be marginal as in the case for inductor measurements.

      Your next line of action on this project (designing a 3d printed case) is in the right direction. Good luck!

      Delete
    8. Mac,

      I am not sure why the capacitance measurement would be unstable. It doesn't appear to be in my realisation of the circuit. I am building another meter in the next week or so. I will check both versions and see if the problem appears. It sounds as if you are getting some drift in the measurement capacitor. I used a mica film capacitor for the measurement capacitor to ensure the measurement portion of the circuit was more accurate. If you breadboarded the circuit you may having issues due to extra introduced capacitance from the wiring etc.

      This capacitor from Farnell Electronics would be suitable:

      http://uk.farnell.com/epcos/b32529c1102j189/capacitor-film-1000pf-100v-5-rad/dp/2367340

      Delete
    9. Hello Langster!
      The problem was due to the fixed (reference) capacitor that I used which U've also alluded to. When I changed it to a 1.5nF capacitor with a tolerance of 1%, the measurement then looks better. Thank You!
      Below is the picture of a 22pF capacitor measurement after the correction was made.

      http://www.datafilehost.com/d/cc891e14

      Bare with me whiles I use a 2nd party website for uploading the image. I don't know how to upload it directly into the forum. Regards!

      Delete
    10. Hi Mac,

      Well done, I'm glad my advice helped you fix the issue. I notice you have used strip board for making your version. If you were to use a proper printed circuit board with a ground plane you might find the circuit works better.

      I should really provide a parts list for this circuit as it would appear people like yourself are building it!

      I notice three T0220 packages on your version of the LC meter. One I am assuming is a transistor to drive the relay and the other two are voltage regulators?

      I also notice that you have used a natively programmed atmel328p microcontroller. How are you uploading the firmware? I didn't see a programming header.

      If you like I can send you a blank PCB of my version...I have a spare PCB.

      Cheers

      Alex - Langster

      Delete
    11. Well, the other two T0220 packages are LM7805 and LM7812 voltage regulators which I used to provide constant 5VDC to the microcontroller and 12VDC to the relay respectively.
      The one in-front of the relay, is a TIP122 Darlington transistor used to drive the relay as U said.

      As for the ATMEGA328P microcontroller, I program (upload firmware) using Arduino Uno. After the programming is done, I then remove the chip and place it in the circuit.

      Thanks!

      Delete
  5. I recently built another of these LC meters and have made some changes to the information above. In my version I used a 4.7nF capacitor for C1 and a 100uH inductor for L1. This is to ensure that the firmware provided works without modification. I also found that using a higher value capacitor for C1 reduces the top range of the capacitance measurement from up 1uF to about 500nF. I will always want to increase the top range of the measurement and short of redesigning the circuit to include a frequency divider this is the best option.

    Cheers

    Alex - Langster

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
  7. apakah kode nya valid.. Karna saya memasukan kode tersebut error

    ReplyDelete
    Replies
    1. Maaf, Anda mengalami masalah dengan kode. Sudah sangat lama sejak saya melihat kode. Saya masih memiliki perangkat keras di suatu tempat. Saya akan menggali dan mencoba dan membuatnya bekerja untuk Anda.

      Delete
  8. Hello. Will this circuit requires a general change for ESP32 instead of Arduino?

    ReplyDelete
    Replies
    1. I haven't had much experience with ESP 32 so I'm not 100% certain. The esp32 has the required analogue to digital converter so the oscillator section can be directly connected. The issue is the frequency measurement code was not written with the ESP 32 in mind. I have not tested it and have no idea whether it would work. I will try it and get back to you...It may work fine without issue. You could try it yourself and see what happens.

      Delete