Electronic – Detect if coil is near steel piece using MCU

coilinductanceinductance-measurementmicrocontrollerproximity-sensor

How to detect inductance change using MCU (lowest power methods preferred). I want to detect if the coil touches steel piece (higher inductance) and when it does not (lower inductance). Basically I need to compare inductances at two positions and compare the values. Then I will derive a threshold value to detect when the coil is away from the steel piece.

Best Answer

I used a PIC12F509 to make this kind of sensor, years ago. It used 100uH leaded-resistor type inductor L=6mm D=2.5mm. The actual capacitor values I can't recall. It was used to make a waterproof switch that reliably worked in salt water. In my case a spring (ID=8mm L=4mm) slid over the coil forming a shorted turn.

schematic

simulate this circuit – Schematic created using CircuitLab

C1,L1 form a resonant circuit at 150kHz (for values shown). One half cycle is approx 3us The output is enabled, then a single pulse energises the circuit (hi for 2us), then you switch back to input and sample the input. The LC tank will now resonate. i.e it will going - + - + at the resonant frequency for a couple of cycles. Immediately after energising it goes negative, then a half cycle later the voltage will peak +ve, and you will sample as logic 1 . When there is metal forming a shorted turn the peak happens earlier, because L is effectively reduced, and you will sample 0. Code is very simple - probably less than 10 opcodes.

You need to choose L and C to suit how fast your micro works (PIC was 1us instruction cycles). You need to experiment with coil types to suit your situation. You need to empirically test the best excitation pulse (how wide, single +ve pulse vs 1/0 pulse) and explore what the resonance looks like and how it moves, using an oscilloscope. Note that there are two detection modes possible. I used change in L and therefore change in position of resonant pulse.

It is also possible to look at the decay-time of the ringing, by counting the number of ring cycles. In this case the presence of metal will increase the loss, and the ringing dies faster. e.g ring count drops from 3 to 1.