Precise Pocket Inductor Meter Based on Arduino

by SHARANYADAS in Circuits > Arduino

7257 Views, 48 Favorites, 0 Comments

Precise Pocket Inductor Meter Based on Arduino

CktMain.jpeg

This is an Arduino UNO based Inductor Meter that I developed for my next big project(i.e High Current MPPT Solar Charge Controller for my home use).The said circuit would need custom made Inductors to handle high current.I don't have any Inductor meter to test the custom inductors during my R&D.Though,i can buy some off-the-shelf cheap component testers available in the market to accomplish the task! But i don't believe in cheap craps & parallelly, good LCR meters from reputed companies like BK Precision/Fluke has become insanely costly these days(around 50k in INR) !!!

Lastly,i thought,why buy when you are capable to build one??Thus,after some study in the weekend,tinkering & programming,finally i build mine.When completed,i thought to make it OPEN SOURCE so that,anyone in need,can build one for him/herself......

These kind of Arduino based Inductor meter projects can be found in the Internet but what makes this one special is because of two reasons

1) This circuit can measure very precisely down to 1uH(Micro-Henry) range & also can be adjusted to measure in the nH(Nano-Henry) range by some simple modification in my custom source code.I will come to that part later.This makes it a great tool for those who are in the smps/power supply repair jobs.

2) The whole unit runs on a single 3.7v rechargeable Li-Ion battery with auto shut off feature that makes the battery lasts for years.It doesn't need any kind of external power supply & messy wires.

Now,without wasting any more time,lets jump into the construction part....

The Basic Working Principle

LC.jpg

The basic idea behind this is very simple,a TANK circuit! Now,what is a tank circuit? It is simply a LC oscillator circuit which consists of two main things which you can easily guess by the name,one Inductor(represented by L) & one Capacitor(represented by C). You simply connect a Inductor & Capacitor in parallel & apply a short pulse across them.Whenever the pulse is applied,the circuit starts to "resonate".The resonating frequency can easily be found by this simple formula i.e F =1/(2π√(LC)).You can check in the nasty hand drawn image of mine where a pulse is applied in the LC circuit & the corresponding resonant output frequency in the waveform.Now,we can simply use a known Capacitor value in conjunction with an unknown Inductor value.Upon applying a pulse,we will measure the output frequency.When we get the frequency,we can simply calculate the "Unknown" Inductor value! In theory,this is perfect but sadly,in practical electronics,things are not that straight forward & we will discuss the challenges in the next step....

The Challenge & the Solution

LT.png

Now,the basic working principle works great in theory but sadly,microcontrollers alone are very bad to handle analog signals!!

To overcome this,we will add a comparator in our circuit! Now,what a comparator doing here?? You can google for more working info of a comparator! But we are working on practical electronics here & will be brief & also,as much as to the point as we can.

The comparator will generate output signal in square wave corresponding to the input signal.Lets jump to the LTspice simulation where i am feeding a sinusoidal signal of 60Hz to the + input of the comparator & the - input of the comparator is tied to ground.Watch closely,how the comparator is generating a squarewave signal corresponding the +ve cycle of the sinusoidal signal & chopping off the -ve cycle.Now,our Arduino will easily measure the +ve half cycle period by simply measuring the duration of the square wave & easily calculate the frequency!

Now,things are making much more sense,eh ??

Into the Real World

OSC_TANK.jpeg

Now,these are some oscilloscope waveforms captured after the circuit is completed.I am sharing it with you to make you understand the working principle in the real world.

As discussed before,whenever,we will feed a positive pulse to the input of the tank circuit,the circuit will start to resonate.It will simply generate a sinusoidal output of a very little amplitude(The Yellow signal here from Oscilloscope CH-1).The CH-1 amplitude divisions are set to 2mV to capture the signal properly.As we are applying a short positive pulse of 5ms,the output resonating signal from the Tank will eventually lose it's amplitude & die.

Look closely,how the comparator output is generating a corresponding digital pulse represented by the Blue signal captured via Oscilloscope CH-2.

Circuit & Explanation + Parts List

Circuit.png

Lets understand the circuit first!

I've used both SMD parts & DIP parts to build the circuit.You can build your own PCB but i assembled the circuit in prototype board as i didn't have much time to design PCB(As this was supposed to be a weekend project)

The heart of the circuit is U1 i.e Atmega328p in DIP package.As we have to run the circuit using battery,we can't just feed power directly to the power hungry parts like the OLED display & LM393 Op Amp etc & also,can't run the circuit indefinitely!

