Download Print this page

Parallax TSL1401-DB Instructions Manual page 9

Linescan camera module

Advertisement

' bright edges, displaying them graphically using DEBUG. Finally it
' computes both the area and extent of the object found.
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
ao
PIN 0
si
PIN 1
clk
PIN 2
' -----[ Constants ]-------------------------------------------------------
DRK
CON 0
BRT
CON 1
FWD
CON 0
BKWD
CON 1
' -----[ Variables ]-------------------------------------------------------
VariableName
VAR
pdata
VAR Word(8)
pixels
VAR pdata.BIT0
exp
VAR Word
lptr
VAR Byte
rptr
VAR Byte
i
VAR Byte
cnt
VAR Byte
which
VAR Bit
dir
VAR Bit
found
VAR Bit
' -----[ Program Code ]----------------------------------------------------
' NOTE: This code assumes that DEBUG will wrap after 128 characters,
'
regardless of the DEBUG window width. Later versions of DEBUG
'
may not do this, and you will have to add CRs where needed.
exp = 8333
DEBUG HOME
GOSUB DispHdr
DO
GOSUB GetPix
DEBUG CRSRXY, 0, 2
GOSUB DispPix
lptr = 0 : rptr = 127: which = BRT : dir = FWD : found = 1
GOSUB FindEdge
dir = BKWD
GOSUB FindEdge
DEBUG CLREOL
IF found THEN
DEBUG CRSRX, (lptr - 1), "_|"
DEBUG CRSRX, rptr, "|_"
GOSUB CountPix
DEBUG CR, CR, "Area = ", DEC cnt,'
"
Extent = ", DEC rptr - lptr + 1, CLREOL '... and extent of object.
ELSE
DEBUG CR, CR, "No object found.", CLREOL
ENDIF
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
'TSL1401R's analog output (threhsolded by Stamp).
'TSL1401R's SI pin.
'TSL1401R's CLK pin.
'Value assignd to "which" for dark pixels.
'Value assigned to "which" for bright pixels.
'Value assigned to "dir" for left-to-right search.
'Value assigned to "dir" for right-to-left search.
Byte
' What is variable for?
'Pixel data, as acquired LSB first from sensor.
'128-bit pixel array mapped onto pdata.
'Exposure (integration) time in 2uSec units.
'Left pixel pointer for count and find operations.
'Right pixel pointer for count and find operations.
'General-purpose index.
'Result of pixel-count routine.
'Indicates seeking DRK or BRT pixels/edges.
'Indicates direction of search (FWD or BKWD).
'Indicates pixels found (= 1), or not found (= 0).
'Set exposure time to 8333uSec (1/120th sec).
'Go to home position on DEBUG screen.
'Display the pixel location header.
'Begin the scan-and-process loop.
'Obtain a pixel scan.
'Move to column 0, row 2.
'Display the pixels here.
'Initialize parameters for find.
'Find first dark-to-light edge going L->R.
'Switch directions.
'Find first dark-to-light edge going L<-R.
'Clear the next line.
'Both edges found?
'Yes: Display left edge.
'
'
'No:
Display right edge.
Compute area (light pixel count).
Display area ...
Display failure message.
Page 9 of 52

Advertisement

loading