Sensor Interface Using PIC12CXXX as a Sensor Interface for Metal Detection

Similar documents
Connecting Sensor Buttons to PIC12CXXX MCUs

Triple Stage Incubator

Discrete Logic Replacement Garage Door Indicator

FM Tuner Controller for Portable and Car Radios

IST TSic Temperature Sensor IC Application Notes ZACwire Digital Output

Electromechanical Timer Replacement Solutions Cubed Real-Time Clock

Electromechanical Switch Replacement

Microcontroller Based Inductance Capacitance Meter

ELCT 912: Advanced Embedded Systems

2015 Technological Studies. Advanced Higher. Finalised Marking Instructions

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

Section 22. Basic 8-bit A/D Converter

PIC12F529T39A. 14-Pin, 8-Bit Flash Microcontroller. High-Performance RISC CPU. Low-Power Features/CMOS Technology. Special Microcontroller Features

GCE A level 1145/01 ELECTRONICS ET5. P.M. THURSDAY, 31 May hours. Centre Number. Candidate Number. Surname. Other Names

Final Project Report E3390 Electronic Circuits Design Lab. RFID Access Control System. Jeffrey Mok Joseph Kim

MicroToys Guide: Motors N. Pinckney April 2005

The Electronic Whoopie Cushion

GROAN DETECTOR SYSTEM

EASTERN MEDITERRANEAN UNIVERSITY FACULTY OF ENGINEERING Electrical and Electronics Engineering Department

GCE A level 1145/01 ELECTRONICS ET5

Embedded Systems. Interfacing PIC with external devices Analog to digital Converter. Eng. Anis Nazer Second Semester

Physics 335 Lab 7 - Microcontroller PWM Waveform Generation

AN654. PWM, a Software Solution for the PIC16CXXX METHODS INTRODUCTION

PIC12F529T39A Data Sheet

Application Note Temperature Sensor IC

GCE A level 1145/01 ELECTRONICS ET5

TECHNICAL NOTE. A COMPACT ALGORITHM USING THE ADXL202 DUTY CYCLE OUTPUT by Harvey Weinberg

;;;;;;; Variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; cblock Bank0RAM ;Temporary storage for STATUS during interrupts

PIC Analog Voltage to PWM Duty Cycle

Laboratory Exercise 1 Microcontroller Board with Driver Board

AN1730. Digital Amplification Control of an Analog Signal Using the MC68HC705J1A. Introduction

MCU Reset and Oscillator Circuits Application Note

PIC16C5X. EPROM/ROM-Based 8-Bit CMOS Microcontroller Series. Peripheral Features: Devices Included in this Data Sheet: CMOS Technology:

Hashemite University Faculty of Engineering Mechatronics Engineering Department. Microprocessors and Microcontrollers Laboratory

MOS (PTY) LTD. E Single Channel PIR Signal Processor. Applications. General Description. Features. Digital Sensor Assembly with E931.

A NEW DECISION ALGORITHM FOR AUDIO VOTING SYSTEM

PROCESS. Object. Block diagram of our design. DISPLAY THE DISTANCE (7 segment display) PIC 16F873

K7QO Marker Generator

AN606. Low Power Design Using PICmicro Microcontrollers INTRODUCTION DESIGN TECHNIQUES RESISTOR TO LOWER POWER IN RC MODE CONTROL CIRCUIT

AN528. Implementing Wake-Up on Key Stroke. Implementing Wake-Up on Key Stroke INTRODUCTION IMPLEMENTATION FIGURE 1 - TWO KEY INTERFACE TO PIC16C5X

AN720. Measuring Temperature Using the Watch Dog Timer (WDT) THEORY INTRODUCTION HARDWARE REQUIRED. Equation 1: Microchip Technology Inc.


PIC16C5X Data Sheet. EPROM/ROM-Based 8-bit CMOS Microcontroller Series Microchip Technology Inc. Preliminary DS30453D

Controlling DC Brush Motor using MD10B or MD30B. Version 1.2. Aug Cytron Technologies Sdn. Bhd.

PIC Functionality. General I/O Dedicated Interrupt Change State Interrupt Input Capture Output Compare PWM ADC RS232

On-chip RC oscillator based Watchdog Timer(WDT) can be operated freely 12 I/O pins with their own independent direction control 3. Applications The ap

Mechatronics Project Kit - Getting Started Manual

PRODUCT OVERVIEW OVERVIEW OTP

Measuring Distance Using Sound

PIC ADC to PWM and Mosfet Low-Side Driver

Binary Outputs: LEDs

Department of Mechanical and Industrial Engineering MECH 471 MICROCONTROLLERS FOR MECHATRONICS. Laboratory Specialist

