Measuring inductance

I was wondering what precautions I should take for measuring a coil’s inductance. Following the various capacitive sensing programs my idea was to use a pin for pulling a pin connected to the coil L1 HIGH and then measuring the voltage drop across a resistor R1 in series to the coil.

WRITEPIN±----------o----OOOO—o--------o---------R1--------| GND
----|<|------/ --READPIN

By measuring the time it takes for READPIN to reach HIGH it should be possible to calculate L1 given a known R1 value…right?
My concern is about the coil’s kickback though. Is the parallel diode sufficient to protect the readpin from high voltages ?

Hmm, this is a tricky one! You should be OK with a diode to protect the Arduino when you switch off the current, though.

There are a few different ways to measure inductance, none of them easy. The traditional way is to use a Wheatstone Bridge, and drive it with AC:

Another way would be to set up the inductor and a resistor as a voltage divider, again with AC, and measure the impedance of the inductor. I suppose that's similar to the way yuo've described.

Just for reference: it works ! 8-)

I hooked the components up according to the diagram. The components I used are a N4004 rectifier diode, and R1= 230 Ohm. The coil is something I salvaged from a toy and my best guess is that it has an inductance of 0.3 uH. I tried a simple "wire around a pen" coil (0.03uH) but that did not work at all. With 230 Ohm and 5V output the maximum current should be around 22mA

Because of the resistors I had floating around, I made R1=230 Ohm. That should yield a current of 22mA (maximum rating is 40mA). For improved sensitivity it might be worth lowering it to 150 Ohm.

In my code I pulled up the output pin and then increased an int variable until the read port pin went HIGH. digitalRead() is a bit slow, so I wrote an optimized version and it took ~50 iterations for the pin to toggle. At that point I switch the output pin to be a read pin, turn off the pull-up, wait a few milliseconds and put it back into write mode.

I tested some iron and brass screws which increased the counter by 10% when they were 0.5" or less from the coil. The surprising result though was that placing aluminium in the same spot DECREASED the counter. So I am guessing that there is either some capacitive coupling or a phase shift going on. In contrast to the CapSense examples this measurement is not sensitive to grounding issues- connection to wallplug and battery gave identical results. Putting my hand on top of the coil did not change the values.

So there you have it: robust short-range metal detection with an arduino ;)

it works !

Good news!

How did you display the results?

So I am guessing that there is either some capacitive coupling or a phase shift going on.

It's to do with the material's Permeability.

Have a read:-

How did you display the results?

I have a DOG-M LCD module hooked up to display the counter value. Then I got a little carried away and added a bargraph to that LCD screen, before utilizing the Serial port to write the value back to the host and displaying it in a graph :D

It's to do with the material's Permeability.

I dunno about that. Obviously u for iron is much bigger than for air. But u for aluminum should not be smaller than uAir. Your article had a couple of other factors though that might mess up my readings.

But u for aluminum should not be smaller than uAir.

The magnetic filed will induce eddy current to flow in the metal. This then acts like an electro magnet. As the direction of this current flow is opposite to the creating field then it will act as a sort of negative inductance. Therefore your results are to be expected.

Has anyone considered implementing Prof. George Steber's "LMS Impedance Bridge" on the Arduino? It has the advantage of being able to measure capacitance as well. In his article (QEX Sep/Oct 2005 pp 41-47) he uses only a PC's soundcard I/O and a LM358 dual op-amp. The description is out there on the web.