STM32 (Duino) Inductance Meter and Saturation Tester

by Poldo in Circuits > Arduino

3850 Views, 8 Favorites, 0 Comments

STM32 (Duino) Inductance Meter and Saturation Tester

FullSizeRender.jpg

If you are an electronics hobbyist like myself you probably have cannibalized many types of old non-working PC boards and assemblies for their electronic parts. Among these parts are inductors of all shapes and sizes. Unlike common components such as transistors, capacitors and resistors, inductors are often custom and have no meaningful markings in order to look up a specification. Visually you can't determine the core material type or even the number of turns in some cases. It is possible to obtain certain parameters through simple measurements such as wire diameter, resistance and core dimensions. Although these can help determine things like the the power handling capability in order to effectivly use these parts you need more information. Two main parameters are the inductance value itself but more importantly is the inductor current rating. Specifically, how inductor current affects the inductance value as the ferro-magnetic material begins to saturate. My project will identify these two key parameters in order to allow the inductor to be used in design projects such as a buck or boost converter or in a AC/ DC filter application. The features of this project are as follows;

1) Two modes of operation:

  • A "Short" button press for an Inductance measurement only
  • A "Long" button press for a full Saturation test

2) OLED display

  • Displays Inductance value (uH)
  • Plots Inductor current (A) clearly showing the saturation level
  • Adds 3rd order polynomial curve fitting when the number of samples is small
  • Plots a linear straight line with the slope based on user defined saturation point (helps see the saturation knee clearly)
  • Displays up to three user defined saturation levels (%) with associated current
  • Displays max saturation level

3) User Console via the Arduino IDE Serial monitor allows for changing various operational parameters such as;

  • Inductor resistance
  • Turn on / off curve fitting and linear line plots
  • Set saturation detection levels and more

4) Provides continuous status checking for proper input voltage and verify the inductor under test is connected.

5) Automatically increments the pulse width during testing to capture the inductance the saturation data on many types core materials

  • For inductance only - the meter can measure inductances from a few microhenrys to ten's of millihenrys
  • For the saturation test - a few microhenrys to a few millihenrys (dependent on core material type) can be evaluated

Supplies

3D Printer - Any - I used an Ender 3 V2

Filament - PLA

M1 OLED Display - SSD1306, I2C, 0.96"

U1 - Microcontroller - STM32F103C8

U2 - Mosfet Driver - SOT-23-5 1.5Amp Microchip P/N MCP1416

U3 - 12V Regulator - TO-220 1 Amp P/N 7812 or equiv

U4 - 5V Regulator - SOT-223 1 Amp P/N AMS1117-5.0 or equiv

Q1 - Mosfet - TO-220 N -Channel 30V 170A Rds on = 2.4mΩ or equiv. (I used Infineon P/N IRLB8314)

D1 - Rectifier - DO-214AB - Fast reverse recovery type - 50V, 1 Amp (Not critical I used Tiawan Semi PN HS3M)

D2 - Zener Diode - 3.3V, 1/2Watt or equiv

C1-1,C1-2,C1-3,C1-4,C1-5 - Capacitor, Electrolytic type, 4700uF, 16V, 12.5mm(DIA) x 25mm (HT) or equiv

C2 - Capacitor, Tantalum, 10uF 16V Case B (This is not critical it could be ceramic I used Kemet P/N T491B105K)

C3,C4,C5,C7 - Capacitor, ceramic, SM, 0805,0.1uF, 50V

C6 - Capacitor, ceramic, SM, 0805 1uF, 25V

R1,R5 - Resistor, metal film, SM, 0805, 1kΩ

R2 - Resistor, metal film, SM, 0805, 5.6kΩ

R3,R4,R7 - Resistor, metal film, SM, 0805, 10kΩ

R6 - Resistor, metal film, SM, 0805, 5Ω

R8 - Resistor, Current Sense, metal film, SM, 2512, 50mΩ

R9 - Resistor, Thru Hole - 10Ω 1/4W any type

PB1 - Push Button - SPST type 7mm (DIA) thread mounting