2. Circuit diagram The overall functional diagram is:

MK7A20P 8 bit microcontroller

AN1202. Capacitive Sensing with PIC10F IMPLEMENTATION INTRODUCTION + - BASIC OSCILLATOR SCHEMATIC. Microchip Technology Inc.

Dual Channel PIR Signal Processor E Production Data - Dec 16, 2016

Introduction to Using the PIC16F877 Justin Rice IMDL Spring 2002

Lesson 19 In-Circuit Programming

Pulse Width Modulated Linear LED Bar Graph Display

Development of a Matlab-Based Graphical User Interface Environment for PIC Microcontroller Projects

Generating DTMF Tones Using Z8 Encore! MCU

K1EL Granite State Crystal Matcher GS XTAL

Pulse Width Modulation

JX pin PIC Microcontroller Project Board

WSPR VCXO Controller

Development of a Low Cost MPPT Circuit for Solar Panel

Microcontroller Based Electric Expansion Valve Controller for Air Conditioning System

SN8P Bit Micro Controller

Stepper Motors & Look Up Table

NJ88C Frequency Synthesiser with non-resettable counters

Project Final Report: Directional Remote Control

Figure 1. C805193x/92x Capacitive Touch Sense Development Platform

AN611. Resistance and Capacitance Meter Using a PIC16C622 INTRODUCTION. Microchip Technology Inc.

Design and Implementation of Shift Frequency Measurement System for Metal Detector

The rangefinder can be configured using an I2C machine interface. Settings control the

GCE A LEVEL. WJEC Eduqas GCE A LEVEL in ELECTRONICS ACCREDITED BY OFQUAL DESIGNATED BY QUALIFICATIONS WALES SAMPLE ASSESSMENT MATERIALS

SG8F160P. 8-BIT MCU With Embedded Touch Sensor Version 1.1. Sigma reserves the right to change this documentation without prior notice

Embedded Systems and Software

Section 2. Oscillator

Temperature Monitoring and Fan Control with Platform Manager 2

Z86116 CMOS Z8 PN MODULATOR WIRELESS CONTROLLER CUSTOMER PROCUREMENT SPECIFICATION FEATURES GENERAL DESCRIPTION Z86116 CP95WRL0501 PRELIMINARY

HT1620 HT1621 HT1622 HT16220 HT1623 HT1625 HT1626 HT1627 HT16270 COM

Hardware Flags. and the RTI system. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

HT162X HT1620 HT1621 HT1622 HT16220 HT1623 HT1625 HT1626 COM

Temperature Monitoring and Fan Control with Platform Manager 2

MS8891A. Application Note. 1 General product description. 2 Introduction to capacitive sensing

EE 314 Spring 2003 Microprocessor Systems

ECE Senior Design Final Report For. Scalable Regulated Three Phase Power Rectifier. May 10, 2004 Rev. 1.0

PAK-VIIIa Pulse Coprocessor Data Sheet by AWC

A Ballistic Chronograph

PATENTED. PAT No. : HT1622/HT1622G RAM Mapping 32 8 LCD Controller for I/O MCU. Features. General Description.

HT1621. HT1621 RAM Mapping 32x4 LCD Controller for I/O MCU

Moving Message Dot Matrix Display

X-10 Compatible Appliance Module

High-Performance 8-Bit CMOS EPROM Microcontrollers RD1/AD9 RD0/AD8 RE0/ALE RE1/OE RE2/WR RE3/CAP4 MCLR/VPP TEST

QRPGuys SMT Digital Dial/Frequency Counter

S3C9442/C9444/F9444/C9452/C9454/F9454

CHAPTER 3 PIC Microcontroller CCP and ECCP Tips n Tricks

PIC16F84A Firmware Configuration Details: 400MHZ LCD Frequency Counter

νµθωερτψυιοπασδφγηϕκλζξχϖβνµθωερτ ψυιοπασδφγηϕκλζξχϖβνµθωερτψυιοπα σδφγηϕκλζξχϖβνµθωερτψυιοπασδφγηϕκ χϖβνµθωερτψυιοπασδφγηϕκλζξχϖβνµθ

Transcription:

