Introduction: BFO Metal Detector
In this instructable I will go thru all the steps to design and build a BFO metal detector.
BFO (beat frequency oscillator) works by mixing two signals to produce an audible Beat frequency. One oscillator is fixed at a specific frequency, the second (of which the search coil is a part) varies it's frequency slightly in the precense of a metal. The change in pitch alerts the user to the presence of a metal.
For this to work the change in frequency must be large enough to be noticeable. i.e. a change of only a couple of Hz would only be noticeble to someone with perfect pitch.
Practically we want a change of between 200 to 1000 Hz, which means that the search coil is operating at quite a high frequency... around 600kHz in my case. At this frequency a small change in coil inductance (as in the precense of a coin) will result in the desired change in frequncy.
Step 1: Building the Search Coil
After a bit of online searching i settled on a 30 turn coil, 15cm in diameter, using 30 gauge wire - as this seems to be consistant enough over a number of projects. The project I found was operating the coil at 200kHz... but I got better results at 600kHz - I assume the 200kHz minimizes interference with AM radios.
After winding the coil should be shielded using tinfoil. I wrapped around a strip of tinfoil and then stripped some wire and secured the foil using the wire, I then soldered a lead to it and encased it by wrapping around the secondary insulation and secured it to a plastic base using cable ties.
Notice the shield does not form a complete loop around the coil, as this would form a shorted secondary loop, instead a few cm are left open.
Step 2: Design and Build the Oscillator
I decided to build a Colpitts oscillator for this.
These are the requirements for oscillation, as googled:
- To start the oscillations, the total phase shift of the circuit must be 360° and the magnitude of the loop gain must be greater than one.
The gain is provided by the common emitter amplifier, which also has a phase shift of 180°.
We need an additional 180° which is provided by the LC tank circuit in a Colpitts configuration.
Notice the two capacitors are in series (if we look at the total capacitance accross the coil) if the capacitors are equal it equates to HALF the capacitence accross the coil.
I used two equal capacitors of known value and connected my signal generator to ground and point A. I also connected Ch1(yellow) of my oscilloscope to point A and Ch2(blue) to point B. The math function Ch1 - Ch2 is in red. Something interesting happens at the resonant frequency, the amplitude of the math function peaks, this can be seen in the sample images at 75kHz. Compared to 65kHz and 85kHz. This is because at the resonant frequency we have the largest signals which are also and importantly at 180° phase.
This frequency and only this frequency satisfies the 360° phase shift requirment. So this is the frequency our oscillator will oscillate at.
Knowing the value of the capacitors we can calculate our inductor value, then we use this value to calculate the capacitors we need for oscillation at 600kHz.
The transistor used in a 2N2222A, and the resistor values where caulculated as follows.
The output should sit at mid-rail , 2V5, Vce is 2V and Ve is the remainder, 500mV. I selected 1mA for Ic as this would set re to Vt/Ic = 26mV/1mA = 26 ohm. At the base of the transistor the input impedance would be beta (100) * re = 2k6. Which closely matches the output impedance, this is not a requirement but i like the simmetry. Also with Ic at 1mA and Vce at 2V we are well into the active region of the transistor as may be verified on the IV curve for the 2N2222A. With Ve at 500mV and Ic = 1mA then Re = 500mV/1mA = 500 ohm.
Vb = 500mV + the diode drop of the transistor 650mV = 1V15.
The input impedance is therefore beta (100) * Re (500 ohm) = 50K. The voltage divider (R1, R2) should therefore have 10 times the current thru it and it's impedance should therefore be 5K.
The equations are:
R1||R2 = 5k and (5/(R1 + R2)) * R2 = 1.15
solving the equations we get R1 = 21k and R2 = 6k5.
Rg should be 10 times larger than Re, therefore Rg = 5k. This allows for Rg to be negligible, (10 times larger) to 0 ohm, in which case it dominates the gain. 2k5 / 500 = 5. Thefore the gain of the amplifier can be set from 5 (which is often enough gain for oscillation anyway) all the way to 2k5 / 26 ohm (re) = 96.
All the capacitors should have negligible impedance at 600kHz.
Zc = 1 / (2*PI*f*C).
so for an impedance of 1 ohm at 600kHz C = 265 nF. I used capacitors larger than that.
Finally build the circuit, connect point A to the input, point B to the output - and adjust the gain until you have a nice clean sine wave. As seen in the final image. The desired frequency is not exactly as designed, this is mostly due to measurement errors and using capacitors close to (but not exactly) the calculated value.
Step 3: Mixing Signals
To test the metal detector i used my signal generator to generate a signal close to the search coil frequency - the difference should be in the audible range. The generate signal also needs to be of similar amplitude to the signal from our oscillator. My signal generator is outputing a sinusoidal wave, but I have tested with a square wave and the results are satisfactoraly, meaning you could use a simple 555 timer to generate the reference signal, in which case you may need a 1k pot to decrease the amplitude to a level suitable for mixing. In my case this was 400mV.
A couple of 10k resistors where selected for this, the output of the signal generator (at 400mV came thru a 10k resistor, the output my the oscillator also came in thru a 10k resistor.
As the frequencies are very close to each other there will be times when the positive and negative peaks mostly align, in this case we have both sides of the resistor divider at the same potential at all times and we get the maximum signal output at the midpoint. However at other times the peaks will be at opposite peaks, and the output at the midpoint is just midrail, with the minimum signal amplitude.. this happens at the difference, or beat frequency.
In the images above the beat pattern can be seen when a coin is present and not present at the search coil.
The next step is to demodulate the signal.
Step 4: Demodulation
We can't just feed the signal into a speaker and expect to hear the beat frequency. If the signals in the previous section where averaged out the average is always 0 (mid-rail or 2V5 is our '0' in practice), because for every increase in amplitude there's a correspondingdrop in amplitude - look at the top and bottom of the envelope.
Instead we need to either clip off the top or bottom half of the signal and average what's left.
For this we build a second common emiter amplifier, but whereas previously we designed the output to sit at mid-rail - allowing for maximum voltage swing up and down - we now deliverately design the output to sit close to rail voltage, thereby clipping the amplified signal. Another way to think of it is we set the potentiometer so that the transistor just begins to conduct - positive going pulses will drive the transistor even more, but negative going pulses will go below the transistor turn-on voltage and so will be neglected.
Again i used 2k5 for Rc, the pot is 1k and R1 is 50k. The second transistor is configured as a voltage follower, with a large Re (i used 20k) so that there's sufficient current flow to set the transistor into the active region - without it the impedance of the piezo is so high that the transistor was not operational.
The built in capacitance of the piezo resulted in a surprisingly clean sunisoidal output at the beat frequency. Here the 2kHz beat frequency can be seen on the last image. Again i used a coupling capacitor larger than 270 nF.
Step 5: Practical Demonstration
As can be seen on the video, the change in pitch is quite noticeable.
Step 6: Arduino
Listening to the tone continuously can be quite hard on your ears. For those who are comfortable using micros it could be a good idea to process the output signal and only output a beep or light an LED when a significant change in frequency is detected.
For example setting the beat frequency to 1kHz the period of the signal is 1ms
a 200 hz change either way
800hz: period = 1.25 ms
1k2 = 0.833 ms .
that's 250us in one direction and 166us in the other. if the output signal from the demodulator where put thru a comparator to generate a square wave, and then a micro where used to measure the time between positive edges, then any micro capable of 1us timing resolution would be capable of calculating the change in tone.
For this i would recommend the pulseIn() function.
this function returns a pulse duration in us, you can select to either time the HIGH or LOW period and there's even an option for a timeout, which i recommend.
as per their example
int pin = 7;
unsigned long duration;
then in the loop:
duration = pulseIn(pin, HIGH, 5000);// 5ms timeout
// then some simple if statements, for example
if(duration < 833) led_on();
if(duration > 1250) led_on();
if(duration == 0) error_led_on();// we timed out
Step 7: Final Circuit
The local oscillator is a second Collpits oscillator using the same component values as the first. The inductor is made to be adjustable so that the correct frequency can be dialed in. A little piece of rubber band is glued to the inductor (a bead of ferrite) to stop it moving freely on its own.
Step 8: Assembly
Now that everything has been tested and is functioning I decided to add a longer lead to the search coil so that it may be mounted on a handle away from the rest of the electronics.
A shielded cable must be used for this.I decided on a shielded USB cable, as it has 4 conductors and a shield. We only need two conductors and a shield so I paired up two conductors.
Unfortunately the added length of cable and presumably the added parasitic capacitance means my search oscillator is now running at 300kHz. This is not a problem as other projects I have researched use a value between 200kHz and 300kHz anyway.
For this reason i had to modify the local oscillator by adding capacitance to the LC circuit for it to also operate at 300kHz.
Having done this I recombined all my individual prototype boards and assembled them all together on the larger PCB.
Next I will find a light plastic pole for a handle and a plastic container for the electronics.
Participated in the