## Wednesday, January 16, 2013

### Metal detector using Colpitt oscillators

This is a project I found through http://www.geotech1.com/. It's an old EDN article describing a very simple metal detector I thought I'd use treasure hunting with one of my daughters.

### Oscillator circuits

The basic principle is to use two oscillators. At least one of them should use an inductor as a part of the oscillator tank. The easiest design is a Colpitt's oscillator, since it only use one simple inductance together with a couple of capacitors. An LC circuit would oscillate spontaneously if it weren't for the resistance in the coil, capacitors, wires etc. To compensate for the resistance we use a transistor to give a small charge push in every oscillation. Here's an LTSpice simulation of such a circuit:

 Colpitt oscillator

The output of the oscillator is taken from the emitter, and if you look at the simulated currents in the transistor, you will see some strange oscillations. These come from the base going above the collector for a short period of time. They will probably not be present in the real circuit due to internal resistance in the various elements of the circuit (this will of course be checked in reality..)

The oscillator frequencies depends on the inductance of the coil. By winding a big air coil, the frequency of the oscillator will change when the surrounding permeability changes according to this formula:
$L = \mu k$
where L is inductance, $\mu$ is permeability and k is a constant depending on the physical shape of the coil.

### Frequency mixing

Frequency is typically around 400kHz, so we need to convert it down to audio levels if we want to use a loudspeaker as indicator. This is done using a local oscillator with a fixed frequency. The two oscillator outputs are connected via capacitors, like in the schematic below. We also need to pull the out signal somewhere, not to leave output floating. The pull up/pull down resistors are chosen to have a total resistance of 75k$\Omega$ (you will see why when we design the audio amplifier). We can see the capacitors as output from one stage and the resistors as inputs to the next stage. One wants a low output impedance connected to a high input impedance to avoid loading the oscillator. The impedance of the capacitors are less than 7.5k$\Omega$ according to the formula $|Z| = \frac{1}{2 \pi f C} \approx 4000 \Omega$ at our lowest required frequency 20Hz. The capacitors and resistors make a high pass RC-filter, so we also need to check that the filter doesn't filter out sound above 20Hz. The cut-off frequency is: $f_c = \frac{1}{2 \pi R C} \approx 1$Hz.
 Simplified mixer circuit

So, what will the output of this setup be? Let the capacitors be complex impedance's:
$z_1 = \frac{-j}{2 \pi f_1 C_1}$
$z_2 = \frac{-j}{2 \pi f_2 C_2}$
The current through the resistor is the sum of the current from the capacitors.
$I_{C1}+I_{C2}=I_R$
The voltage drop over R is
$V_{out} = R \cdot I_R = R (I_{C1}+I_{C2})$
The current from the capacitors will be:
$I_{C1} = \frac{V_1}{z_1} = \frac{-j\cdot V_1}{2 \pi f_1 C_1}$
$I_{C2} = \frac{-j\cdot V_2}{2 \pi f_2 C_2}$
so
$V_{out} = R \left (\frac{-j\cdot V_1}{2 \pi f_1 C_1}+\frac{-j\cdot V_2}{2 \pi f_2 C_2}\right)$
Since we are dealing with real voltages, the output voltage will be
$|V_{out}| = R \left (\frac{\sin(2 \pi f_1 t)}{2 \pi f_1 C_1}+\frac{\sin (2 \pi f_2 t)}{2 \pi f_2 C_2}\right )$
When adding two sine waves, we can use this identity:
$\sin(\alpha)+\sin(\beta) = 2 \sin\left (\frac{\alpha + \beta}{2}\right ) \cos\left (\frac{\alpha - \beta}{2}\right )$
Without actually calculating the amplitude of the resulting wave ( which we are less interested in) we can see that the resulting wave will have both the added and the subtracted  frequencies of the two original waves. It will look for example like this,
20 beats per second from a 400.00kHz and a 400.02KHz sine wave.
By using a local oscillator with a frequency very close to the variable oscillator, we can generate a frequency component in the audible range that is proportional to the permeability close to the search coil.
The first step is to build the oscillators  and trim them so they are close enough to each other. The second step will be building an audio amplifier to amplify the mixed signal. In the EDN article, they use a dedicated audio amplifier chip. I will build the amplifier from transistors, since that is one of the purposes of this project, to learn about transistor (BJT) electronics.