So far,what i've done here is that the Arduino gets the power directly from the battery & goes into sleep mode.Also,it supplies power to the power hungry parts only whenever necessary to save the battery.This is achieved by the Two MOSFETS Q2 & Q1 & the biasing resistors R2,R7 & R8(These are the only SMD parts in the circuit)! The Arduino stays in the sleep mode & whenever the user press the SW2 (which is tied to Interrupt pin),it wakes from Sleep & Turns Q2 via Q1.The Comparator(U$1G1) & OLED Display then gets the power & initiated.Next,the Arduino generates a pulse via PD7(Digital Pin 7).The connected Inductor on the INDUCTOR_IN pins in accordance with the known capacitor C6 forms the resonance as we discussed before & the comparator gives a corresponding digital output which is connected to Arduino's pin PB0(Digital Pin 8).(I will explain in the code section,why i took the digital pulse on this particular pin!)

After getting the digital pulse,the Arduino measures the frequency & calculates the unknown Inductor value based on the frequency & Capacitor value as per our previous formula & displays it via the OLED display.Also,in addition,the Arduino measures the Battery voltage via the Resistor divider R3 & R4 & shows it on the OLED.After all this is done,the arduino remains on for 60s & again go to sleep & cuts off the power to the OLED & Comparator & resistor divider part by turning off Q2.In between this 60s timeout,if we measure measure again,the time gets reset & the circuit again wait for 60s to sleep & so on....

I've Used a 128x32 OLED Display for my Seup in I2C mode.Notice,there are 4 OLED PINS for the display i.e OLED_VCC,OLED_GND,OLED_SDA_PIN,OLED_SCL_PIN.

Also,if you wish to program the Arduino later,you can easily do it using a FTDI breakout board.As our Atmega328p is having the Arduino bootloader installed,it handles the job to self program without the need of any external programmer.Just connect the DTR,GND,RX & TX pins of the FTDI breakout board to the circuit's FTDI_DTR,FTDI_GND,FTDI_RX & FTDI_TX pins.You can connect them to a 4 pin header if you wish for a neat look.Note that the FTDI_DTR pin is connected to a 0.1uF capacitor which is used to auto-reset the Arduino from the Arduino IDE to put the bootloader into action.

Also,For my setup,i didn't connect the battery directly as shown here.Instead,i used a cheap TP4056 module to save the battery from overdischarge when not in use for a long time.I will discuss more about it later....


Parts List:

U1: Atmega328p with Arduino Bootloader(Or you can burn the program on an UNO & remove the Atmega328p from there)

U$1G1 : LM393

C1,C2 : 22PF

C3,C4,C5 : 100nF/0.1uF

C6 : 1uF (You can use 105J /450v or 105J/250v polyester caps as well)

X1 : 16MHz Crystal

R1,R4 : 10k (1% MFR)

R3 : 33k (1% MFR)

R5 : 150R

R6 : 1k

R2(SMD 1206 Package) : 10k

R7,R8 (SMD 1206 Package) : 150R

D1 : 1N4007

SW1 , SW2 : 4 Pin / 2 Pin Tactile Switch (Whichever available)

128x32 I2C OLED Display (You can check this for ref)

TP4056 Breakout board with Load Disconnect (You may check this for Ref)

Note that this board has 4 pins.2 is used to connect the battery & other 2 is used to connect the load.The board will disconnect the battery from Load after the battery voltage reaches to around 2.4v

Also, R3 & R4 should be 1% MFR otherwise the battery readings in the display will be wrong.........

Code & Explanation

CodeScreenShot.png

I used Arduino IDE for writing the code.The code is pretty self explanatory as i've commented out whenever necessary! I will try to be as brief as possible here.

The main thing to focus here is about how the code measures the frequency!

What i've found in other codes that the arduino uses pulseIn() function to measue the frequency(basically measures the width of the high pulse in microsecond).But,when i was testing,i noticed that the code is not working for the Inductors which generates a high duty cycle of less than 10uS as this is the limitation of pulseIn() function.

Other thing is,if the measurement time is not precise,we may capture the wrong frequency.For say,whenever the Positive pulse is first applied to the tank circuit,the inductor start a little bit of oscillation/ringing.If we capture that frequency,that is not desireable.So,i adjusted all the time critical functions in the code using Oscilloscope readings.

I decided to write all the code by myself & used Timer1 Input capture method using interrupt to measure the high pulse for low value inductors.The limitation to use Timer1 Interrupt Capture method is that it can only be used on a dedicated ICP pin i.e D8 in Arduino(As i told previously why i used this particular pin)

The Mosfets are switched on/off via the PWR pin i.e Digital Pin 2.ADC CH0 is used here to measure the battery voltage via the voltage divider in every 2s interval during the active period.Digital Pin 7(TANK) is used to provide the Pulse to the LC Tank circuit in order to start resonating.....

External Interrupt INT1 is used precisely to wake the Arduino from sleep & make it to go to sleep & handle all the inputs/outputs correspondingly.The Arduino uses the sleep functions to go into powersaving mode.

