Pulse Metal Detector on Arduino
A redesigned version of the well-known impulse metal detector – “Pirate”, but on Arduino. Has good sensitivity even for small coins. Stable regardless of temperature and battery charge. The scheme of Pulse Metal Detector based Arduino is simplified as much as possible.
Among the shortcomings, one can note the lack of the ability to determine the type of metal. The type can only be determined by metal detectors with a radio emitting detection principle (they are complex in the device and require precise adjustment). The impulse metal detector, in turn, operates on the magnetic detection of induction currents in the metal. Search induction is indistinguishable for ferrous and non-ferrous metals.
By the way, there is also a third type of metal detector – frequency. An ineffective and very simple design based on a generator of oscillations of a magnetic circuit, which is sensitive to changes in the magnitude of the induction of the coil. We will not consider it due to its low sensitivity. Personal experiments in the development of such a design, at best, allowed detecting a frying pan 20 cm deep. I reacted to coins only at point-blank range. Practically useless thing. Therefore, he immediately refused it.
Our pulse metal detector circuit has several main components in it. Arduino generates pulses, they are amplified by a field-effect transistor (power switch), which in turn induces pulses of a magnetic field in the coil. The magnetic pulse travels to the desired metal and induces a current in it, and then a return signal of the magnetic field. This reverse magnetic flux, after a short delay, returns back to the coil of the metal detector and generates a pulse. The signal passes by a pair of diodes (diodes are needed to limit the voltage to 1 volt) and goes to the input of the operational amplifier. The amplified signal enters the arduino in which the “falling tail” is calculated after the coil is disconnected with the power switch. Those. just the answer from the desired metal object. Depending on the decay time, we can judge the size or distance of the object. The indicator shows this value in 8 levels of indicators.
Speaking of the coil. It should be 20 cm in diameter with 20 turns of wire 0.4 – 0.8 mm. The thickness of the wire also affects the induction of the entire coil. A large deviation from the wire thickness will lead to a deterioration in the sensitivity of the device. The coil is inserted into a PVC water pipe and does not have any additional metal connections.
The pulse metal detector based arduino program sketch contains a pulse generator and an algorithm for processing the incoming signal from the amplifier.
int ss0 = 0;ss0 = 0 ;
int ss1 = 0;int ss1 = 0 ;
int ss2 = 0;int ss2 = 0 ;
long c0 = 0;long c0 = 0 ;
long c1 = 0;long c1 = 0 ;
long c2 = 0;long c2 = 0 ;
byte i = 0;byte i = 0 ;
int sss0 = 0;int sss0 = 0 ;
int sss1 = 0;int sss1 = 0 ;
int sss2 = 0;int sss2 = 0 ;
int s0 = 0;int s0 = 0 ;
int s1 = 0;int s1 = 0 ;
int s2 = 0;int s2 = 0 ;
void setup ()void setup ()
{{
DDRB = 0xFF; // port B - all out= 0xFF ; // port B - all out
DDRD = 0xFF; // port D - all out= 0xFF ; // port D - all out
for (i = 0; i <255; i ++) // calibrationfor ( i = 0 ; i < 255 ; i ++) // calibration
{{
PORTB = B11111111; = B11111111 ;
delayMicroseconds (200); ( 200 );
PORTB = 0; = 0 ;
delayMicroseconds (20);( 20 );
s0 = analogRead (A0);= analogRead ( A0 );
s1 = analogRead (A0);= analogRead ( A0 );
s2 = analogRead (A0);= analogRead ( A0 );
c0 = c0 + s0;= c0 + s0 ;
c1 = c1 + s1;= c1 + s1 ;
c2 = c2 + s2;= c2 + s2 ;
delay (3);( 3 );
}}
c0 = c0 / 255;= c0 / 255 ;
c0 = c0 - 5;= c0 - 5 ;
c1 = c1 / 255;= c1 / 255 ;
c1 = c1 - 5;= c1 - 5 ;
c2 = c2 / 255;= c2 / 255 ;
c2 = c2 - 5;= c2 - 5 ;
}}
void loop ()void loop ()
{{
PORTB = B11111111; = B11111111 ;
delayMicroseconds (200); ( 200 );
PORTB = 0; = 0 ;
delayMicroseconds (20); ( 20 );
s0 = analogRead (A0);= analogRead ( A0 );
s1 = analogRead (A0);= analogRead ( A0 );
s2 = analogRead (A0);= analogRead ( A0 );
ss0 = s0 - c0;= s0 - c0 ;
if (ss0 <0) if ( ss0 < 0 )
{{
sss0 = 1;= 1 ;
} }
ss0 = ss0 / 16; = ss0 / 16 ;
PORTD = ss0; // send to the indicator (send to LEDs)= ss0 ; // send to the indicator (send to LEDs)
delay (1);( 1 );
ss1 = s1 - c1; = s1 - c1 ;
if (ss1 <0) if ( ss1 < 0 )
{{
sss1 = 1; = 1 ;
} }
ss1 = ss1 / 16;= ss1 / 16 ;
PORTD = ss1; // send to the indicator (send to LEDs)= ss1 ; // send to the indicator (send to LEDs)
delay (1);( 1 );
ss2 = s2 - c2;= s2 - c2 ;
if (ss2 <0)if ( ss2 < 0 )
{{
sss2 = 1;= 1 ;
}}
ss2 = ss2 / 16;= ss2 / 16 ;
PORTD = ss2; // send to the indicator (send to LEDs)= ss2 ; // send to the indicator (send to LEDs)
delay (1);( 1 );
if (sss0 + sss1 + sss2> 2)if ( sss0 + sss1 + sss2 > 2 )
{{
digitalWrite (7, HIGH);( 7 , HIGH );
digitalWrite (6, HIGH);( 6 , HIGH );
digitalWrite (5, HIGH);( 5 , HIGH );
digitalWrite (4, HIGH);( 4 , HIGH );
digitalWrite (3, HIGH);( 3 , HIGH );
digitalWrite (2, HIGH);( 2 , HIGH );
digitalWrite (1, HIGH);( 1 , HIGH );
digitalWrite (0, HIGH);( 0 , HIGH );
delay (1);( 1 );
sss0 = 0;= 0 ;
sss1 = 0;= 0 ;
sss2 = 0;= 0 ;
}}
}}
|
Reference : https://diytimes.ru/post/84