Connect with us

How do I build a Metal Detector?

Discussion in 'General Electronics Discussion' started by chuchito, Mar 28, 2014.

Scroll to continue with content
  1. chuchito

    chuchito

    2
    0
    Mar 28, 2014
    I need a cheap metal detector for a ferrous material with a range of at least 3'. The output signal needs to be a DC voltage. Ideally the output should vary from 0 V when no ferrous object is in range to 5 V as the detector approaches the object. The goal is to feed the signal to an analog input from a microcontroller.
    Does anyone know of a circuit configuration I could use to meet those specs?
    Thanks
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    11,413
    2,619
    Nov 17, 2011
    Welcome to our forum.

    Others have written tons of stuff on metal detectors. Here's a collection of different detector circuits.
    All these detetcors have in common is that they either give a yes/no indication for metal detected or an audible signal (beat frequency) which changes with distance between the metal and the detector (and with the type of metal).

    I'm not aware of a detector that gives an anlog signal where the amplitude changes with distance. You have at least these options:
    1) convert the beat frequency into an analog signal (you could use a rectifier and a filter for a crude conversion)
    2) feed the beat frequency (with suitable voltage level) to an input pin of the microcontroller. Have the microcontroller count the freqeuncy directly.

    Regards,
    Harald
     
  3. Arouse1973

    Arouse1973 Adam

    5,165
    1,087
    Dec 18, 2013
    What about a magnet, very good at sensing metal.......Only joking. I am with harald don't know of one with an analog out. But a few years ago I helped design one which worked like this. Take a tuned circuit and ping it with a pulse the after a time measure the voltage. Then measure again and if metal is present the voltage will be lower. This measures the amplitude of ringing which for a under damped coil is an exponential function
    Adam
     
  4. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,489
    2,830
    Jan 21, 2010
    The problem with the requirements is that a large piece of metal further away will generally produce the same response as a small piece of metal that is closer.
     
  5. switychandra

    switychandra

    3
    0
    Mar 26, 2014
    Simple BFO metal detector

    BFO ( beat frequency oscillator ) metal detectors use two oscillators, each of which produces a radio frequency. One of these oscillators uses a coil of wire that we call the search loop. The second oscillator uses a much smaller coil of wire, and is usually inside the control box and is called the reference oscillator. By adjusting the oscillators so their frequencies are very nearly the same, the difference between them is made audible as a beat note, this beat note changes slightly when the search loop is moved over or near to a piece of metal. It has been found in practice best to make the search oscillator fixed say at 100khz and to arrange for the reference oscillator to be adjustable 100khz plus or minus 250hz. This gives a beat note of 250hz to 0 to 250hz. The beat note disappears or nulls when the two oscillators are about equal. This type of detector is most sensitive when the beat note is close to zero, about 5hz ( motor boating ) any slight change being noticeable.
     
  6. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Posting other people's work without attribution is plagiarism and is bad netiquette.

    It is best to post the link to the article. In this case, it is http://www.instructables.com/id/bfo-metal-detector/
     
  7. jpanhalt

    jpanhalt

    426
    4
    Nov 12, 2013
    @chuchito

    Are you trying to determine the distance of a piece of "ferrous" metal in air or can it be behind walls, in earth, or otherwise obscured from direct line of sight?

    Is it correct to assume you mean ferromagnetic, not ferrous? How important is that distinction to what you are doing?

    John
     
  8. Arouse1973

    Arouse1973 Adam

    5,165
    1,087
    Dec 18, 2013
    I agree Kris. You got me thinking, what about the common circuits we all use every day that we didn't design ourselves that appear time and time again. Someone designed it in the first place but we never mention it but would take credit for it. We all do that.
    Adam
     
  9. jpanhalt

    jpanhalt

    426
    4
    Nov 12, 2013
    And that got me thinking years ago, why electronics doesn't have a decent indexing system. Chemists have had a system for indexing structures for well over a century.

    John
     
  10. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    That one was a special case. switychandra posted a whole section of text, verbatim, from an easily accessible source, with no attribution, implying that it was his own words. He's also a new user. This usually means that he's trying to reach the 10 post limit so he can spam users with lots of PMs.

    As for standard building block circuits, I guess they all have inventors - thinking of the two-transistor astable multivibrator, for example - but mostly their names are lost in the mists of time. Some could be found through patent searches, and specific clever or unique circuits are still associated with their inventors, but not that many.

    Many designs originally appear in data sheets, application notes, and other application material, created by engineers working for component manufacturers, and are usually uncredited. Of course there are famous names in the field, such as Bob Widlar, who has patents for techniques used inside ICs, but I couldn't name any application circuits he designed.

    A lot of circuits are trivial and would have been "invented" by many people - who invented the op-amp-based summing amplifier? And some aren't really circuits, as such, just ways to use basic building blocks - who "invented" the emitter follower?

    I guess I don't have a problem with the status quo, personally.
     
  11. davenn

    davenn Moderator

    13,808
    1,943
    Sep 5, 2009
    and in general I agree wit that too

    I would strongly suggest tho that if a circuit has been obtained from a specific www site / publication it would be VERY GOOD manners to acknowledge the source so others can at least refer to it now or in the future


    Dave
     
  12. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Yes, definitely.

    If you are reproducing a complete circuit design, you should always give the source.

    Personally, I would normally link to the original article instead of reposting the diagram. The diagram is only part of the picture; you need the accompanying text.

    Many schematic images include the source URL; I normally include it in any designs I post here.
     
  13. Arouse1973

    Arouse1973 Adam

    5,165
    1,087
    Dec 18, 2013
    Private message SPAM. does that go on, blimey.
     
  14. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    I've heard that it does. I haven't seen any in my time here. The potential spammers have always been picked up well before they reach 10 posts.
     
  15. Arouse1973

    Arouse1973 Adam

    5,165
    1,087
    Dec 18, 2013
    What they keep asking stupid questions or what?
     
  16. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    No, the stupid questions are normally from genuine users :) We had one guy who would copy a paragraph or two from someone else's post further back on a thread and repost it. And lately there have been quite a few users just posting spam as new threads. They usually get caught within 12 hours or so.
     
  17. CDRIVE

    CDRIVE Hauling 10' pipe on a Trek Shift3

    4,960
    651
    May 8, 2012
    I would imagine that it wasn't a big leap for someone who was previously familiar with a Cathode Follower but who invented that? Perhaps a more accurate question would be can either really be considered inventions at all? After all, the inventor of the Triode had mathematically predicted its behavior prior to building the prototype. ;)

    Chris
     
  18. ami85t

    ami85t

    71
    0
    Feb 19, 2014
    Hi to all,
    I have build a metal detector circuit based on this idea:
    http://www.micro-examples.com/public/microex-navig/doc/076-picodetector.html
    I'm using a PIC16F877 and a Bluetooth module RN42SM.
    I implemented the detector by oscillating a PWM wave via the PIC,
    sending it through an inductor, capturing the frequency at the timer1
    and transmitting the data via the BT module to a PC.

    Up till now the timer's value slightly changes and doesn't give a good indication
    for metal detecting. Does somebody have any ideas of how to improve the
    detecting?
    I tried changing the frequency's value (521-15000hz) and changing the
    captures specifications for flag interrupt between every 4-16th rising edge.
    I have a few inductors of 380~680 mH value.

    Thanks, Amitai
     

    Attached Files:

    Last edited: Apr 1, 2014
  19. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Can you post a schematic please.
     
  20. ami85t

    ami85t

    71
    0
    Feb 19, 2014
    I have attached the schematic, quiet simple.
    hope I didn't forget anything.
    I'm attaching the code as well:

    Code:
    LIST	P=PIC16F877
        	
    include	<P16f877.inc>
    org		0x00
    
    	__CONFIG _LVP_OFF &_WDT_OFF &_PWRTE_OFF &_CP_OFF & _HS_OSC	
    
    	reset:
    	nop
    	goto	start
    	org		0x20
    
    start:
    
    
    
    
    ; configuration
    ;-----------------------------------
    
    ; used_ registers:
    	del1			EQU H'0030'  		; for delay
    	del2			EQU H'0031'  		; for delay
    	to_transmit		EQU H'0050'  		; data register
    	led1			EQU H'0070'  		; for led delay
    
    	banksel		ADCON1
    	movlw		0x07				; ADC PINS configured as a digital I/O									
    	movwf		ADCON1
    
    ;UART/*/*/
    	banksel		TRISC
    	bsf	 	 	TRISC, 6 
    	bsf		 	TRISC, 7	
    	
    	banksel  	TXSTA
    	movlw    	0xA7        		; master, transmit EN, Async mode, Transmit Shift Register empty, BRGH =1
    	movwf    	TXSTA	       		; Baud Rate = Fosc/(16(SPBRG+1)) , BRGH (baud rate) ignored in sync
    	
    	banksel		SPBRG
    	movlw	 	0x03		   		; = d"16" which corresponds to 125Kbps with 8MHz clock
    	movwf	 	SPBRG
    	
    	banksel  	RCSTA
    	movlw    	0x80		  		; enable UART	
    	movwf    	RCSTA
    	
    ;PWM, timer2/*/*/
    	banksel		TRISC
    	bcf			TRISC, 2 			; make the CCP1 pin an output.
    	
    	banksel		T2CON
    	movlw		0x07
    	movwf		T2CON				; Prescaler , TMR2 ON
    	
    	banksel		PR2					; output frequency = 			
    	movlw		0xF3
    	movwf		PR2					; 1 / [(PR2) + 1] • 4 • TOSC •(TMR2 prescale value)
    	banksel		CCPR1L				; duty cycle =(CCPR1L:CCP1CON<5:4>) • TOSC • (TMR2 prescale value)
    	movlw		0x7A				
    	movwf		CCPR1L				
    	banksel		CCP1CON
    	movlw		0x0C
    	movwf		CCP1CON
    
    ;capture, timer1 /*/*/
    	banksel		TRISC
    	bsf			TRISC, 1 			; make the CCP2 pin an input.
    
    	banksel		T1CON
    	movlw		0x01				;  en TMR1
    	movwf		T1CON				; (fosc/4) 
    	banksel		PIE2
    	bcf			PIE2, CCP2IE		; avoid false interrupts 
    
    	banksel		CCP2CON
    	movlw		0x07
    	movwf		CCP2CON				; Capture mode, every Xth rising edge 
    
    ;LED 
    	bcf			TRISD, 4
    	bcf			TRISD, 5
    	banksel		PORTD	
    	bcf			PORTD, 4
    	bcf			PORTD, 5
    	
    ; end configuration --------------------------------------
    
    
    
    
    ;************ MAIN PROGRAM ***************
    ;*****************************************
    	
    main_loop:
    
    Led_flicker:
    	movlw 		0xFF
    	movwf		led1
    	t2:
    	CALL		DELAY
    	decfsz		led1
    	goto		t2
    		
    	bcf			PORTD,5
    	bsf			PORTD,4		
    		
    	banksel		led1		
    	movlw 		0xFF
    	movwf		led1
    	t1:
    	CALL		DELAY
    	decfsz		led1
    	goto		t1
    
    	bcf			PORTD,4
    	bsf			PORTD,5
    ;---end Led flicker
    
    ;capture frequency/*/*
    	banksel		TMR1H	
    	clrf		TMR1H
    	clrf		TMR1L
    	
    	banksel		PIR2
    	bcf			PIR2, CCP2IF
    	check_capture:		
    	btfss		PIR2, CCP2IF					; 1  = A TMR1 register capture occurred (must be cleared in software)
    	goto		check_capture
    	bcf			PIR2, CCP2IF
    	
    ;transmitting data	
    	banksel		CCPR2H							; transmit MSB
    	movf		CCPR2H, w
    	banksel		to_transmit
    	movwf		to_transmit
    	sublw		0xFF				; if data = FF change to FE
    	btfsc		STATUS, Z
    	CALL		data_change	
    	movf		to_transmit, w
    	CALL 		transmitting_data
    	
    	banksel		CCPR2L							; transmit LSB
    	movf		CCPR2L, w
    	banksel		to_transmit
    	movwf		to_transmit
    	sublw		0xFF				; if data = FF change to FE
    	btfsc		STATUS, Z
    	CALL		data_change
    	movf		to_transmit, w
    	CALL 		transmitting_data
    		
    goto main_loop
    
    	
    				
    ;******** END MAIN LOOP ********************		
    
    transmitting_data:	
    	banksel		TXREG
    	movwf   	TXREG					    	; writing to TXREG clears TXIF
        trans_wait2:
    	btfss		PIR1, TXIF						; wait for the frame to be transmitted
    	goto		trans_wait2
    	CALL		DELAY
    	return
    	
    data_change:
    	banksel		to_transmit
    	movlw		0xFE
    	movwf		to_transmit
    	return
    	
    DELAY:
    	movlw		0xFF
    	movwf		del1
    	movlw		0xFF
    	movwf		del2
    	
    	loopa:
    	decfsz		del1, f
    	goto		loopa
    	loopb:
    	decfsz		del2, f
    	goto		loopb
    	return
    		
    end
    
    
    Amitai
     

    Attached Files:

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-