Terminal Block - 2 pin, 5MM pitch - ( I used Wurth Electronik P/N 691102710002) or equiv

Banana 4mm Binding Post Nut Banana Plug Jack Connector, 2 pcs, Black/RED

40 pin Female Header 2.54mm - 1 Piece

Break Away Male Header Straight 40 Pin - 1 Piece

Break Away Male Header R/A 40 Pin - 1 Piece

Machine screw, pan head, M2.5 x 5mm (4pcs)

Wood Screw, Countersunk, 3mm Thread, 12mm Length (4pcs)

Heat Srink Tubing

PCB - Copper clad board, single sided, 4"x5"

Ferric Chloride - PCB etchant, 1 small bottle

Understanding the Theory

Fig1_Fig2_Fig3_Fig4.png

So what does inductor saturation really mean anyway? To explain this we need to go over some basics by talking about current, voltage, inductance and time using an ideal inductor. Lets start with Fig1. Here we have the + 5V side of the battery connected in series with an "unknown" inductor in series with a switch in series with an ammeter and the circuit is completed back to the - side of the battery. When the switch is "open" no current flows as shown in the graph as 0 Amps. Now lets close the switch. Looking at the Fig2 graph we can see that the current rises linearly as a function of time. It rises to a voltage of 5 amps in 1 second. Now for the formula.

L = V / (di / dt)

Where;

L = inductance (Henrys)

V = Volts

di = Change in current (Amps)

dt = change in time (seconds)

So now we can solve for Inductance as L = 5 / (5 / 1) = 1 Henry. And since the current is linear with respect to time we can choose any di/dt from the graph. For example L = 5 / (2.5 / 0.5) = 1 Henry. So in this example of an ideal inductor the current will keep increasing linearly over time at 5 Amps per second rate.

To learn more use the links below;

Inductor i-v equation in action - Spinning Numbers

Inductance of a Coil - Electronics Tutorials

Now let's talk about real-world practical inductors. In order to make inductors small and powerful for use in switching power supply applications, a ferromagnetic material is introduced into the construction. These materials can be steel, iron, nickel, powdered iron, ceramics, ferrites, and other novel formulations. All these materials offer specific advantages depending on the application. One thing they all have in common is the ability to increase the strength of the magnetic field for a given number of turns. This means more inductance for fewer turns, and fewer turns means a smaller size. Another thing that all of these core materials have in common is that as the current increases, the core will eventually become "saturated" which simply means that the magnetic field cannot become any stronger and the core material begins to lose its properties, causing the inductance to decrease and the current to increase. In Fig 3, the blue line is inductance and the red line is current. As the current begins to ramp up in a somewhat linear fashion, the inductance holds fairly flat and steady, but as the current continues to increase, the slope of the current (di/dt) begins to increase as well and the inductance begins to drop. Saturation is defined as the percentage of inductance decreasing from it's initial value. So in Fig3 the initial inductance is approximately 30 microhenrys. The inductor core will be 10% saturated when the value falls to 27 microhenrys (1-(27/30)). So, for this inductor core material, the 10%, 20% and 30% saturation points are shown and correspond to 5, 12 and 19 Amps respectively. The shape of the current curve in Fig3, is referred to as a "soft knee" because the change in di/dt is fairly gradual with no sudden sharp increase and is usually a characteristic of a steel, iron or powdered iron core. Fig4 depicts a "hard knee" where once the current passes a threshold point, the slope of di/dt increases drastically. A hard knee is a common characteristic of a ferrite core.

The Schematic

Schematic.png

The schematic is pretty straight forward and can be described as follows;

