L-METER Arduino Inductance Meter schematic and code
Вставка
- Опубліковано 16 вер 2024
- This code calculates inductors value in µH by counting the frequency of an LC oscillator circuit (See schematic). The LC tank of the oscillator is arranged so that a dpdt switch is inserted between the collector and one terminal of the tank inductor L1, and in parallel to the inductor Lx to be measured.
When the switch is off, Lx is shorted and L1 determines the oscillating frequency (with the oscillator's capacitors).
When the switch is on Lx is now in series with L1, so L1+Lx lower the oscillator frequency. Inductance is calculated as:
L = 1 / ( ( 2PI * F ) ^ 2 * C )
where F is oscillator frequency and C is total capacitance Ct, given by
Ct = C1 + ( C2 * C3 ) / ( C2 + C3 )
The code needs to calculate L1 first (switch off) then use this value to be subtracted from the next result with L1 and Lx in series (switch on).
I think the Arduino Nano can count the maximum oscillator frequency (~193 KHz with L1 = 10 µH for the circuit on breadboard) directly, but a prescaler was used to divide the frequency by two and output a clean 50% duty cycle square wave to the Arduino pin 5.
The frequency counting is done by the FreqCount library, during one second each time. The frequency counted can be slightly off due to variances in the crystal and power supply regulator, so the result was compared with oscilloscope measurements and a correction factor was included.
I believe precision is good enough, (+-10% maybe?), but I do not have a precision inductance meter in order to compare. It is better than my multimeter for sure.
Results are displayed in µH only. I let the code exercise of displaying results also in nH and mH for you, because I am lazy at the moment.
The circuit is from an Elektor article (Philippe Le Guen) that was based on a circuit available at F. Kudelsko website, both using PIC µcontrollers.
An alternative oscillator could be the one featured on 73 Amateur Radio September 1990, by N4TM1 Michael Covington, but it needs a higher power supply voltage (about 18Vdc).
Thanks for watching.
/* This code calculates inductors value in µH by counting the frequency of
an LC oscillator circuit (See schematic). The LC tank of the oscillator
is arranged so that a dpdt switch is inserted between the collector and
one terminal of the tank inductor L1, and in parallel to the inductor Lx
to be measured.
When the switch is off, Lx is shorted and L1 determines the oscillating
frequency (with the oscillator's capacitors).
When the switch is on Lx is now in series with L1, so L1+Lx lower the
oscillator frequency. Inductance is calculated as:
L = 1 / ( ( 2PI * F ) ^ 2 * C )
where F is oscillator frequency and C is total capacitance Ct, given by
Ct = C1 + ( C2 * C3 ) / ( C2 + C3 )
The code needs to calculate L1 first (switch off) then use this value to
be subtracted from the next result with L1 and Lx in series (switch on).
I think the Arduino Nano can count the maximum oscillator frequency
(~193 KHz with L1 = 10 µH for the circuit on breadboard) directly, but
a prescaler was used to divide the frequency by two and output a clean
50% duty cycle square wave to the Arduino pin 5.
The frequency counting is done by the FreqCount library, during one
second each time. The frequency counted can be slightly off due to
variances in the crystal and power supply regulator, so the result was
compared with oscilloscope measurements and a correction factor was included.
I believe precision is good enough, (+-10% maybe?), but I do not have a
precision inductance meter in order to compare. It is better than my
multimeter for sure.
Results are displayed in µH only. I let the code exercise of displaying
results also in nH and mH for you, because I am lazy at the moment.
The circuit is from an Elektor article (Philippe Le Guen) that was based on
a circuit available at F. Kudelsko website, both using PIC µcontrollers.
An alternative oscillator could be the one featured on 73 Amateur Radio
September 1990, by N4TM1 Michael Covington, but it needs a higher power
supply voltage (about 18Vdc).
*/
#include // www.pjrc.com/teensy/td_libs_FreqCount.html
#include // native Arduino library
#include // github.com/marcoschwartz/LiquidCrystal_I2C
// set LCD address to 0x27, 16 chars and 2 line display:
LiquidCrystal_I2C lcd(0x27, 16, 2);
boolean swState; // switch state flag (pressed=false, using pull-up pin)
int sw = 2; // switch connected to Arduino pin 2
int dv = 2; // frequency division after LC tank oscillator
double L1 = 0.0; // holds oscillator's inductor value
double Lx = 0.0; // holds value of inductor under test
double const C1 = 3.42; // enter measured C1 value in nano Farads
double const C2 = 97.00; // enter measured C2 value in nano Farads
double const C3 = 231.00; // enter measured C3 value in nano Farads
// Calculate circuit's total capacitance:
double const Ct = (C1+(C2*C3)/(C2+C3))/1000000000;
double const cf = 0.0045; // correction factor for Arduino crystal frequency
void setup() {
pinMode(sw, INPUT_PULLUP); // switch pin (2) as input with internal pull-up
lcd.init(); // initialize the lcd
lcd.backlight(); // turn LCD backlight on
lcd.setCursor(0,0); // set cursor to first column and first row
lcd.print(" L-Meter"); // print some text
lcd.setCursor(0,1); // set cursor to 1st column, 2nd row
lcd.print("Sbranvlztronics"); // print some text
delay(1200); // wait 1.2 seconds
lcd.setCursor(0,1); // set cursor to 1st column, 2nd row
lcd.print("F: Hz"); // print some text
lcd.setCursor(0,0); // set cursor to 1st column and 1st row
lcd.print("L: uH"); // print some text
FreqCount.begin(1000); // initialize frequency counter, measuring 1 second interval
} // end of setup()
void loop() {
if (FreqCount.available()) // if a frequency reading is available,
{
swState = digitalRead(sw); // switch state is equal to pin 2 (sw) state
unsigned long count = FreqCount.read(); // put pulses counted in variable 'count'
// apply division and correction factor so freq is as close as possible to osc. frequency:
double freq = count*(dv+cf);
lcd.setCursor(0, 1); // set cursor to 1st column, 2nd row
lcd.print("F: Hz"); // print F for frequecy, in Hz
lcd.setCursor(3, 1); // set cursor to 4th column, 2nd row
lcd.print(freq); // print frequency value in Hz
if (swState) // if switch is off (true),
{ // use oscillator frequency readings to measure L1 inductance:
L1 = 1000000 / ( pow(2 * PI * freq, 2) * Ct); // calculate L1 inductance
lcd.clear(); // clear the display
lcd.setCursor(0, 1); // cursor to 1st column, 2nd row
lcd.print("F: Hz"); // print F and Hz
lcd.setCursor(3, 1); // cursor to 4th column, 2nd row
lcd.print(freq); // print frequency value in Hz
lcd.setCursor(0, 0); // cursor to 1st column, 1st row
lcd.print("L: uH"); // print L and uH (micro Henries)
lcd.setCursor(3, 0); // cursor to 4th column, 1st row
lcd.print(L1, 2); // print inductance of L1 in µH
lcd.setCursor(8, 0); // cursor to 9th column, 1st row
lcd.print("-CAL-"); // warn its calibrating
}
if (!swState) // if switch is pressed (false, pin 2 grounded),
{ // the inductor Lx to be measured is now in series with L1, so
// calculate total inductance and subtract L1 value:
Lx = (1000000 / ( pow(2 * PI * freq, 2) * Ct ) ) - L1;
lcd.clear(); // clear the display
lcd.setCursor(0, 1); // cursor to 1st column, 2nd row
lcd.print("F: Hz"); // print F and Hz
lcd.setCursor(3, 1); // cursor to 4th column, 2nd row
lcd.print(freq); // print frequency value in Hz
lcd.setCursor(0, 0); // cursor to 1st column, 1st row
lcd.print("L: uH"); // print L and uH (micro Henries)
lcd.setCursor(3, 0); // cursor to 4th column, 1st row
lcd.print(Lx, 2); // print inductance of Lx in µH
}
}
} // end of loop()
what is the lowest inductance it can measure?
Lowest I measured was 500nH, I think it can measure as low as 100nH, maybe less if built properly (mine is still on breadboard).