1 Working Principle

The metal detector operates based on the principle of electromagnetic induction. The LC sensor detects the metals using one inductor coil and one capacitor grouped in a parallel circuit. The LC circuit works like an electrical resonator and oscillates at the circuit's resonant frequency using stored energy (Signal A). When a metal object draws close to the proximity of a varying magnetic field generated by the inductor coil, currents are induced in the metal object. The Eddy currents induce their magnetic field. The oscillating signal will attenuate faster due to the energy absorbed by the currents within the metal. The signal period will be reduced, and the signal amplitude will attenuate (Signal B).

Figure 1-1. Signal in Proximity of Non-Metal Object

Figure 1-2. Signal in Proximity of Metal Object

The overlap between Signal A and B presents insignificant variations at the beginning and end phases. The signal difference is perpetually increasing when tracing its envelopes; it reaches the peak value around its midst phase and returns to zero at the end phase. Use the maximum difference between the two envelopes when configuring the metal detector.

When the envelope reaches its peak, the measuring period starts. When the maximum distance between Signal A (green) and Signal B (red) is met, the measuring period stops, as shown below. This value is compared with the non-metal value and can provide information about the distance to a specific metal (the amplitude varies for different types of metals used, given the environmental conditions do not change).

Figure 1-3. Time Measurement at Maximum Difference Between Two Envelopes

The solution for metal detector using the PIC18-Q71 device family uses the LC sensor, the integrated OPA, and the RC circuit to create the envelope of the resulting signal. The Capture/Compare/PWM (CCP1) peripheral is used to generate the PWM signal, with the period set using the Timer2 (TMR2) peripheral to charge the capacitor and generate the oscillation with the LC circuit. This signal is the input for the integrated OPA with unity gain configuration. The output signal of the OPA is the input for the LC circuit that defines the envelope signal. Using the comparator (CMP) peripheral, the value of the envelope is compared with a fixed voltage set by the Digital-to-Analog Converter (DAC) peripheral. Once the TMR1 module counts between the peak of the envelope and the set voltage level, one GPIO toggles once the given condition is met. The usage of the GPIO driving an LED is purely for visual feedback.

Figure 1-4. Hardware Representation of LC Circuit

The frequency or the period of the generated oscillations varies when a metal object interferes with the magnetic field of a metal detector. The frequency or oscillations period can be used as additional information to calculate a precise measurement of the distance to the metal object.