15 to 18VDC is fed to the input the +12V regulator U3. C6 provides stability for the externally supplied voltage and C3 is the input bypass capacitor. The output of the +12V regulator feeds the input of the +5V regulator as well as R9 and pin2 of U2. C5/C7 are the +5V regulator input/output bypass capacitors. The +5V line provides power to the M1 Oled display and the U1 microcontroller. R9 acts as a current limit resistor for charging each of the five 4700uF capacitors C1-1 to C1-5. R1 and R2 form a voltage divider that senses the C1 voltage potential and passes it to the microcontroller U1 analog to digital converter input PA1. R3, R4 and R5 is another voltage divider that forms the inductor detect circuit and connects to the microcontroller U1 analog to digital converter input PA2. The main purpose of D1 is to provide a low impedance discharge path for the inductors stored energy and is a fast reverse recovery type. TB1 is the external connection for the inductor. The U1 output (B9) connects to the input of the Mosfet driver U2. R7 keeps Q1 turned off if B9 is floating. The output of U2 feeds the gate of Q1 through R6 which helps to reduce output ringing at the drain. Q1 acts as a switch with the drain connected to the anode of D1 and the source connects to current sense resistor R8 to ground. The voltage across R8 is fed to the U1 analog to digital converter input PA0. D2 provides over voltage protection for input PA0. Finally, the the I2C pins (SCL and SDA) of the Oled display are connected to U1 pins PB6 and PB7 respectively. The P1 header allows for externally connecting an oscilloscope for monitoring U1- PB9 and the R8 current sense resistor voltage.

The schematic design tool that I use is called TinyCad. It is open source and available for free.

TinyCAD

So How Does It Work?

Fig5_Fig6_Fig7_Fig8.png

Here is a basic overview of the methodology used to obtain both the inductance and saturation values.

A voltage pulse of a certain time duration is applied to the gate of the Mosfet. While the pulse is "HIGH" the Mosfet switch is turned "on" and current will begin to flow through the inductor under test and the current sense resistor. A voltage proportional to the current through the sense resistance is created (V = I / R). This voltage (Vsns) is fed to an analog to digital (AtoD) converter and the value is stored in a Vsns_array. As soon as one conversion completes the next one is started. This continues for the duration of the pulse width. The time of each measurement is captured and stored in a t_array. When the pulse goes "LOW" the Mosfet switch is turned "off". The values stored in the Vsns_array can be read back and converted to the precise inductor current (IL) in amps (I = V / Rsns) and the time value stored in the t_array is converted to microseconds. By combining each IL current measurement with the associated time (t) measurement we get the change of current with the change of time (di and dt). Since the applied voltage is constant we can calculate the inductance as L = V / (di / dt) for each data sample. We can use the first two data samples to calculate the inital inductance. By subtracting each subsequent value of L from the initial value we can calculate the change in inductance. The current data is then plotted on an x-y graph with x= time and y= amps and the saturation levels can be shown.

Let's look at a real example of an actual inductor tested. An inductor was pulsed for 50.54μs and the inductor voltage = 12.0V. In Fig5 you can see that there were 10 samples taken. Blue is the inductor current (IL) Amps and Red is the time in μs. We first derive the initial inductance using the first two data points. We know that L = V / (di / dt) so substituting we get;

L(initial) = 12V / (di /dt)

di = 2.12A - 0.87A = 1.25A

dt = 7.87μs - 2.54μs = 5.33μs

L(initial)μH = 12 / (1.25 / 5.33) = 12 / .2345 = 51.2μH

We can know calculate the inductance value and saturation level for each succeeding data sample by keeping the first data point as constant for the di/dt calculations. Let's do the 5th sample to demonstrate this.

di = 6.49A - 0.87A = 5.62A

dt = 23.87μs - 2.54μs = 21.33μs

L(μH) = 12 / (5.62 / 21.33) = 12 / .2635 = 45.54μH

Let's now calculate the saturation percentage value;

Sat% = 1 - ( L / L(initial)) * 100 = 1 - (45.54 / 51.2) * 100 = 11%

To help contrast the how quickly the inductor core is saturating it is helpful plot a linear line on the same graph. Using the same two data samples that we used to calculate the initial inductance we can plot a straight linear line using the formula y=mx+b where;

y = (IL) Amps

m = di / dt (the first two data samples)

x = (t) μs

b = 0 (since the line would pass though the origin point 0,0)

solving for m = (2.12-0.87) / (7.87 - 2.54) = (1.25 / 5.33) = 0.2345

