## AVR LC Meter With Frequency Measurement

I have been thinking about building an LC meter for a while since I do not have a multimeter that is capable of measuring inductance and while the multimeters I have can measure capacitance, they are not able to give accurate readings for small capacitance in the range of several pF’s.

There are quite a few good articles on how to build LC meters using PIC MCUs (like the ones here: 1, 2, 3), but instructions on how to build one with an ATmega MCU are few and far in between, although the basic principle is largely the same. So I decided to write this article on how to build an LC meter using an ATmega328p chip and Arduino libraries.

A typical LC meter is nothing but a wide range LC oscillator. When measuring an inductor or capacitor, the added inductance or capacitance changes the oscillator’s output frequency. And by calculating this frequency change, we can deduce the inductance or capacitance depending on the measurement.

The following schematic shows the comparator based LC oscillator I used in the LC meter. The oscillator portion is quite standard. Most of the other designs I have seen use LM311 comparator. But for this type of application, any comparator capable of oscillating up to 50kHz should be more than sufficient. I happen to have some spare LM339’s lying around so I used it in the oscillator circuit.

LC Meter - Oscillator

Note, there should be a 3K pull up resistor on pin 1 and the feedback resistor should be 100K instead of 10K.

Because what we are really meausring is the frequency of the oscillator, we can build a frequency meter using the same circuit at almost no additional cost. As you can see in the circuit above, a reed relay is used to switch the measurement from LC mode to frequency mode. In the schematics above, the second comparator forms a Schmitt trigger to condition the input waveform so that the frequency measurement can be made more accurate. When in the LC mode, the frequency output from the first comparator is simply feed through the Schmitt trigger. The output frequency is determined by
$f_0=\frac{1}{2\pi\sqrt{LC}}$

where
$L=L_0 + L_{measured}$ and
$C=C_0 + C_{measured}$

Choosing a high accuracy L0 and C0 helps improve the accuracy of the meter.

Here’s the MCU side of the schematics:

LC Meter

This circuit is capable of measuring inductance in a wide range, from a few nH all the way up to a few Henrys. For capatance measurement, I have found that it is most suitable for measurement from a few pF to tens of nF. You maybe able to measure slightly larger capacitors if they have a high ESR rating. But this range limit in capacitance measurement should not be an issue as what we care most about is the accuracy in the pF range.

I used this frequency library for the frequency measurement. By default, the display is updated every second. This mode provides the most accurate result. You can shorten this update interval easily, but the measurement accuracy will be reduced.

The Arduino code for this project can be downloaded here (LCFrequencyMeter.zip). This project was developed using the NetBeans IDE and you may need to adjust the included header files if you are using Arduino IDE. For more information, please see my previous article on this topic.

The calibration method I used is like this: in capacitance measurement mode, the none-load reading is used to calculate stray inductance (assume that C0 is accurate) which is then used to compensate capacitance measurements. And similarly, in inductance measurement mode, we assume that L0 is accurate and the none-load reading (by shorting the test leads) is used to calculate stray capacitance which is then used to compensate inductance measurements. If you read through the code you will get a better idea on how this is done.

The following picture shows the capacitance reading when using this meter to measure a known 2.22nF capacitor:

Capacitance Measurement

And this picture shows the LC meter in inductance mode, measuring a small inductor:

Inductance Measurement

Here is a picture showing frequency measurement. The frequency source is a 555 timer generated square wave:

Frequency Measurement

Within a selected mode, the display is auto ranged for the components/frequencies under measurement.

Be Sociable, Share!

1. xraid says:

Hi,

I am interested in building this, there seems to be a mismatch of code and schematics, there is a missing code for the backlight circuit going to pins 16-pb2 and 23-pc0 …

do you have it handy ?

some kind of spec for the relay in the “MCU side of the schematics:” would be most welcome … as i do not understand what part that would be … partly because as the code for that part is missing ;-) …

thanks

• kwong says:

Hi Xraid,

