Metal Detecting with PIC18-Q71 Microcontroller

Summary of Metal Detecting with PIC18-Q71 Microcontroller


This article describes a metal detector using PIC18‑Q71 microcontroller CIPs that senses changes in damping of an LC resonant tank caused by eddy currents in nearby metal. A PWM excites the LC tank; an OPAMP peak detector charges an RC timing network; the microcontroller’s comparator and DAC measure RC discharge time to distinguish metallic from non‑metallic objects. R1 protects I/O diodes and startup calibration sets the detection threshold.

Parts used in the Metal Detecting with PIC18-Q71:

  • PIC18-Q71 microcontroller (with built-in CIPs: OPAMP, Comparator, DAC, PWM)
  • Inductor (tank coil)
  • Capacitor (for LC resonant tank)
  • Diode (between PWM and tank)
  • Current-limiting resistor (R1)
  • Resistor and capacitor for RC resonant/timing network
  • Optional protective ESD diodes (internal to MCU)
  • Power supply for microcontroller and tank drive

Distinguish between metal and non-metallic objects using Core Independent Peripherals (CIPs) with the Metal Detecting with PIC18-Q71 Microcontroller.

Metal Detecting with PIC18-Q71 Microcontroller

Story about Metal Detecting with PIC18-Q71

Quick Solutions to Questions related to Metal Detecting with PIC18-Q71:

  • How does the detector distinguish metal from non-metallic objects?
    By measuring the faster damping of the LC resonant tank caused by eddy currents in nearby metal, which shortens the LC ringing and changes the RC discharge timing.
  • What excites the LC resonant tank?
    A PWM waveform from the microcontroller, with duty cycle set to half the resonant period, excites the LC tank.
  • Why is a diode used between the PWM and the tank?
    The diode protects the microcontroller I/O and prevents dissipation of energy applied to the tank.
  • What is the role of R1 in the circuit?
    R1 is a current-limiting resistor that reduces current through ESD diodes to a safe level, protecting the microcontroller.
  • How does the OPAMP contribute to detection?
    The internal OPAMP is configured as a unity gain peak detector that recharges the RC timing network when LC peaks exceed the RC voltage, stretching timing for measurement.
  • How is the RC network used to sense changes?
    The RC network is charged by the OPAMP and discharged through a resistor; the microcontroller measures its discharge time to a DAC-set reference using the analog comparator.
  • What internal peripherals of the PIC18-Q71 are used?
    The application uses the OPAMP, Analog Comparator (CMP), Digital-to-Analog Converter (DAC), and PWM Core Independent Peripherals.
  • Is calibration required?
    Yes, discharge time is calibrated on startup to set the detection threshold.

About The Author

Muhammad Bilal

I am a highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.