Metal Detector

Metal Detector is a security device which is used for detecting metals which can be harmful, at various places like Airports, shopping malls, cinemas etc. Previously we have made a very simple Metal detector without a microcontroller.

Working Concept:

Whenever some current passes through the coil, it generates a magnetic field around it. And the change in the magnetic field generates an electric field. Now according to Faraday’s law, because of this Electric field, a voltage develops across the coil which opposes the change in magnetic field and that’s how Coil develops the Inductance, means the generated voltage opposes the increase in the current. The unit of Inductance is Henry and formula to measure the Inductance is:

 

L = (μο * N2 * A) / l

Where,

L- Inductance in Henries

μο- Permeability, its 4π*10-7 for Air

N- Number of turns

A- Inner Core Area (πr2) in m2

l- Length of the Coil in meters

When any metal comes near to the coil then coil changes its inductance. This change in inductance depends upon the metal type. Its decreases for non-magnetic metal and increases for ferromagnetic materials like iron.

Depending on the core of the coil, inductance value changes drastically. In the figure below you can see the air-cored inductors, in these inductors, there will be no solid core. They are basically coils left in the air. The medium of flow of magnetic field generated by the inductor is nothing or air. These inductors have inductances of very less value.

 

Arduino Interfacing:

Code:

 

#define capPin A5
#define buz 9
#define pulsePin A4

#define led 10

long sumExpect=0; //running sum of 64 sums 
long ignor=0;   //number of ignored sums
long diff=0;        //difference between sum and avgsum
long pTime=0;
long buzPeriod=0; 

void setup() 
{
  Serial.begin(9600);
  pinMode(pulsePin, OUTPUT); 
  digitalWrite(pulsePin, LOW);
  pinMode(capPin, INPUT);  
  pinMode(buz, OUTPUT);
  digitalWrite(buz, LOW);
  pinMode(led, OUTPUT);
}

void loop() 
{
  int minval=1023;
  int maxval=0;
  long unsigned int sum=0;
  for (int i=0; i<256; i++)
  {
    //reset the capacitor
    pinMode(capPin,OUTPUT);
    digitalWrite(capPin,LOW);
    delayMicroseconds(20);
    pinMode(capPin,INPUT);
    applyPulses();

    //read the charge of capacitor
    int val = analogRead(capPin); //takes 13×8=104 microseconds
    minval = min(val,minval);
    maxval = max(val,maxval);
    sum+=val;

    long unsigned int cTime=millis();
    char buzState=0;
    if (cTime<pTime+10)
    {
      if (diff>0)
        buzState=1;
      else if(diff<0)
        buzState=2;
    }
    if (cTime>pTime+buzPeriod)
    {
      if (diff>0)
      buzState=1;
      else if (diff<0)
      buzState=2;
      pTime=cTime;   
    }
    if (buzPeriod>300)
    buzState=0;

    if (buzState==0)
    {
      digitalWrite(led, LOW);
      noTone(buz);
    }  
    else if (buzState==1)
    {
      tone(buz,2000);
      digitalWrite(led, HIGH);
    }

    else if (buzState==2)
    {
      tone(buz,500);
      digitalWrite(led, HIGH);
    }
  }

  //subtract minimum and maximum value to remove spikes
  sum-=minval; 
  sum-=maxval;

  if (sumExpect==0) 
  sumExpect=sum<<6; //set sumExpect to expected value
  long int avgsum=(sumExpect+32)>>6; 
  diff=sum-avgsum;
  if (abs(diff)<avgsum>>10)
  {
    sumExpect=sumExpect+sum-avgsum;
    ignor=0;
  } 
  else 
    ignor++;
  if (ignor>64)
  { 
    sumExpect=sum<<6;
    ignor=0;
  }
  if (diff==0) 
    buzPeriod=1000000;
  else 
  buzPeriod=avgsum/(2*abs(diff));    
}

void applyPulses()
{
    for (int i=0;i<3;i++) 
    {
      digitalWrite(pulsePin,HIGH); //take 3.5 uS
      delayMicroseconds(3);
      digitalWrite(pulsePin,LOW);  //take 3.5 uS
      delayMicroseconds(3);
    }
}

 

Application:

  • Airport security– screen people before allowing access to the boarding area and the plane
  • Building security– screen people entering a particular building, such as a school, office or prison
  • Event security– screen people entering a sporting event, concert or other large gathering of people
  • Item recovery– help someone search for a lost item, such as a piece of jewelry
  • Archaeological exploration– find metallic items of historical significance
  • Geological research– detect the metallic composition of soil or rock formations

 

Reference:

https://electronics.howstuffworks.com/gadgets/other-gadgets/metal-detector7.htm

 https://www.instructables.com/id/Simple-Arduino-Metal-Detector/

https://create.arduino.cc/projecthub/mircemk/diy-arduino-based-pulse-induction-metal-detector-c6f244

https://create.arduino.cc/projecthub/Ameduino/metal-detector-301d35

WhatsApp us whatsapp