You are on page 1of 13

CHAPITRE 2 : Conception et réalisation d’un détecteur de métaux

1. Introduction

La conception et réalisation d’un détecteur de métaux peuvent être une


entreprise fascinante pour les bricoleurs et les passionnés d’électronique.

Cependant, cela peut sembler intimidant pour les débutants ou les personnes
ne disposant pas de connaissance en électronique.

2. Description du schéma d’un détecteur de métaux :


3. Conception et réalisation d’un détecteur de métaux :

4 .Réalisation détecteur de métaux :


La réalisation d’un détecteur de métaux implique l’assemblage des composant
électronique dans un bobine, la connexion des fils et la fixation de la bobine de
recherche .Les guides de fabrication de détecteur de métaux [6] peuvent aider
à la réalisation pratique en fournissant des schémas de conception, des liste de
composant et des instructions étape par étape.

La revue Electronique & Loisirs Magazine [1] décrit la réalisation pratique d’un
détecteur de métaux à induction pulsée en utilisant un microcontrôleur PIC,
une 20 cm de diamètre et une interface utilisateur avec un écran LCD et des
boutons-poussoirs.
5 .Programmation du microcontrôleur:
//Metal detector based on pulse delay in LR circuit
//Connect a coil between pin 10 and pin 8,
//a 100 Ohm resistor between pin 8 and ground,
//a speaker in series with a 10muF capacitor between pin 12 and ground,
//a reset-button between A0 and ground.
//Reference coil: 60 turns, diameter 6.3cm, AWG26 (0.25mm) wire.
L~300muH, R~2Ohm

#define debug true

//some parameters
#define sensitivity 5000 //threshold as a fraction of reference
#define aim time 160000 //aim for measurement every 160k cycles
(=10ms)
#define LEDpulselen 16000 //length of the LED pulse in clock cycles
#define cycles 40 //number of clock cycles reserved for calculations
#define printfrac 50 //fraction of measurements printed when in debug
mode

//pin definitions - cannot change freely!


#define pulse pin 10 //must be pin 10 - TIMER1B output
#define probe pin 8 //must be pin 8 - input capture pin
#define LED pin 13 //if changed also need to update the direct-port
writing
#define sound pin 12 //if changed also need to update the direct-port
writing
#define reset pin A0 //can be changed freely

//global variables - shared between main loop and measurement function


long int imeas=0; //counts the number of measurements performed
int absdiff; //absolute value of difference wrt reference
long int phase=0; //tracks integral of absdiff
long int phasemax; //value at which the phase counter turns over
int LED cycles=0; //number of cycles that the LED pin stays high
int LED cycle=0; //cycle index of the LED pulse

Void setup () {
no Interrupts (); //disable all inerrupts to avoid glitches

if (debug) Serial. begin (9600);

pin Mode (pulsepin, OUTPUT);


digital Write (pulsepin, LOW);
pin Mode (probepin, INPUT);
Pin Mode (LEDpin, OUTPUT);
digitalWrite (LEDpin, LOW);
Pin Mode (soundpin, OUTPUT);
digital Write (soundpin, LOW);
Pin Mode (resetpin, INPUT_PULLUP);

//setup timer1 to FASTPWM on pin 10


TCCR1A=0B00100011;
TCCR1B=0B00011001;
}

//perform measurement of delay of the trailing edge


long int meas (int period, int minlen, int maxlen, int steplen, int nloop){
long int sum=0;
int nmiss=0;
OCR1A=period; //set the period
TIFR1 |= 0B00000001; //clear the timer overflow bit
for (int iloop=0; iloop<nloop; iloop++){
for (int len=minlen; Len<maxlen; len+=steplen){
OCR1B=len; //set the pulse length
While ((TIFR1 & 0B00000001) == 0); //wait for timer overflow
TIFR1 |= 0B00000001; //clear the timer overflow bit
While (TCNT1< (period-cycles)); //wait till pulse is almost finished
if ((TIFR1&0B00100000)! =0) { //check if trailing edge has been
detected
Sum+= (ICR1-len);
TIFR1 |= 0B00100000; //clear the input capture flag
} else {
nmiss++;
}
//update phase
Phase+=absdiff;
//blink and click when phase rolls through
if (phase>phasemax) {
Phase-=phasemax;
LED cycle=LED cycles;
PORTB= (PORTB|0B00100000); //switch on LED
PORTB= (PORTB^0B00010000); //invert sound pin - click!
}
//switch off LED when it's been on long enough
if (LED cycle>0) {
LED cycle--;
if (LED cycle==0) PORTB= (PORTB& (! 0B00100000));
}
}
}
if (nmiss>0) sum=0; //invalidate the result if there have been missing
pulses
return sum;
}

//flash LED with error code indefinitely if there's been an error