Using PIC12CXXX as a Sensor Interface for Metal Detection Author: Vladimir Velchev AVEX - Vladimir Velchev Sofia, Bulgaria email:avex@iname.com APPLICATION OPERATION PIC12CXXX microcontroller can be used in quite an unexpected area of application - as an intelligent metal detector. Few components are needed to build a hand held (stand alone) or a static, remotely controlled metal sensor connected to a computer or another microcontroller. As known, the metal objects can change the resonant frequency of an LC circuit. If this circuit is connected to oscillator inputs of PIC, then the operating speed of the microcontroller will be influenced by the metal objects located near inductor L1 (figure2). The microcontroller must measure its own frequency at start up, save it as reference frequency, and compare it with all other currently measured frequencies. To perform such a type of measurement, a RC circuit (R2,R3,C4) is connected to a GP2 pin and determines a constant time interval for calculations. GP2 has two functions: to discharge the capacitor C4 (as output) and to control its voltage (as input). See Figure 1. The button S1 (RESET) is needed for periodical (from time to time) calibration of the reference frequency, since the LC oscillator frequency and the RC circuit time interval are a function of the supply voltage, the operating temperature and the stability of the components. The size of metal objects to be detected determine the size and geometry of inductor L1. If we need stand alone small size metal detector, then outputs GP0 and GP1 can be connected to control LED and head phones (for sound effects). If we need to get data from the PIC and to transmit some special commands to microcontroller, GP0 & GP1 can be I2C s - DATA and CLOCK pins. FIGURE 1: Vth Vth-1 Vth-0 GP2-out GP2-in T=100ms Microchip Technology Incorporated, has been granted a nonexclusive, worldwide license to reproduce, publish and distribute all submitted materials, in either original or edited form. The author has affirmed that this work is an original, unpublished work and that he/she owns all rights to such work. All property rights, such as patents, copyrights and trademarks remain with author. 1997 Microchip Technology Inc. DS40160A/3_007-page 1

GRAPHICAL HARDWARE REPRESENTATION: C2 15pf C1 15pf L1 INDUCTOR R1 10K S1 RESET R2 100K C3 15pf R3 200 C4 470nf U1 1 2 3 GP5/OSC1/CLKIN GP4/OSC2 4 5 GP3/MCLR/Vpp GP2/T0CKI 6 7 GP1 8 GP0 Vss PIC12C508 D1 LED R4 1K DATA or LED CLOCK or PHONES BILL OF MATERIALS (BOM) Part# Manufacture U1-PIC12C508 Microchip C1-15pf C2-15pf C3-15pf C4-470nf R1-10K R2-100K R3-200 R4-1K S1-button D1-LED L1 unknown DS40160A/3_007-page 2 1997 Microchip Technology Inc.

FLOW CHART There are m intelligent algorithms that can be implemented in PIC12CXXX for metal detection and automatic calibration. The algorithm shown below is just for experiments. START CALC_FREQ Initial setup Wait for power & oscillator stabilization CALL CALC_FREQ Measuring & calculating current oscillator frequency Reference freq. = current freq. CALL CALC_FREQ Measuring & calculating current oscillator frequency Reset capacitor of RC group (used for time interval) Reset timer TMR0 Current freq.= 0 Current freq. = current freq. + TMR0 clocks RC time interval over? Y RETURN N Freq. Offset = Ref.freq. - curr.freq. Freq. Offset > max. limit? Y LED = ON N LED = OFF Y RESET button pressed? N MICROCHIP TOOLS USED Assembler/Compiler version MPLAB 3.22, MPASM 1.5 1997 Microchip Technology Inc. DS40160A/3_007-page 3

APPENDIX A: SOURCE CODE ;************************************************************************ ; Using PIC12CXXX as a sensor interface for metal detection ; Written by Vladimir Velchev 07.1997. ; (C) AVEX - Vladimir Velchev ; Version 1.00 ;************************************************************************ ; LC osc.: F=2MHz; GP5/GP4 must be configured as XT type OSC1,2 in/outs ; GP0 - LED indicator (output: 0=LED ON, 1=LED OFF) ; GP1 - not used (reserved output for phones or DATA pin [GP0- CLOCK]) ; GP2 - RC group - 100mS measurement time (input/output) ; GP3 - RESET button for calibration (input) ; GP4 - LC oscillator (OSC1 input) ; GP5 - LC oscillator (OSC2 output) LIST P=12C508 #include <p12c508.inc> ;*** Equates LED_Pin equ 0 ;LED indicator - GP0 RC_Pin equ 2 ;RC group RESET_Pin equ 3 ;RESET button pin FREQ_OFFS equ D'10' ;freq. offset limit (threshold) Fmax-Fmin ;determines the device sensibility START_UP_COUNT equ D'10' ;number of start up false measurements IOSET equ B'00001000' ;initial I/O port settings ;GP3-input, others- outputs RC_MASK equ B'00000100' ;bit mask for RC pin ;*** RAM locations Frh equ H'07' ;reference frequency - MS byte Frl equ H'08' ;reference frequency - LS byte Fch equ H'09' ;current frequency - MS byte Fcl equ H'0A' ;current frequency - LS byte ;*** Vectors org 0 ;RESET vector ;*** Code Starting Point BEGIN: ; Initial setup movlw IOSET ;init GPIO tris GPIO clrf GPIO ;reset all outputs (=0) movlw H'D2' ;init option register option ;TMR0: int.clock, prescaler 1:8 ; Additional delay after start up movlw START_UP_COUNT ;read number of start up cycles movwf Frl ;use Frl as counter for start up START_UP_LOOP: call CALC_FREQ ;call freq. subroutine decfsz Frl,1 ;counter Frl--, skip if=0 (exit) goto START_UP_LOOP ; Measurement of the reference frequency call CALC_FREQ ;call calculate freq. subroutine movf Fch,W ;copy measured to reference freq. movwf Frh movf Fcl,W movwf Frl MAIN_LOOP: DS40160A/3_007-page 4 1997 Microchip Technology Inc.

