UVTron to PIC Example
Last Modified: 2006-11-16
find:

basket

Acroname Robotics PDF webpage version UVTron to PIC Example PDF

Related
Products

Product image for UVTron Flame Detector Package
UVTron Flame Detector Package

Contents

Hardware used for UVTron to PIC controller.

Introduction

In this example, the Hamamatsu UVTron detector provides a one-bit flame detection input for a commonly used 16C84 Microchip micro-controller.  The controller continually polls the detector and sounds an alarm buzzer when there is a flame detection. 

Circuit Schematic

This circuit is only applicable for an unmodified UVTron Driver Board that still has its own 5V regulator in place.  It is possible to remove the regulator and use an external 5V regulated supply.  (This modification is described in the booklet that comes with the UVTron Package.)

Wiring diagram between the UVTron and the PIC controller.

Part's List

The following items were used in this example:

element type not assigned

Source Code

This code is written in Microchip's MPASM format.  The settings you will need in MPASM are to use a decimal RADIX, watchdog timer off, and a crystal oscillator.  This code is not meant to be elegant.  It is meant only to demonstrate a simple example. 

;--------------------------------------------------------- ; uvtron.asm ; ; Configuration Bits: ; ; This code assumes HS resonator, watchdog timer on, ; and power up timer on. LIST P=16F84 #include "p16F84.inc" ;--------------------------------------------------------- ; variable defs RAMBASE EQU 0x20 ; state (whether buzzer is on or not) STATE EQU RAMBASE+0 ; count of photons per measurement interval PCOUNT EQU RAMBASE+1 ; counter to keep track of measurement interval ACCUM EQU RAMBASE+2 ; bit in STATE variable that is set for buz stateBUZ EQU 0 ; number of buzzer ticks in which to accumulate photons accumTICKS EQU 200 ; number of photons per accumulation interval for buz photonTHOLD EQU 2 ; square wave size for buz, each tick is .000256 sec buzFREQ EQU 3 ; buzzer is on pin 4 buzPIN EQU 4 buzMASK EQU b'00010000' ; UVTron output is on pin 7 photonPIN EQU 7 photonMASK EQU b'10000000' ;--------------------------------------------------------- ; reset vector ORG 0 GOTO reset ;--------------------------------------------------------- ; interrupt vector ORG 0x04 GOTO handle_interrupt ;--------------------------------------------------------- ; standard entry ORG 0x05 reset movlw accumTICKS ; no measurements yet movwf ACCUM clrf STATE bsf STATE, stateBUZ ; buzzer starts on bsf STATUS, RP0 ; bank 1 movlw photonMASK ; photon is input movwf TRISB movlw b'00000111' ; prescaler 256:1 movwf OPTION_REG bcf STATUS, RP0 ; bank 0 bsf INTCON, T0IE ; enable timer bsf INTCON, RBIE ; enable port B change bsf INTCON, GIE ; enable global ints ;--------------------------------------------------------- main_loop goto main_loop ; just spins here ;--------------------------------------------------------- handle_interrupt btfsc INTCON, T0IF ; check for timer 0 int goto int_tmr0 btfsc INTCON, RBIF ; check for PORT B int goto int_portb int_done retfie ;--------------------------------------------------------- int_tmr0 bcf INTCON, T0IF ; clear timer int flag clrwdt ; clear each time through btfss STATE, stateBUZ ; buz when bit set goto int_tmr0_buz_done movlw buzMASK ; toggle buzzer state xorwf PORTB, f ; for square wave int_tmr0_buz_done movlw 255 - buzFREQ ; reset timer count movwf TMR0 decfsz ACCUM, f ; check accumulation goto int_done ; interval bcf STATE, stateBUZ ; assume buz off movlw photonTHOLD subwf PCOUNT, w ; w = w - PCOUNT btfss STATUS, C ; skip if negative goto int_tmr0_reset bsf STATE, stateBUZ ; turn buz on int_tmr0_reset clrf PCOUNT ; reset photon count movlw accumTICKS ; reset measurment movwf ACCUM goto int_done ;--------------------------------------------------------- int_portb btfsc PORTB, photonPIN ; detect rising edge only incf PCOUNT, f ; count the photon goto int_done ;--------------------------------------------------------- end

Comments

This circuit demonstrates the incredible sensitivity of the UVTron detector.  Stand several feet away from the detector and light a match.  The alarm will sound almost immediately. 

Revision History:

  • 2000-10-16: Example Created.
 
 
voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy
© Copyright 1994-2010 Acroname, Inc., Boulder, Colorado. All rights reserved.