Void go error (byte error code) {
If (debug) {
Serial. Print ("ERROR ");
Serial. Print (error code);
If (error codes==1) Serial.println (": No pulse on probe pin - check
connections");
If (errorcode==2) Serial.println (": Delay too short - try more windings");
If (error codes==3) Serial.println (": Delay too long - try fewer
windings");
If (error codes==4) Serial.println (": No robust pulse on pulse length
scan - check coil resistance");
}
//enable in interrupts to use delay () and flash to indicate error code
Interrupts ();
While (true) {
For (byte i=0; i<error code; i++) {
digital Write (LEDpin, HIGH);
delay (100);
digital Write (LEDpin, LOW);
delay (100);
}
delay (500);
}
}

Void loop () {
//perform initial robust measurement of average delay time
long int tau=meas (16000, 8000, 8001,1,16)/16;
if (debug)Serial. Print ("delay in clock cycles :");
if (debug) Serial.println(tau);
if (debug) Serial. Print ("estimated coil inductance in muH :");
if (debug) Serial.println (1.44*tau*100.0/(16.0));

if (tau==0) go error (1); // no pulse


if (tau<5) go error(2); // too short
if (tau>800) go error (3); // too long

//choose pulsing parameters based on measured delay time


int minlen=3*tau;
int maxlen=5*tau;
int period=maxlen+2*tau+cycles;
LED cycles=LEDpulselen/period+1;

// repeat loop or speed up loop to approach aimed duration of


measurement
int steplen=1;
int nloop=1;
float tot time=float(period)*(maxlen-minlen);
if (tot time>aim time*(3.0/2.0)) steplen=round (tot time/aimtime);
if (tot time<aim time*(2.0/3.0)) nloop=round (aim time/tot time);

if (debug) Serial. Print (" minlen: ");


if (debug) Serial. Print (minlen);
if (debug) Serial. Print (" maxlen: ");
if (debug)Serial. Print (maxlen);
if (debug) Serial. Print (" steplen: ");
if (debug) Serial. Print (steplen);
if (debug) Serial. Print(" period: ");
if (debug) Serial. Print (period);
if (debug) Serial. Print (" nloop: ");
if (debug) Serial. Print (nloop);
if (debug) Serial. Print (" LED cycles: ");
if (debug) Serial.println (LED cycles);

//perform a scan from minlen to maxlen


long int minval=1000000000
;
for (int len=minlen; len<maxlen; len+=steplen) {
long int Val=meas (period, len, len+1, 1, nloop);
minval=min (val, minval);
if (debug) Serial. Print ("len, Val :");
if (debug) Serial. Print (len);
if (debug) Serial. Print (" ");
if (debug) Serial.println (val);
}
if (minval==0) go error (4);

//determine the reference value


long int ref=meas (period, minlen, maxlen, steplen, nloop);

//threshold and phasemax


int threshold=ref/sensitivity;
Phasemax=16000000/period*threshold; //aim for 1Hz at threshold
if (debug) Serial. Print ("reference, threshold, phasemax: ");
if (debug) Serial. Print (ref);
if (debug) Serial. Print (" ");
if (debug) Serial. Print (threshold);
if (debug) Serial. Print (" ");
if (debug) Serial.println (phasemax);

long int sum=0;


long int sumsq=0;
While (true) {
long int Val=meas (period, minlen, maxlen, steplen, nloop);

//check if reset of reference value is requested


if (digital Read(reset pin)==LOW) ref=val;

int diff=val-ref;
Absdiff=abs (diff);
If (absdiff<threshold) {
Phase=0; //reset the phase
if (diff>0) ref+=1; //absorb slow drifts
if (diff<0) ref-=1;
}

If (debug){
Sum+=diff;
Sums+=long (diff)*long (diff);
if (imeas%printfrac==0) {
float mean=float (sum)/printfrac;
float rms=sqrt ((float (sumsq)/printfrac) - POW (mean, 2.0));
Serial. Print (imeas);
Serial. Print (" val ref diff phase ");
Serial. Print (Val);
Serial. Print (" ");
Serial. Print (ref);
Serial. Print (" ");
Serial. Print (diff);
Serial. Print (" ");
Serial. Print (mean);
Serial. Print (" ");
Serial. Print (rms);
Serial.println ("");
sum=0; sumsq=0;
}
} Imeas++;} }
6. Principe de fonctionnement du circuit :

Un détecteur de métaux fonctionne en émettant un champ électromagnétique

à travers une bobine de fil conducteur. Lorsque ce champ entre en contact avec

un objet métallique, il crée un courant électrique dans l’objet qui perturbe le

champ électromagnétique.

Le détecteur de métaux détecte cette perturbation et émet un signal sonore ou

visuel pour alerter l’utilisation.

7. Teste et résultat :

Nous avons passé une pièce d’or à travers le détecteur de métal cela nous a

causé un son et il en était de même avec l’argent et plus la masse du métal était

grande plus le son était fort et à la fin nous l’avons testé en présence du

enseignants et cela a été fait avec succès.


8. Conclusion :

La czonception et la réalisation d’un détecteur de métaux peuvent sembler

intimidantes, mais avec une compréhension de base de l’électronique et de

guides de fabrication, cela peut être un projet réalisable. Les résultats de

recherche donnent des informations sur la conception et la réalisation de

détecteur de métaux à induction pulsée, de détecteur de débris de matériaux

métallique et de détecteur de métaux sensibles. Il est important de notre qu’il

peut y avoir des réglementations locales sur l’utilisation de détecteur de

métaux et il est important de connaitre ces réglementation avant de fabrique

ou d’utiliser un détecteur de métaux.

You might also like