call CALC_FREQ ;calculate current freq. ; Calculate absolute value of the frequency offset ; Fc= Fc - Fb movf Frl,W ;read reference freq. LSbyte subwf Fcl,1 ;sub. from current freq. btfss STATUS,C ;skip if result is 0 or positive decf Fch,1 movf Frh,W ;read reference freq. MSbyte subwf Fch,1 ;sub. from current freq. btfss Fch,7 ;skip if result is negative goto CHECK_FREQ comf Fcl,1 ;convert negative to positive offset comf Fch,1 ;Fch:Fcl- absolute value of offset CHECK_FREQ: movf Fch,1 ;checks freq. offset MSbyte btfss STATUS,Z ;skip if zero goto LED_ON ;else - turn LED ON movlw FREQ_OFFS ;read freq. offset limit subwf Fcl,W ;compare with result offset btfsc STATUS,C ;skip if result < limit offset goto LED_ON ;else - turn LED ON LED_OFF: bsf GPIO,LED_Pin ;LED= OFF goto CHECK_RESET ;go to check the reset button LED_ON: bcf GPIO,LED_Pin ;LED= ON ; Checking the RESET button (calibration) CHECK_RESET: btfsc GPIO,RESET_Pin ;skip if reset button is pressed goto MAIN_LOOP ;go to measurement loop goto BEGIN ;go to begin for calibration ;*** Subroutine - CALC_FREQ ; Input : ; Output: Fch:Fcl- current freq. ; Info : Calculates current frequency of the external oscillator ; Fosc.= 2MHz; Fclk.= 2MHz/4= 500kHz ; TMR0 prescaler: TMR0ps= 1:8 ; TMR0freq= Fclk./TMR0ps= 500kHz/8= 62500Hz ; TMR0tick= 1/TMR0freq= 16 us ; Measurement interval: (RC circuit) TRC = 100mS ; Frequency counter [max]: Fc= TRC/TMR0tick= 100mS/16uS= 6250 ; Frequency counter rate: Frate= Fosc./6250= 320Hz ; Fmax-Fmin interval= FREQ_OFFS*Frate= 10*320Hz = 3200Hz ; Fch:Fcl = Fosc./320 CALC_FREQ: clrf Fch ;clear current freq. counters clrf Fcl ; Discharging the RC circuit movlw IOSET&(~RC_MASK) tris GPIO ;set RC pin as output bcf GPIO,RC_Pin ;RC pin= 0 clrf TMR0 ;use TMR0 as discharge timer CALC_FREQ_DISCH: clrwdt ;clear watchdog timer movlw H'FF' ;look for TMR0 overflow subwf TMR0,W btfss STATUS,Z ;skip if TMR0 overflowed goto CALC_FREQ_DISCH 1997 Microchip Technology Inc. DS40160A/3_007-page 5

; Enable RC time interval circuit movlw IOSET RC_MASK tris GPIO ;set RC pin as input ; Start counting (measurement of the current frequency) clrf TMR0 CALC_FREQ_LOOP: clrwdt ;clear watchdog timer btfsc GPIO,RC_Pin ;continue if RC pin still=0 goto CALC_FREQ_STOP ;else- stop the measurement movlw H'FF' ;look for TMR0 overflow subwf TMR0,W btfsc STATUS,Z ;skip if TMR0 not overflowed incf Fch,1 ;increment MSbyte freq. counter goto CALC_FREQ_LOOP CALC_FREQ_STOP: movf TMR0,W ;read current value of TMR0 movwf Fcl ;store to LSbyte of freq. counter return end ;end of program DS40160A/3_007-page 6 1997 Microchip Technology Inc.