Lastly,do not modify the code unnecessarily as it may ruin your whole readings & the circuit may not work as expected....

You need to download u8g2 library in the Arduino IDE to use the display functions! (Given that you have the knowledge about how to add a library! Otherwise,there are tons of example/videos available in the internet)

Building the Circuit & Calibration

Ckt1.jpeg
Ckt3.jpeg

You can see in the picture that i've built the circuit in a prototype board.You may need to follow some guidelines before you start building the circuit.

1) Place C3 & C4 as close as much possible to the AVCC & AREF pin of the Atmega328p.

2) Don't run long traces / unnecessary wires around or near the pcb as it may act like antenna in analog circuits & produce abnormal readings.

3) Don't run mobile phone near the circuit as it hamper the readings

Now,as you have come this far,you have genuine interest to build this circuit.Assemble it on a prototype board/PCB whichever suits you better & once you are done,follow the steps to calibrate:

1) Burn the code to the Atmega328p/If previously burnt the code,simply place the atmega328p into the circuit

2) Power up the circuit using the battery or any known power source

3) If everything goes well,you can see the battery Voltage & "Open" written in two lines of the OLED

4) Now, when the display is ON,quickly measue the voltage by using a DMM(Digital Multimeter) on the AREF pin to GND(one pin of the DMM to GND & Other to AREF pin i.e physical pin 21 of the Atmega328p.Note the reading.(It should be in the range of 1.08v to 1.1v range)

5) Next,measure R3 & R4.Note them down

6) Open the code & come to this section

#define R1 33370
#define R2 9970
#define divFactor (R1 + R2) / R2
#define RefVolt 1.098

replace it with your reading.

For ex: if you read R3 as 33.1k,then R1 will be 33100(in ohms range)

if you read R4 as 9.9k,the R2 will be 9900

leave the div factor as it is

If you read RefVolt as 1.085,then RefVolt will be 1.085

That means for your setup,this part of the code would be like below

#define R1 33100
#define R2 9900
#define divFactor (R1 + R2) / R2
#define RefVolt 1.085


Now,recompile the code again & burn it to the Atmega328p again!

This time,measure the battery with DMM & cross-check it with your reading on the OLED Display,it should be spot-on.....VOILA


Adding TP4056 Brekout Board As LVD

TP4056.jpeg
Ckt2.jpeg

In my setup,rather than connecting the battery directly to the circuit,i've used a ready-made TP4056 charging/Low voltage disconnect(LVD) module in between.Please check the block diagram

TP4056 breakout board has 4 pins.Two B+/- pins for Battery & Two OUT+/- Pins for the load.I've connected the Battery to the B+/- Pads of the TP4056 board & The wires from my circuit to the TP4056 OUT +/- Pads.This is basically to prevent the battery from over discharge as the DW01 IC on the TP4056 Breakout board disconnects the load when the battery voltage reaches below 2.4v.

It is not mandatory to add the TP4056 breakout board.For regular users,you can connect the battery directly to the circuit as the meter shows the battery voltage.You can recharge whenever necessary.I added the board to prevent deep discharge!

Measuring the Current Consumption of My Setup

Ckt4.jpeg
Ckt5.jpeg

Now,as we have come nearly to the end,i am sharing some snaps of the circuit current consumption when it is in active mode & when it is in sleep mode.It was measured using Current Ranger which is a very precise digital ammeter from Low Power Labs.

In active mode,the circuit nearly consumes 17mA & in sleep mode,it goes to as low as 19uA which is pretty impressive!!!!

The battery can easily last over 1.5 to 2 years.

Final Assembly

Ckt6.jpeg
Ckt7.jpeg
Ckt8.jpeg
Ckt10.jpeg
Ckt9.jpeg
Ckt11.jpeg

Now,the only thing remains is to get a good enclosure & put everything inside it.

I've used some scrap enclosures from my junkyard.I used double sided tape to stick the battery to the enclosure.I placed the pcb on top of the battery seperated by some sponge kinda insulator.Lastly,i drilled some holes for the push switch & the Wires to come out to connect the test Inductors! Also,cut the top part of the enclosure & fixed the display.Now,after all these,it looked like a small,cute professional looking inductor meter.....

Some Measurements Done

Ckt14.jpeg
Ckt13.jpeg
Ckt12.jpeg
Ckt16.jpeg
Ckt15.jpeg

Here,i captured some readings starting from 1uH to 2.2mH.The results are quire satisfactory......

Final Part

This is not a beginner level project by any means! Only people with moderate/advanced level knowledge of electronics & embedded programming,should start the project otherwise there is a high chance,the project wouldn't work.....

By any means,i am not disheartening/demotivating you....

& lastly,if any problem/query occurs,you can contact me whenever necessary.....


Happy Building


Sharanya