The code uses the standard Arduino library, and the pinout are slightly different then the chip pinout. Please refer to (http://www.arduino.cc/en/Hacking/PinMapping) for more information. Pin 14- Pin 19 correspond to the analog pin 0 to 5.

In the code for this LC meter, the relay is controlled by pin 14 (analog pin 0, which is pin 23 of the chip in the diagram) and the backlight is controlled by pin 10 (which is pin 16 in the diagram).

The relay is used to switch between the LC mode and Frequency measurement mode automatically and you can use any kind of SPDT relays.

2. xraid says:

yes i got that . but not the circuit part for the pins 16-pb2 and 23-pc0, that is for regulating the LCD DRIVING VOLTAGE …

there is no code for it ? …

• kwong says:

Check the variable pinRelay (Arduino pin 14) and pinBACKLIGHT (Arduino pin 10) and those are the two pins controlling the LCD back light and the relay.

Not sure what you mean by “regulating the LCD driving voltage”. The HD44780 compatible LCDs can be driven by either TTL or CMOS voltage level and the backlight can be powered directly (some does require a current limiting resistor) by 5-6V DC supply.

Hope this helps.

3. xraid says:

ahhh . k let me try … i dident get that the relay is the same relay as in the oscillator schematic and how its connected to the relay in the mcu schematic …

4. Zack says:

I’m in the process of building this awesome circuit, thanks for sharing!!! I do have one question so far though. Looking at the “LC Meter – Oscillator” schematic, I’m a bit lost on the relay portion at L/C-Freq. How is the coil of the relay hooked up/activated? I only see where the switching contacts are in this schematic. What does the coil connect to? Thank you.

• kwong says:

Hi Zack,

The relay coil is activated via analog pin 0 (see code, it corresponds to pin 14 since I used it as a digital pin). If you look at the circuit, it is connected to the NPN transistor on the left.

5. Paul says:

Looks remakably like elmcie (with an atmega8).

• kwong says:

There probably aren’t that many different ways to achieve this to begin with. Yes, the basic principal is the same. One minor difference would be the included Schmidt Trigger.

6. Stanley says:

Hi, thanks for publishing the diagrams for the LC/Freq meter for AVR/Arduino…

Can you also list all the components needed to make this meter assuming we are using an Arduino UNO board.

I’ve done the LCD portion, so no issues wiring that part, I’m quite confused and could not understand the LC oscillator portion of the circuit..

Can you explain more details about the LC Oscillator portion of the circuit ?

Is the Freq going to Pin 5 or Pin 2 on the circuit…

Perhaps some pictures ?

Thank you

• kwong says:

The frequency output (to the far right of the op-amp schematic) goes to Arduino pin 5, and the switch (far left towards the bottom) goes to pin2. Pin2 (in the MCU schematic marked with L/C Switch Sense) is used to sense the position of the switch (i.e. in L or in C mode). Hope this helps.

7. Nishank says:

Hi Kwong,

My name is Nishank and I am working on building a LC meter myself. However, much to my distress, i am not allowed to use the microprocessor that you used but i am allowed to use an 80C188 microprocessor and also, we are not allowed to use a 555 timer, however, we are required to use the timer of the microprocessor itself to measure the frequency. do u have any solution. any help would be greatly appreciated.

regards
Nishank

8. hayankata says:

can we use ATmega168(DUEMILANOVE) instead of ATMEGA328P.

• kwong says:

Yes, the program will fit on an ATmega168 as well. As long as the MCU frequency is set to the same (in this case, 16MHz) nothing else needs to be changed.

9. hayankata says:

what is the range of Frequency measurement.

• kwong says:

The max measurable frequency is 8MHz (50% duty cycle). For other waveforms, the max frequency will be much lower.

10. Pete says:

is it just me… or does the schematic and the circuit not match. When I ground pin 2… as it shows in diagram… I go int L mode… not C mode.

11. vigulas says:

hello, i would probably start to ask a little help but i think i need a lot of help….
i´m just trying to set up this nice project but i know almost nothing about programming….:S
i tryed to compile this file on arduino software and even after a few changes on #include line e keep having the same error….:
In file included from LCFrequencyMeter.cpp:16:
d:/arduino/arduino-0022/hardware/tools/avr/lib/gcc/../../avr/include/math.h:439: error: expected unqualified-id before ‘double’
d:/arduino/arduino-0022/hardware/tools/avr/lib/gcc/../../avr/include/math.h:439: error: expected )’ before ‘double’
d:/arduino/arduino-0022/hardware/tools/avr/lib/gcc/../../avr/include/math.h:439: error: expected )’ before ‘double’
yeh…im just a big lame on this but do you think you could give a big little help?(if you think it is possible due to my so lame programming skils…:D )
best regards

