Download Print this page

Parallax TSL1401-DB Instructions Manual page 33

Linescan camera module

Advertisement

Here's a program snippet that uses ACQGRAY and outputs the pixel data at 38400 baud to the DEBUG
port. It's identical to that used by the TSL1401-DB Monitor Program:
pixno VAR Byte
char
VAR Byte(16)
OWOUT owio, 0, [ACQGRAY]
GOSUB Ready
FOR pixno = 0 TO 7
OWIN owio, 8, [STR char\16]
SEROUT 16, 6, [STR char\16]
NEXT
In the above code, Ready is a subroutine, defined in the code template, which polls the AVR until it's no
longer busy.
The binary acquisition commands that perform Boolean operations on the data acquired from a previous
scan can be used to see what changes or stays the same between acquisitions. With the possible
exception of ACQAND and ACQOR, they are typically used second in a pair of commands, the first being
an ACQBIN. In other words, you first obtain a scan that simply records pixels in the usual way, then wait
awhile, then obtain another scan modifies the first one.
In addition to the 32 bytes of binary pixel data, each acquire command also collects statistics from the
image it has acquired. These are the intensity and location of the dimmest pixel, the intensity and
location of the brightest pixel, and the average pixel intensity over the entire image. The following chart
shows the readable AVR memory locations, including those affected by the acquisition commands:
Name
Addr
PIXELS
$00
to $1F
MINPIX
$20
MINLOC
$21
MAXPIX
$22
MAXLOC
$23
AVGPIX
$24
The location information ranges from 0 to 127. This is because we're dealing with grayscale pixels here,
and there are only 128 of them, whose locations are zero-based. (Binary pixels, by contrast, number from
1 to 255.) The information provided by these stats can be used, for example, to adjust the exposure
time to maintain a constant maximum pixel intensity. An example of this technique is shown in a later
section.
In addition to buffering pixels and stats, the acquire commands initialize the internal Left and Right
pointers for counting a searching to 1 and 255, respectively.
Counting Pixels and Edges
One of the simplest methods of analyzing a binary image is to determine how many pixels are bright and
how many are dark. This information alone can tell you an object's width, for example, a conveyor's
degree of coverage, or whether a bottle cap is present. The commands that performs this task are
CNTNEW and CNTNXT:
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Binary subpixel data. Pixels are packed LSB first. Since there are only 255
pixels, the last pixel (MSB of location $1F) is always 0.
Intensity (0 – 255) of the dimmest pixel.
Location (0 – 127) of the dimmest pixel. If multiple pixels share the lowest
intensity, it will be the location of the last one.
Intensity (0 – 255) of the brightest pixel.
Location (0 – 127) of the brightest pixel. If multiple pixels share the brightest
intensity, it will be the location of the last one.
Average pixel intensity (0 – 255) of all 128 pixels.
Description
Page 33 of 52

Advertisement

loading