Download Print this page

Parallax TSL1401-DB Instructions Manual page 35

Linescan camera module

Advertisement

not
When DRKEDG or BRTEDG is selected, the command looks for the first pixel that does
match the
selected intensity (i.e. DRK or BRT), starting from the Left limit. It then looks for the next pixel that
does
match. This transition is an edge, and is counted as such. This process continues, accumulating the edge
count until the Right limit is reached. Here is an example:
OWOUT owio, 0, [CNTNEW|DRKEDG, 32, 64]
GOSUB Ready
Here are the same pixels, but with the counted edges
highlighted
:
... 0000111000
11111111000000001111110000111111
1111100000 ...
31 32
64 65
There are two such edges within the region of interest, so the result of this command is 2, which is then
buffered at the next available buffer location. Assuming again that this is just a continuation of the code
that went before, we could then read this result into the Byte variable edge_count from location $20
(RESULTS):
OWOUT owio, 0, [DUMPADR, RESULTS]
OWIN owio, 2, [edge_count]
But if we're interested in
both
the pixel count and the edge count, it's much more efficient to compute
then
them both,
read the results. This is what the code would look like in that case:
OWOUT owio, 0, [CNTNEW|DRKPIX, 32, 64]
GOSUB Ready
OWOUT owio, 0, [CNTNXT|DRKEDG]
GOSUB Ready
OWOUT owio, 0, [DUMPADR, RESULTS + 5]
OWIN owio, 2, [dark_count, edge_count]
Note that, because these commands are executed immediately, we need to wait for each one to
complete by calling Ready before sending another. Also note that edge_count is now being read from
location RESULTS + 6 ($26) instead of RESULTS ($20). This is because there is no reset this time
between reading dark_count and edge_count.
Also note that CNTNEW leaves the internal pointers set to Begin and End, and CNTNXT leaves the
internal pointers where they were when it was invoked. For that reason, the second count can use
CNTNXT, since the 32 and 64 are already established.
In the section that discusses buffered commands, we shall see how this whole sequence can be made yet
more efficient by chaining the commands in the command buffer and executing them as a single
command.
Locating Pixels and Edges
In addition to counting pixels and edges, it's also useful to know where certain pixels and edges are
located within the image. We may want to locate the edge of a web on a paper machine, for example, to
make sure it's tracking right, or follow a seam for welding two pipe sections together, or determine the
level of liquid in a clear bottle. The commands that do all this are FNDNEW and FNDNXT:
FNDNEW|Modifiers, Begin, End
FNDNXT|Modifiers
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Page 35 of 52

Advertisement

loading