UVTron to Handyboard Example
Last Modified: 2006-11-01
find:

basket

Acroname Robotics PDF webpage version UVTron to Handyboard Example PDF

Related
Products

Product image for Handy Board Kit 1.21 MacOS
Handy Board Kit 1.21 MacOS
Product image for Handy Board Kit 1.21 Windows
Handy Board Kit 1.21 Windows
Product image for UVTron Flame Detector Package
UVTron Flame Detector Package

Contents

Example setup for interfacing the UVTron to the Handyboard.

Introduction

In this example, the Hamamatsu UVTron detector provides a one-bit flame detection input for a Handy Board.  An interrupt routine counts the number of times the input is high during a sampling interval and places the result in a global variable.  A small program written in Interactive C monitors the global variable.  It beeps and prints the message FIRE! to the LCD screen of the Handy Board when the global variable is non-zero. 

Note

This example assumes the user has some knowledge of the Handy Board.  See the Handy Board Web Site for more information. 

Circuit Schematic

This circuit uses a UVTron Driver Board that has had its 5V regulator bypassed.  This technique is described in the booklet that comes with the UVTron Package.  The Handy Board supplies regulated 5V power to the UVTron Driver Board. 

Wiring diagram for the UVTron to the Handyboard.

Source Code - Interactive C

The code consists of three files, a short program in Interactive C, an interrupt routine written in assembly language for the Motorola 6811 processor, and an ICB file. 

The uv_stime global variable sets the sampling period in milliseconds.  Adjust the sampling period so that the uv_count global variable is consistently non-zero while there is a lit flame somewhere near the sensor.  For this example, a sampling period of 250ms worked well.  Try loading the interrupt routine and C program.  Then stand a few feet away and light a match.  The Handy Board will begin beeping almost immediately. 

It is possible to control the output pulse width and background cancellation on the UVTron Driver Board by making some minor modifications to the board.  After such a procedure, it will be necessary to re-adjust the sampling period to get the best results. 

/* * uvtron.ic * Test of UVTron interrupt routine * for handy board. */ void main() { /* set sampling rate of 250ms */ uv_stime=250; for(;;) { if (uv_count) { printf("FIRE!\n"); beep(); } else { printf(" \n"); } msleep(250L); } }

Source Code - Handyboard Interrupt Assembly Instructions

The interrupt routine is hard-coded to use Handy Board digital I/O pin 15 for the UVTron input (this explains the number 15 in the name of the assembly language file).  It is possible to change the pin, but this requires changing the mask value for the I/O pin and reassembling the ASM file.  Possible mask values are $01, $02, $04, $08, $10, $20 which correspond respectively to pins 10-15 as marked on the Handy Board.  Using other pins requires more modification to the interrupt routine. 

* icb file: "hb_uv15.asm" * * Interrupt to check UVTron sensor at digital I/O pin 15 * * Based heavily on example of code installing itself into * SystemInt 1000 Hz interrupt as written by: * * Fred Martin * Thu Oct 10 21:12:13 1991 * HPRIO EQU $103C ; Highest Priority Interrupt and misc. TOC4INT EQU $E2 ; Timer Output Compare 4 PORTA EQU $1000 ; Port A data register ORG MAIN_START variable_uv_stime FDB 100 ; sampling time -- default is 100ms variable_uv_count FDB 0 ; holds number of hits during sampling time temp_var_uv_ticks FDB 100 ; sampling counter temp_var_uv_hitct FDB 0 ; hit counter subroutine_initialize_module: LDAA HPRIO ANDA #$40 ; test SMOD bit BNE *+7 LDX #$FF00 ; normal mode interrupts BRA *+5 LDX #$BF00 ; special mode interrupts * X now has base pointer to interrupt vectors ($FF00 or $BF00) * get current vector; poke such that when we finish, we go there LDD TOC4INT,X ; SystemInt on TOC4 STD interrupt_code_exit+1 * install ourself as new vector LDD #interrupt_code_start STD TOC4INT,X RTS * interrupt program begins here interrupt_code_start: * if uvtron port bit is 1 then increment hit counter LDAA $7FFF ; grab digital I/O port byte ANDA #$20 ; mask for pin 15 on Handy Board BEQ interrupt_code_ctdown ; branch if bit is clear LDD temp_var_uv_hitct ; otherwise increment hit counter ADDD #1 STD temp_var_uv_hitct interrupt_code_ctdown: LDD temp_var_uv_ticks ; decrement sampling counter SUBD #1 STD temp_var_uv_ticks BNE interrupt_code_exit * if ticks=0 then update global count variable * and reset for next sampling interval LDD temp_var_uv_hitct ; move hit count into global STD variable_uv_count LDD variable_uv_stime ; reset sampling counter STD temp_var_uv_ticks LDD #0 ; reset hit counter STD temp_var_uv_hitct interrupt_code_exit: JMP $0000 ; this value poked in by init routine

The ICB file is a special version of the assembled ASM file.  Such a file can be created by using the Interactive C ICB Assembler Server at the Newton Research Labs web site.  The assembly language file includes some unique coding conventions used by the ICB Assembler. 

S12380200064000000640000B6103C84402605CEFF002003CEBF00ECE2FD8070CC8042EDD0 S1238040E239B67FFF84202709FC8026C30001FD8026FC8024830001FD80242612FC802651 S1158060FD8022FC8020FD8024CC0000FD80267E000041 S9030000FC S123872B0064000000640000B6103C84402605CEFF002003CEBF00ECE2FD877BCC874DED9A S123874BE239B67FFF84202709FC8731C30001FD8731FC872F830001FD872F2612FC8731E5 S115876BFD872DFC872BFD872FCC0000FD87317E0000E7 S9030000FC 6811 assembler 10-Aug-91 original program by Motorola. a few modifications by Randy Sargent (rsargent@media.mit.edu) HPRIO 103c *0015 0033 PORTA 1000 *0017 TOC4INT 00e2 *0016 0044 0050 interrupt_code_ctdown 875d *0069 0063 interrupt_code_exit 877a *0086 0045 0074 interrupt_code_start 874d *0057 0049 subroutine_initialize_module 8733 *0031 temp_var_uv_hitct 8731 *0027 0065 0067 0079 0084 temp_var_uv_ticks 872f *0026 0071 0073 0082 variable_uv_count 872d *0024 0080 variable_uv_stime 872b *0023 0081

Revision History:

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