Introduction: Arduino Based Pulse Induction Detector - LC-Trap

Picture of Arduino Based Pulse Induction Detector - LC-Trap

While looking for further ideas for a simple Ardino Pulse Induction metal detector with only one supply voltage I came across the homepage of Teemo:

http://www.digiwood.ee/8-electronic-projects/2-metal-detector-circuit

He created a simple Pulse Induction detector using the LC-Trap principle. Similar circuits were posted here on Instructable by TechKiwiGadgets. Exept that the Teemo circuit uses the internal comparators of the a PIC microcontroller, thus needing less external components

So I was challenged to use the Arduino instead of a PIC-Controller for this schematic and look how far I can get.

Step 1: Schematic

Picture of Schematic

The Arduino schematic is a bit more complicated as the Arduino does not allow to route an internal analog signal to the input of the comparator. This adds two components for the PWM-to-analog converter to the schematic. This leads to a design with 12 external components (leaving out the speaker and the 16x2 LCD), compared to 9 of the Flip Coil design.

The working principle of the schematic is explained very well on the website of Teemo. Basically the coil is powered and then switched off. After switching off, the coil and the condenser in parallel will create a damped oscillation. The frequency and the decay of the oscillation is influenced by metal in proximity of the coil. For further details of the circuit see the page of Teemo or of TechKiwi here on instructables.

As in the Flip Coil Pulse Induction detector I use the internal comparator and the possibility to trigger an interrupt to acquire the signal from the coil.

In this case I will get multiple interrupts as the voltage is oscillating around the reference voltage set at the comparator. At the end of the oscillation, the voltage at the coil will settle around 5V, but not exactly. So the reference voltage of the comparator needs to be set somewhere below this voltage. The value of voltage is not that important, the only thing is, that it should be stable. I am using a digital-to-analog-converter by using the PWM signal at D5 to create this reference voltage.

IMPORTANT: The PWM output use the internal timers to create the PWM signal. As I am using the “timer1” for the measuring of the signal decay, no PWM output using this timer will work. As D5 uses “timer0” D5 is working out well.

At the start up of the detector, this voltage is slowly increased to the point where the Arduino get confusing readings. That is the point where the reference voltage exceeds the signal voltage of the coil (or where I get more pulses than I can work with) The voltage is then set a bit lower and used for reference. This methode allows an automatic adaptation to different coils.


Step 2: Programming

Picture of Programming

Now that the circuit is designed and the prototype is build, it is time to find an appropriate approach for detecting metal.

1. Counting pulses

Counting of pulses of the oscillation until it fully decays is one idea.

If there is metal near to the coil the amount of oscillation decreases. In this case the reference voltage of the comparator should be set to a level that the last pulse is barely still measured. So in case something is detected, this pulse immediately vanishes. This was a bit problematic.

Each wave of the oscillation creates two interrupts. One while going down and one going back up. To set the reference voltage exactly to the crest of an oscillation wave, the time between going down and going up should be as short as possible (see picture). Unfortunately here the overhead of the Arduino environment creates problems.

Each trigger of the interrupt calls for this code:

ISR(ANALOG_COMP_vect){
  oldSREG= SREG;
  cli();
  Toggle1=Toggle0;
  Toggle0=TCNT1;
  SREG = oldSREG;
}

This code takes some time (if I remember right, about 78 instruction cycles witch is about 5 microseconds @ 16MHz). Therefore the minimum detectable distance between two pulses is exactly the time this code takes, If the time between two triggers gets shorter (see picture), it will go undetected, as the code is fully executed prior to detecting a second interrupt

This leads to a loss in sensitivity. At the same time, I noticed, that the damping of the oscillations is very sensitive to whatever external influences, thus making this approach in total a bit difficult.

2. Measuring the frequency

Another way to detect metal is measuring the frequency of the oscillation. This has a big advantage compared to measuring the damping of the oscillation as the change in frequency allows for discrimination of the metal. In case there is ferrous material near the coil, the frequency will slow down, in case there is precious metal near the coil, the frequency will increase.

The easiest way to measure the frequency is to measure the amount of pulses after the coils starts oscillating. The period of time between the start and the last pulse divided by the total amount of measured pulses is the frequency. Unfortunately the last few oscillations are quite unsymmetrical. As the presence of metal also influences the decay of the oscillation the last oscillations is even more unsymmetrical, the readings are difficult to interpret. In the picture this is show with the crossing 1 to 1’ and 2 to 2’.

A better way is therefore to use some earlier pulses to measure the frequency. While testing, interestingly I found out that some pulses pulses are more sensitive than others. Somewhere at 2/3 of the oscillations is a good point to acquire the data.

Processing the data.

While writing and improving the code, I found it pretty difficult to get stable readings. Most of the time the measured values were stable, with single values messing up analysis of the data.

1. The LCD

The first approach was to measure 10 pulses and then to show the values on the LCD. For some kind of reason, each writing to the LCD made the readings shift for a small amount of counts. Although very small, still this made it difficult to get stable readings.

The solution was to write a routine, that each pulse only 3 digits were written to the LCD, resulting in a full LCD refresh every 10 pulses (16x2 digits = 32 digits).

2. Minimum value approach

To improve the stability of the readings further I wrote a serial output routine to get a better feeling for the measured data. There it became apparent, that although most of the readings were somewhat stable, some were not! Some readings of the “same” oscillation pulse were so far apart that it would wreck every approach to analyze a shift in frequency.

When looking into the details I noted, that “misreadings” were only to the positive direction. So if “pulse 18” was normally measured after 6608 counts of “timer1”, deviations were rather higher (6608+) than lower, with quite some readings at the exact lower end (see picture). So I deceided to create a window of 10 measurements and only look only at the lowest measured value. If this lowest value changed (decreased or increased) this could be regarded as a detection.

This approach proved to be very stable.

3. The voltage

The original design of Teemo is powered below 5 volts. As my assumptions was “more volts = more power = more sensitivity” I powered the unit in the beginning with 12V. This resulted in heating up of the MOSFET. This heating-up then resulted in a general drift of the measured values, leading to frequent re-balancing of the detector. By decreasing the voltage to 5V the heat generation of the MOSFET could be minimized to a level where almost no drifting of the readings were observed. This made the circuit even simpler, as the on-board voltage regulator of the Arduino was not needed anymore.

Step 3: Final Results

Picture of Final Results

The advantage of the detector is that it discriminates between precious and ferrous material. The disadvantage is, that the sensitivity with this simple schematic is not that good. To compare the performance I used the same references as for the Flip-Coil detector. Probably good for some pinpointing, but most likely disappointing for real searching.

Here the original design with the PIC controller might be more sensitive as it is running on 32MHz instead of the 16MHz of the therfor providing a higher resolution for detecting shifts in frequency.

Results were achieved by using the coil with 48 turns @ 100mm.

As always, open for feedback

Comments

About This Instructable

235views

3favorites

License:

More by JorBi:Arduino Based Pulse Induction Detector - LC-TrapArduino Based Pulse Induction Detector - Flip CoilArduino IC-Tester
Add instructable to: