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

basket

Acroname Robotics PDF webpage version UVTron to BrainStem Example PDF

Related
Products

Product image for Brainstem GP 1.0 Module
Brainstem GP 1.0 Module
Product image for 2600mAh AA NiMH Battery
2600mAh AA NiMH Battery
Product image for UVTron Flame Detector Package
UVTron Flame Detector Package
Product image for 4X AA Battery Pack w/Connector
4X AA Battery Pack w/Connector

Contents

Interface setup for using the UVTron with the BrainStem.

Introduction

In this example, the Hamamatsu UVTron detector provides a one-bit flame detection input for a BrainStem GP 1.0.  A reflex updates a counter each time it detects a pulse from the UVTron.  A small subroutine written in TEA returns the pulse count in a desired interval.  A main TEA routine continuously takes readings and prints the results to the BrainStem GP 1.0 Console.  This example shows a Palm Pilot running the Console to display the detector readings, but any supported Platform could be used. 

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 BrainStem GP 1.0 supplies regulated 5V power to the UVTron Driver Board. 

Wiring diagram for the UVTron to the BrainStem.

Source Code - Reflex for Counting UVTron Pulses

A UVTron pulse counting reflex is used to tally the number of pulses that occur from the UVTron detector.  The following is a compiled reflex routine that can be loaded onto a BrainStem controller.  The reflex routine is hard-coded to use digital I/O pin 0 for the UVTron input.  It is possible to change the pin, but this requires changing the batch file.  For more information on this reflex, see the Digital Polling example in the Reflexes section of the online BrainStem Reference.  It describes a reflexive routine identical to the one used that is used here. 

The following is bag file that contains the description of the UVTron pulse counting reflex.  To load the reflex, the file must first be placed into the aUser BrainStem directory.  Then enter batch "uv_ex.bag" at the Console prompt. 

/* uv_ex.bag */ 2 11 128 15 0 128 129 128 2 12 128 0 2 3 43 0 1 2 12 128 1 2 2 28 0

Source Code - TEA File

The aUVTron_Read_Int routine takes a sampling interval parameter in 0.1ms units.  It resets an internal counter, then waits for the sampling interval to expire.  Then it returns the number of UVTron pulses during that interval.  The main program has a sampling interval of 1 second. 

Try loading the reflex and TEA program.  Run the program and observe the output.  The Console display should give readings of 0 every second.  Light a match 8-10 inches away from the sensor.  With a stock UVTron, The Console display should have readings of 4 to 6 pulses after each sampling interval. 

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 try a different sampling interval to get the best results. 

/* uv_ex.tea */ /* IOPort definitions and display routines */ #include <aCore.tea> #include <aPrint.tea> #define uvtronIN 0 #define uvtronCTR 0 void aUVTron_Setup() { asm { // configure the uvtron input pin // (enable reflex msg on 0-1 transition // on digital pin 0) pushlb 0b00000111 popbm aPortDigital + (aPortDigitalBlockSize * uvtronIN) + aOffsetDigitalConfig } } /* aUVTron_Setup */ /* * * * * * * * * * * * * * * * * * * * * * * */ int aUVTron_Read_Int(int nTime) { int val=0; asm { // clear pulse count pushls 0 popsm aPortRflxCtr + uvtronCTR } // wait a while aCore_Sleep(nTime); asm { // retrieve the count value // then pop the result into val pushms aPortRflxCtr + uvtronCTR popss 2 } return val; } /* aUVTron_Read_Int */ /* * * * * * * * * * * * * * * * * * * * * * * */ void main() { int num = 0; int reading; /* call setup once to configure the I/O */ aUVTron_Setup(); /* loop forever showing the readings */ while (1) { /* take a reading (number of pulses in one * second) */ reading = aUVTron_Read_Int(10000); /* build up the display line */ aPrint_String("Pulses in Interval "); aPrint_IntDec(num++); aPrint_String(" = "); aPrint_IntDec(reading); aPrint_Char(10); } /* while (1) */ } /* main */

Revision History:

  • 2001-07-06: Example Created.
  • 2001-10-07: Corrected a typo in the TEA program by changing the obsolete "PortCounter" to the current "aPortRflxCtr". Thanks to Al McCutcheon for finding that.
  • 2002-01-11: Updated program for compatibility with Build 5 software and TEA libraries.
 

Related Links:

Brainstem Software: Console Overview

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.