Professional Documents
Culture Documents
Diy Arduino Based Metal Detector
Diy Arduino Based Metal Detector
UPDATE: Try using BC547 as transistor people have reported problems with
2n2222.
Me and my son decided to go treasure hunting with a metal detector that we
have but we couldn't find it anywhere. Being proper makers we decided that
it would be more fun to build one ourselves rather than keep trying to find
it.
Most metal detectors uses a search coil that act as part of an oscillator
circuit. When metal is put in proximity of the search coil the frequency of
the oscilations changes.
Many metal detectors (including the one we can't find) uses another more
stable oscillator BFO (beat frequency oscillator) to act as a reference for
the frequency of the search coil. Usually the frequency of the BFO is
adjusted to exactly match that of the search coil oscillator when no metal
is present near this.
The signals from these two oscillators are then fed to a, usually analog,
circuit that create an output proportionally to the difference in frequency
og the two. This may be either an audiable tone and/or some meter reading.
Another device that are really good at detecting minute frequency changes
is a microcontroller. We decided to swap the BFO approach for a
microcontroller and came up with following simple circuit:
// http://dzlsevilgeniuslair.blogspot.dk/
// Connect search coil oscillator (20-200kHz) to pin 5
// Connect piezo between pin 13 and GND
// Connect NULL button between pin 12 anf GND
// REMEMBER TO PRESS NULL BUTTON AFTER POWER UP!!
#define
#define
#define
#define
SET(x,y)
CLR(x,y)
CHK(x,y)
TOG(x,y)
(x |=(1<<y))
(x &= (~(1<<y)))
(x & (1<<y))
(x^=(1<<y))
//-Last time
//-time between ints
//-Measurement ready flag
//-Guess what
float clf=f*SENSITIVITY;
if(clf>10000)
clf=10000;
FTW=clf;
//-Click generator
if(millis()>timer)
{
timer+=10;
PCW+=FTW;
if(PCW&0x8000)
{
digitalWrite(13,HIGH);
PCW&=0x7fff;
}
else
digitalWrite(13,LOW);
}
// |
// |
//-+
//-Last time
void setup()
{
pinMode(13,OUTPUT);
//-piezo pin
return f;
}
//-Reset flag
//-Click generator
if(millis()>timer)
{
timer+=10;
PCW+=FTW;
if(PCW&0x8000)
{
digitalWrite(13,HIGH);
PCW&=0x7fff;
}
else
digitalWrite(13,LOW);
}
}