| UVTron to OOPic Example Last Modified: 2006-10-26 | | |
| Acroname Robotics | PDF webpage version | ||
| ![]() Introduction In this example, a Hamamatsu UVTron detector provides one-bit flame detection input for an OOPic. An event-driven routine counts the number of pulses in one second and places the result in a global variable. The main program loop monitors the global variable and turns on an LED when the count exceeds a threshold. 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 OOPic supplies regulated 5V power to the UVTron Driver Board. ![]() Source Code This code uses BASIC syntax. It runs with version 3.0.4 of the OOPic compiler and version A.1.7 of the OOPic. ' Filename: uvtron.osc
' UVTron Example for OOPic
'
dim uvOut as new oDio1 ' flame indicator
dim uvIn as new oDio1 ' UVTron input
dim uvPEvent as new oEvent ' UV pulse event
dim uvTEvent as new oEvent ' 1-second timer event
dim uvGate1 as new oGate ' UV event buffer
dim uvGate2 as new oGate ' Timer event buffer
dim uvCt as new oByte ' user pulse ct
dim uvCtx as new oByte ' temporary pulse ct
'--------------------------------------------------------------------------
sub main()
call inituv
uvOut.ioline=17
uvOut.direction=cvOutput
do
if (uvCt >= 4) then
uvOut=1
else
uvOut=0
end if
loop
end sub
'--------------------------------------------------------------------------
' Event-Driven UVTron Monitoring routines
' uvCt is number of UVTron pulses per second
' (4 is a good flame threshold for stock UVTron)
'
sub inituv()
uvIn.ioline=8
uvIn.direction=cvInput
uvGate1.input1.link(uvIn)
uvGate1.output.link(uvPEvent.operate)
uvGate1.operate=cvtrue
uvGate2.input1.link(oopic.hz1)
uvGate2.output.link(uvTEvent.operate)
uvGate2.operate=cvtrue
uvCtx=0
uvCt=0
end sub
sub uvPEvent_code()
uvCtx=uvCtx+1
end sub
sub uvTEvent_code()
uvCt=uvCtx
uvCtx=0
end sub
Comments This code demonstrates the use of oGate and oEvent objects. The uvGate1 object buffers the input from the UVTron and links it to trigger a uvPEvent for each incoming pulse. The uvPEvent subroutine increments the temporary pulse count, uvCtx , every time it occurs. The uvGate2 object buffers the 1 Hertz clock pulse from the OOPic system clock and links it to trigger a uvTEvent. The uvTEvent subroutine saves the temporary pulse count to the pulses per second global variable, uvCt , and resets the temporary pulse count. For a stock UVTron, a nearby flame produces about 5 or 6 pulses per second. Light a match 12 to 24 inches away from the sensor. The output LED should turn on after a delay of about 1 second. For more information about OOPic objects, see the online documentation at the OOPic Web Site. 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-calibrate the threshold for reliable flame detection. Revision History
| |||
| 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. |