• kwong says:

Could you post your code so I can take a look at? Thanks.

• vigulas says:

hello many thanks for the so quickly reply :D
the code is no mine (i wish i would have half of that skills….) the code i just downloaded from the link you´ve posted:

/**
* AVR LC/Frequency Meter
* Kerry Wong
* http://www.kerrywong.com
*/

#define __AVR_ATmega328P__

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

enum MeterMode {
L,
C,
F
};

//Frequency input is digital pin 5

const int pinRS = 3;
const int pinEn = 4;
const int pinD4 = 16;
const int pinD5 = 17;
const int pinD6 = 8;
const int pinD7 = 9;
const int pinBACKLIGHT = 10;

const int btn1 = 0;
const int btn2 = 1;
const int btn3 = 2;

const int pinBtn1 = 11;
const int pinBtn2 = 12;
const int pinBtn3 = 15;

const int pinRelay = 14;
const int pinLCMode = 2;

float F0 = 348000;
const float Cth = 1000 * 1e-12; //theoretical 1000pF
const float Lth = 221 * 1e-6; //theoretical 221uH

boolean backLightOn = false;
boolean dispFreq = false;

float l0 = Lth;
float c0 = Cth;
MeterMode currentMode;

LiquidCrystal lcd(pinRS, pinEn, pinD4, pinD5, pinD6, pinD7);
unsigned long frq;

const int BTN_PINS[] = {pinBtn1, pinBtn2, pinBtn3};
boolean btnPressed[] = {false, false, false};

void delayMilliseconds(int ms) {
for (int i = 0; i < ms; i++) {
delayMicroseconds(1000);
}
}

boolean buttonPressed(int btnIdx) {
if (digitalRead(BTN_PINS[btnIdx]) == LOW && !btnPressed[btnIdx]) {
delayMilliseconds(20);
btnPressed[btnIdx] = true;
return true;
}
}

return false;
}

boolean buttonRleased(int btnIdx) {
if (digitalRead(BTN_PINS[btnIdx]) == HIGH && btnPressed[btnIdx]) {
delayMilliseconds(20);
btnPressed[btnIdx] = false;
return true;
}
}

return false;
}

float calcV(float f, float VRef) {
float v = 0;

v = ((F0 * F0) / (f * f) – 1.0) * VRef;

return v;
}

void checkLCMode() {
lcd.clear();

currentMode = L;
lcd.print("Mode: L");
} else {
currentMode = C;
lcd.print("Mode: C");
}

if (dispFreq) {
lcd.setCursor(0, 0);
lcd.print("Frequency: ");
}
}

void setup() {
for (int i = 0; i < 3; i++) {
pinMode(BTN_PINS[i], INPUT);
digitalWrite(BTN_PINS[i], HIGH);
}

pinMode(pinLCMode, INPUT);
digitalWrite(pinLCMode, HIGH);

pinMode(pinBACKLIGHT, OUTPUT);
digitalWrite(pinBACKLIGHT, LOW);

pinMode(pinRelay, OUTPUT);
digitalWrite(pinRelay, LOW);
lcd.begin(16, 2);
checkLCMode();
}

void displayFreq(long fin) {
lcd.setCursor(0, 1);

float f = 0;
if (fin = 1000) {
f = ((float) fin) / 1000.0;
lcd.print(f, 3);
lcd.print(” KHz”);
}
}

void displayV(long fin) {
float f = (float) fin;
float v = 0;
lcd.setCursor(0, 1);

switch (currentMode) {
case C:
v = calcV(f, c0);

if (v = 1e-9 && v < 1e-6) {
v = v * 1e9; // n
lcd.print(v);
lcd.print(" ");
lcd.print("nF");
} else {
lcd.print("—");
}
break;
case L:
v = calcV(f, l0);

if (v = 1e-6 && v = 1e-3 && v = 1 && v < 100) {
lcd.print(v);
lcd.print(" ");
lcd.print("H");
} else {
lcd.print("—");
}
break;
case F:
break;
}

}

