Download Print this page

Parallax TSL1401-DB Instructions Manual page 10

Linescan camera module

Advertisement

LOOP
END
' -----[ Subroutines ]-----------------------------------------------------
' -----[ GetPix ]----------------------------------------------------------
' Acquire 128 thresholded pixels from sensor chip.
' exp is the exposure time in microseconds.
GetPix:
SHIFTOUT si, clk, 0, [1\1]
PWM clk, 128, 1
PULSOUT si, exp >> 1 MIN 1016 – 1016 'Wait for remaining integration time.
SHIFTOUT si, clk, 0, [1\1]
SHIFTIN ao, clk, LSBPRE, [pdata(0)\16, pdata(1)\16, pdata(2)\16, pdata(3)\16]
SHIFTIN ao, clk, LSBPRE, [pdata(4)\16, pdata(5)\16, pdata(6)\16, pdata(7)\16]
RETURN
' -----[ DispHdr ]---------------------------------------------------------
' Display a header to aid in identifying pixel positions.
DispHdr:
FOR i = 0 TO 12
DEBUG DEC i DIG 0
IF i < 12 THEN DEBUG "
NEXT
FOR i = 0 TO 127
DEBUG DEC i // 10
NEXT
RETURN
' -----[ DispPix ]---------------------------------------------------------
' Display 128 pixels: light pixels as "1"; dark, as "_".
DispPix:
FOR i = 0 TO 127
IF pixels(i) THEN DEBUG "1" ELSE DEBUG "."
NEXT
RETURN
' -----[ FindEdge ]--------------------------------------------------------
' Find the first edge within the range lptr through rptr, in the direction
' given by dir and of the type indicated by which (0 = light-to-dark;
' 1 = dark-to-light).
FindEdge:
which = 1 - which
GOSUB FindPix
which = 1 - which
' -----[ FindPix ]---------------------------------------------------------
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
'Clock out the SI pulse.
'Rapidly send 150 or so CLKs.
'Clock out another SI pulse.
'Read 8 words (128 bits) of data.
'Display tens digits.
" ELSE DEBUG CR
'Display ones digits.
'Look for opposite kind of pixel first.
'Then look for desired pixel,
'
by falling through to FindPix.
Page 10 of 52

Advertisement

loading