Fig6 shows this line plotted in Green. This line represents what the current ramp would look like for an ideal 51.2μH inductor. As you can see it is now easy to visualize how the current diverges from the linear. Another enhancement is to curve fit the data sample points to for a smooth line. This is helpful when the number samples is small. This can be accomplished in most cases by using a 3rd order polynomial. Fig7 shows the smooth curve fitting. The math on this is daunting but the good news is there is an Arduino Library called curveFitting.h that handles this task quite nicely. Finally, Fig8 shows more or less how the data will be presented on the Oled display.

Unit Operation

Final Complete Demo

Read this short operation explanation before viewing the demo video.

After powering on the unit, the user is prompted to do either a "Short" button press to do a quick inductance measurement only or a "Long" button press for a full saturation test. In both cases an under voltage check along with an inductor continuity check is performed. Starting with the inductance test only, the pulse width begins at 10μs upon completion the data samples are evaluated. If required, another pulse will be automatically initiated and incremented by +5μs each time. This process will continue until the initial inductance value has been calculated. The main criteria for this calculation is that the measured inductor current must be greater than the user defined minimum. The default value is 0.32Amps. Based on the A to D accuracy and tolerance this value results in no more than a 5% error. The pulse is then terminated and the results are shown on the Oled display. If for some reason the initial inductance value is not found, the pulses will continue until the saturation % value is greater than the user defined limit or the current is greater than 50Amps or the pulse width is greater than 850μs.

The process for the saturation test is identical to the inductance only test except the pulses will continue until the saturation % value is greater than the user defined limit. If for some reason the saturation limit is not exceeded, the pulses will continue until the current is greater than 50Amps or the pulse width is greater than 850μs.

PCB Fabrication

PCB FAB Updated

I like to make my own PCB's so I have included a short video that highlights the process. I used a 4"x5" single sided .062thk PCB material. I did the design using FreePCB which I have used for years. The gerber viewer I use is Gerbv 2.6.0 it may not be the latest revision but it always works for me. The PCB layout is for a double-sided PCB so when using a single sided board the bottom layer(Red) is the artwork and the top layer(Green) is for jumper wires.

FreePCB: freeware PCB layout software

gerbv — a Gerber (RS-274X) viewer Files - SourceForge

PCB Assembly

PCB Assembly Updated Wide

After drilling and cleanup, the first thing I do is to solder in all the surface mount components. Surface mount components are easy to solder. I apply a thin coating of flux to the board and place several components at a time and then solder them. I repeat this process until all the components are soldered down. Next, I put in and solder all the through hole components. Next is to solder in all the top jumper wires. Finally, I solder the wire to board connectors.

Housing and Cover 3D Printing and Unit Assembly

Cover and Housing Assy

I used FreeCad version 0.19 to design the housing and cover. I sliced the stl files using Cura version 4.9.1 I used an Ender 3 V2 printer with PLA filament "Bone White" (205º - 225ºC) My bed temperature was set to 65ºC

FreeCAD: Your own 3D parametric modeler

Powerful, easy-to-use 3D printing software - Ultimaker Cura

Ender-3 V2 3D Printer - Creality

The Code

The attached code was developed on the Arduino IDE version 1.8.12 Use the RogerClark core that can be obtained from here "https://github.com/rogerclarkmelbourne/Arduino_STM32

During upload the following warning will be displayed;

WARNING: library JC_Button-master claims to run on avr architecture(s) and may be incompatible with your current board which runs on STM32F1 architecture(s)

Don't worry..it works!

Final Thoughts

This design can certainly be improved and I welcome any constructive comments. You can get all the necessary files using the link below. With regard to the PCB Fab I have included two folders, the one called Home Fab which contains the files necessary to make the PCB at home as described in my video. The second folder called Professional PCB contains modified files that "SHOULD" work if you wanted to send the gerbers out for fabrication. Since I have not done this I cannot guarantee the final result. Their may be unforeseen issues.

https://drive.google.com/drive/folders/1kDgG7nveHNSfvONXITkRaQ6ZjVJNfuAx?usp=sharing