Microchip | The Embedded Control Solutions Company Register Login
Browse All
Microchip Technology
 367 Code Snippets

Sensor Board Metal Detection using PIC16F18446

Microchip Technology

Check out this project's MPLAB Xpress Webpage to view the complete code example along with a detailed step by step write-up and description, or visit the PIC16F18446 Device Product Page for more information.

About this Code Example

Introduction

The PIC16F184xx family has a new Analog to Digital Converter with Computation (ADCC) with a 12-bit resolution. This project shows the reading of a metal detector using the ADCC.

Description

In this example we will be using the PIC16F18446 Sensor Board. Initially, the board scans the metal detector LC circuit in order to find the peak (resonant) frequency. It then supplies a signal with that frequency using the NCO, and reads the ADCC. If a metal object approaches, it shifts the resonant frequency, and the ADCC value changes. The demo has 2 operating modes. In the first mode, the 12-bit and 10-bit values are plotted in real time.

When entering this mode, the first ADCC reading is used as an offset for the plots. The LCD backlight turns OFF after some time of inactivity, and turns back ON when the user presses a button. In the second mode, the buzzer is beeping at a variable time interval, according to the metal detector reading.

MCC Settings

Here are the settings used for MSSP, CLC, NCO, FVR, ADCC, CCP, CWG, and TMR. MSSP + CLC are used for the LCD control.

MSSP Settings

CLC Settings

NCO Settings

The NCO is used to oscillate the LC circuit.

FVR Settings

FVR is used as positive refference for the ADCC, to get higher accuracy and gain.

ADCC Settings

ADRPT register is set to 0x40, to average a burst of 64 samples.

CCP Settings

CCP1 is used for generating the buzzer tone.

CWG Settings

CWG is used to output the signal from CCP1 in antiphase on 2 pins, so that the buzzer sounds louder.

TMR Settings

TMR1 is used to clock the CCP1. It sets the pitch of the buzzer tone.TMR3 is used to set the beep interval.

Categories

Release History

  • Dec 4, 2018

    Version: 1.0.0

    Initial Release

Download Contact the Developer

*Required Fields


  • Current Version:1.0.0
  • Created:Dec 4, 2018
  • Updated:Dec 4, 2018
  • Downloads:338
  • MPLAB Version:MPLABX IDE
  • C Compiler:XC8 (v1.45)
  • Development Tools:Xpress Board
  • Supported Devices:PIC16F18446

Corporate News

Resources

Stay Connected

Stay up to date with the latest news from Microchip Technology.