void loop() {
FreqCounter::f_comp = 106;
FreqCounter::start(1000);
frq = FreqCounter::f_freq;

checkLCMode();

if (buttonPressed(btn1)) {
backLightOn = !backLightOn;
if (backLightOn) {
digitalWrite(pinBACKLIGHT, HIGH);
} else {
digitalWrite(pinBACKLIGHT, LOW);
}
} else if (buttonPressed(btn2)) {
switch (currentMode) {
case C:
c0 = calcV(frq, Cth) + Cth;
F0 = frq;
break;
case L:
l0 = calcV(frq, Lth) + Lth;
F0 = frq;
break;
default:
break;
}

lcd.print(" Cal");
} else if (buttonPressed(btn3)) {
dispFreq = !dispFreq;

if (dispFreq)
digitalWrite(pinRelay, HIGH);
else
digitalWrite(pinRelay, LOW);
}

if (dispFreq)
displayFreq(frq);
else
displayV(frq);

for (int i = 0; i < 3; i++) {
if (buttonRleased(i)) {
//the button is released, no action is necessary.
}
}
}

many thanks
best regards

12. vigulas says:

i don´t know why but on the beginig the code start with the include line where there sould be:
#include interrupt.h
#include binary.h
#include HardwareSerial.h
#include pins_arduino.h
#include WConstants.h
#include wiring.h
#include wiring_private.h
#include math.h
#include WProgram.h
#include EEPROM.h
#include LiquidCrystal.h
#include FreqCounter.h
all the *.h are between

sorry
thanks

• kwong says:

I don’t know if this is due to the particular version of the avr-gcc that your version of Arduino is using or not but on the Arduino forum (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1247924528/3) there is a suggestion to include the following code to fix this error (I haven’t tried. I did not run into this issue using the code supplied):

#undef int
#undef abs
#undef double
#undef float
#undef round

If you google your error, it seems that this is quite common among other users.

13. vigulas says:

hum….i´ve tryed to had that lines and didn´t work…
had a look on google and found lots of problems and no solutions :D
i just took out all the #define and then run compiling
had each libraries evry time i got an error and there it is…
GOT IT working, just changed the sequence….:S
is this the realy problem? :S
has i told you, know nothing about programing…:(
ok, i´m going now to the hardware episode and will let you know about it ;)
once again, many thanks
best regards

14. […] inductors and have an idea what their value is without doing a lot of math (f=1/(2*pi*(sqrt LC))). Kerry Wong has a nice page describing a reasonably accurate LC meter built around an ATMega328P and a LM339 […]

15. […] LC meter then the one I had on a breadboard. As I said in the last post, the design is from Kerry D Wong. As an exercise, I made an attempt at getting the parts strictly from the local radio shack. […]

16. FunSpark says:

First off Happy Holidays and Thank You for posting such an awesome project!!
I am pretty much a weekend warrior self taught amature when it comes to electronics, so this question may give you all something to smile about but anyway, there is no designation for the transistors you used other than npn which I understand and I know they are fairly interchangable in some regards however could ya help an old dog out and give up a part number or something please?? Its my holiday project and I have everything lined up except the comparators for the ocillator and the transistors… so I have to go shopping today and need to know so I dont smoke the whole thing!! :~)

Thanks a bunch and thanks again for posting a great project!!

Happy Holidays to All !! sorry for such a lame question…

17. DaveSeether says:

Hi Kerry , Is there any code available for the STM32F4 instead ?

18. Anurag Bakshi says:

Hi,

I am planning on building this extremely useful project. I was designing a PCB to fit over the Arduino but I cannot seem to get it to work. Has any one already made a PCB for this?

Thanks,
Anurag

19. rep says:

I built this circuit loaded the program but go very slowly, which may be the problem?

20. swdev says:

Is the schematic for this circuit correct? For example, the LM339 doesn’t appear to be connected to any power source (pins 3 and 12 on the LM339). Is this intentional?

• kwong says:

Typically the power connection is implied to simplify the schematics. But yes, power is needed for LM339 to work.

• swdev says:

Thanks. In the schematic VCC is both 5 volts and 3.3. Which are you actually running at? If you’re at 3.3 then are there any adjustments that need to be made to make it work at 5 volts? I’m running at 5 volts.

I can’t get the Schmitt trigger section to work. If I take readings from pin 2 on the LM339 then I get a normal output (about 394 khz) but the output of the Schmitt section is not swinging enough to get a reading on the atmega input (ie. I get a frequency of 0 or very low like 20). I built two separate circuits (one surface mount and one through hole) and neither Schmitt section works. Any ideas?

21. Gus says:

Hi,
I’m having a problem building this project. The first part of the circuit, the oscilator, is not giving me ~350Khz. I’m just getting 1 or 2 Hz. I’ve tried LM311, LM339 and LM393, all with the same results. I’m checking the frequency with a frequencimeter. I’m not concern yet to the Schmit Trigger part and Arduino part. I would like to verify first why the oscilator part is not running at ~350Khz.

I’m doing the test using the Capacitor circuitry, but without actually measuring one, so the only parts I’m using are: 3 x 100K, 47K, 1K, LM IC, 2 x 10uF, 1 x 1000pF. With only those part I get 1 or 2 Hz with LM339 and LM393 and 5 or 6 Hz with LM311. All is powered by 5V from USB (I mean, no external power)

What could be the issue? If anyone can measure the output freq. on pin 2 on LM339, without any measure cap, and selecting cap switch, could you post the resulting freq?

Thanks!

• Gus says:

I got ~ 530 KHz using the Inductor part. So I guess that the Capacitor part needs another cap to calibrate…. not sure…

• Gus says:

530Khz was using an unknown inductor. Using 220uH I get 348 Khz :) I’m getting closer….

22. Gus says:

There’s a bug on the first image (the oscillator image): The “L” and “C” are inverted. When measuring caps, contact must be as the way you see on the image, and when “L”, the switch should be switched; so swaping “L” by “C” is what have to be done.
Regards!

23. Tuxology says:

Hi Kerry Wong, I made your project, but I find myself in trouble with the code; importing the code in the Arduino IDE, the code compiles correctly, but the LCD display don’t work.
May be due to different pin mapping between Arduino IDE and NetBeans (with your plugin installed?)?
Could you kindly send me the program already compiled on your machine with Netbeans? (tuxologyATyahooDOTit)

What changes must be made ​​to the code to make it work with Arduino “Ide”?

Thanks a lot for the great project.
Francesco

• kwong says:

I can definitely send you the compiled code (the only thing is that if the component values you used are different than mine then you would see significant measurement error). But it sounds like your circuit was not displaying anything? Using the NetBeans environment shouldn’t have any impact on the generated binaries as long as there were no compiling error.

Could you tell me what specific symptoms you were getting? (e.g. no display at all, or not getting correct values?)

24. Tuxology says:

Hi Kerry Wong, with the code compiled with arduino “IDE” I see no display at all; the button for switch the relays in l\c mode works correctly, but without the display I cannot go ahead with the testing of the circuit.
With Netbeans IDE… I am unable to set up netbeans :-(
Thank a lot for the patience :-)

25. Alchemysrt says:

hi Keey wong, i cant see anything on LCD, i have the same problem that Tuxology user above

• kwong says:

Hi, could you double check your LCD pin connection and verify your code? Since the display code uses the standard Arduino Library, you should be able to verify that the LCD is working properly. Please let me know if you are able to isolate your problem.

• Alchemysrt says:

ah ok ok all right, pins 3, 5 , 7 , 8 , 9 , 10 of LCD must be GROUNDED :) , but i have a BIG PROBLEM, i can change LC / Frecuency mode… but i cant switch C from L mode and doesn´t work any measurement… i believe that is problem of DPDT switch on LCMETER CORE diagram… i have two questions… the relay on the MCU diagram is linked to LC / Frecuency SPDT SWITCH on LC METER CORE DIAGRAM? and two… the DPDT SWITCH selector of L or C in the core diagram is a basic DPDT SWITCH or a RELAY DPDT SWITCH?, i´ve just used a simple DPDT SWITCH for switching L or C… is that correct? thank you

• Alchemysrt says:

sorry i was mistake… PIN 3 of LCD IS CONTRAST VOLTAGE and shouldn´t be grounded… only 5,7,8,9 pins must be grounded… i wait for my big problem with L / C Switch and measurement problem

thank you

• Alchemysrt says:

sorry i was mistake… PIN 3 of LCD IS CONTRAST VOLTAGE and shouldn´t be grounded… only 5,7,8,9 pins must be grounded… i wait for my big problem with L / C Switch and measurement problem

thank you

26. Alchemyst says:

i have a BIG PROBLEM, i can change LC / Frecuency mode… but i cant switch C from L mode and doesn´t work any measurement… i believe that is problem of DPDT switch on LCMETER CORE diagram… i have two questions… the relay on the MCU diagram is linked to LC / Frecuency SPDT SWITCH on LC METER CORE DIAGRAM? and two… the DPDT SWITCH selector of L or C in the core diagram is a basic DPDT SWITCH or a RELAY DPDT SWITCH?, i´ve just used a simple DPDT SWITCH for switching L or C… is that correct? thank you

• kwong says:

Yes, the relay is the STDP switching between LC/Freq. The DPDT switch is just a basic switch. Since you can switch between LC and Frequency modes, you can first try using the frequency mode to measure a known frequency (e.g. from a simple oscillator) and if that works then your problem is most likely the op-amp circuit. If you have an oscilloscope, you may want to see if you can obtain a clean square wave from the output in L mode, which both input leads shorted.

27. Alchemyst says:

Hi Kerry, all works allright except “L mode” i cant Switch C mode to L mode… only i can Display C and Frecuency but when i use the DPDT Switch i cant get “L mode”, Please i need help :( , all circuit is revised and is allright but the problem persist and i cant solve this :(((((((

• kwong says:

It’s been a while….

Anyway, if you look at the code, the LC mode is controlled by pin 2. So if it is not switching, you may have wired the LC mode switch to a different pin? Also, the pin needs to be set as input.

28. […] to do this. For more design information, code and circuitry visit Kerry’s detailed page here. When building your own rendition of this meter, consider using ourLCD Keypad shield, which offers […]

29. Gus says:

Hi. I’ve finally did this project using the LM393 IC. I’ve to add a 1k resistor from 5v to the second output of the LM393 (pin 7) to make the signal more reliable.
Links that help me figure this out:

Here’s a photo:

Regards

• kwong says:

Awesome! Thanks for sharing.

• Aty says:

Hi Gus.
Any chance you still have your code and schematics ?
I am very interested in seeing it, if you do.

• Gus says:

Hi Aty,

I’ve prepared a dropbox folder for you and anyone else who is interested:
https://www.dropbox.com/sh/69pfgsw023e3kd2/F3qQSsgjpH
If you have any question don’t doubt to ask.
Regards.

• Darau, blė says:

Hi, Gus. During the weekend I have fully copied your project (with two initial solder bridges :-D) and glad to have L meter. C meter, unfortunately, does not show any meaningful results. I have used simple ceramic capacitor of 1000 pF. Wonder, if there are some special parts, that could be more accurate?

• Marcelo says:

Hi Gus, can you send code and schematics? your link of DropBOX dont work.
Thank you.

30. francisco says:

Hi
Can this be built using the Arduino Uno?
Thx
Francisco

31. Francisco says:

Hi Kerry
If I built this circuit and copy the code exactly as you have written it (other than perhaps some of the pin designations) will this work with Arduino Uno?
Thx again
Francisco

32. Francisco says:

Sorry Kerry
Thx

Francisco

33. texane says:

Hi,

I largely used your project to make a lcmeter (with some modifications:
https://github.com/texane/lcmeter
A few pictures here:
https://github.com/texane/lcmeter/tree/master/doc/pic/scaled

Cheers,

Texane.

34. Greg says:

Hi Kerry,

Thanks for the great project. Would it be possible for you to email me a HEX file? I only have an Atmel AVRISP mkll programmer.

Best Regards,
Greg

• kwong says:

I have sent you a PM. FYI, unless your build is exactly the same as mine (e.g. all the LC component values are the same), the HEX file may not be useful as the results won’t be accurate.

• Greg says:

Hi Kerry,

Thanks for the HEX file. I have used the same LC components as you have so it should work with no problems. Thanks again!

Best Regards,
Greg

35. Nathan says:

I might build an LC Meter. I was wondering though, would it be possible to use the built in comparator un the 328 ?

• kwong says:

The short answer is no. You cannot use the built-in comparator to form an oscillator in ATmega328. Although this is possible though for some PICs.

36. dheeraj says:

hello
i am engineering student
can i use atmega8 instead of atmega328

how to make hex file to burn target mcu by using usbbasp programmer

37. jorgre says:

Can someone explain what the left side of the 339 does, and the purpose of the various resistors and capacitors connected to it. I don’t understand the purpose of the 100k feedback resistor and the 10uF capacitors. As far as I can see, the left side of the 339 acts as some form of non-inverting derivator, but I can’t understand why it’s really there.

38. Ka-Tua says:

Hi Kwong
how display the serial data in PC monitor (not using LCD component).

39. Nenet says:

Does anyone have done PCB. I would be grateful if you could send it to me. Thank you

40. […] Kerry Wong LCF Meter […]

41. Elac says:

Hello, I’m trying to make this and was wondering.
Is there a full schematic and parts list for this project?
Thanks

• kwong says:

Anything specific? The schematic in the post is everything that is needed to get it to work. Please let me know.

42. Gab says:

Hello!
What type of switch is at the input side of the comparator.
I want its technical name. A name I could mention in the
market to get one.
Regards!

• kwong says:

The first switch on the left is a DPDT (double pole double throw) and the one on the right is called a SPDT (single pole double throw).

43. Juliana says:

Dear, please could you send me the source code and schematic? i’m building this but it’s not working. Thanks
juliana_soares12@hotmail.com

44. prosim says:

An interesting project. I wanted to ask whether the calibration is saved to the EEPROM?
Regards

45. Martin says:

Dear Mr. Wong!
How do you switch between L and C mode? I cannot find it in the code. Does Btn3 all the work or is it done autmatically? If not how to modify the code to switch between 3 modes with one button?
Thank you for this nice project. I did some mods and will send pics, when finished,
Martin

• kwong says:

Hi Martin,

L/C mode is determined by the switch (DPDT) connected at Arduino’s digital pin 2. When in L mode, the 1000 pf capacitor is used to form an LC circuit with the external capacitor and when in C mode, the 221uH inductor is used to form an LC circuit with the external capacitor under test. Pin2 is used to sense which mode it is currently in and display accordingly.

• Martin says:

Dear Mr. Wong, Thank You for answering!
My question was how the DPDT is driven (manually?). There is only one pinRelay defined associated with Btn3 to switch the SPDT to get to frequency mode. There is only one Relay in the MCU schematic. So how is it done? There is something missing for my understanding. Thank you for help.
Martin

• kwong says:

Yes, the DPDT switch is a manual switch (so you switch it betwen L or C mode).

• Pwillard says:

Martin, I successfully replaced the dpdt with a latching relay making a spst pushbutton only design. You do need extra contact closure to help the MCU know which mode you are in.

46. eni says:

hi to all
can I change the code of this project for an ATMEGA8A ?

47. EV says:

Hi, thanks for the circuit, i tried to build one, but the value of resistor in below picture make me canfused. plz help me:

48. Jdub says:

This is an awesome project! and I am attempting to build this… My question is do you think it will work with the Arduino Micro?
Also I was thinking about putting this into one of the proto sheilds instead of custom pcb … I’m having trouble finding the 220uh inductor (locally) that you use
and will be following this project
http://langster1980.blogspot.com/2013/07/arduino-lc-meter-shield.html
as he based his design off of yours and gives you credit!
anyways Awesome work!

• kwong says:

Yes, the source code is based on Arduino.

• Jdub says:

Alright I built this however I cant seem to get any result in either mode (haven’t tried freq yet).. In my build I had to substitute the 221uh inductor and the 1000pf capacitor ..
using this site: http://www.1728.org/resfreq.htm
I calculated yours to be running at 338khz
I had a 47uh inductor and using that calculator it told me to use a 4.7nf capacitor to match the same frequency which “is” correct running 338khz.
I edited these lines of your code:
float F0 = 348000; // made no changes here
const float Cth = 4700 * 1e-12;// 4.7nf ==//1000 * 1e-12; //theoretical 1000pF
const float Lth = 47 * 1e-6;// 47uh ==//221 * 1e-6; //theoretical 221uH
So in your opinion Where should i be looking to get a reading.. I figured even if some numbers are off I should still get a bogus reading right?
Everything else works, switches, buttons, relay so im a little confused..

i’m using a polyfilm cap 472j if that helps.. should be 5% accurate