Download Print this page

Parallax TSL1401-DB Instructions Manual page 37

Linescan camera module

Advertisement

As with the count commands, we need to call Ready before issuing further commands. Now suppose the
binary pixel array looked like this, where vertical bars represent the location 32 and 64 boundaries:
... 0000111000
The result of the FNDNEW would thus be 40, the location of the first dark pixel, starting from location
32 and moving right. That value would be appended to the results buffer, as with the count commands,
and we can read it into the Byte variable location like this (assuming this is the first command after the
last acquisition:
OWOUT owio, 0, [DUMPADR, RESULTS + 5]
OWIN owio, 2, [location]
Now suppose we wanted to locate the first dark-to-light edge in the same region. Here's the code:
OWOUT owio, 0, [FNDNEW|FWD|BRTEDG, 32, 64]
GOSUB Ready
We use BRTEDG here because that's the kind of edge (low-to-high) FNDNEW has to find. But for there
to exist such an edge within the given range, there has to be a dark pixel first, followed by a light one.
So, given the same image as above, we find our edge at location 48, as
... 0000111000
Now, suppose we want to find the first bright
begins with a low-to-high transition and ends with a high-to-low transition. Here is where chaining two
finds comes in handy:
lft_edge VAR Byte
rgt_edge VAR Byte
OWOUT owio, 0, [SETEXP, 60, SETBIN, 100, 3, 0, ACQBIN]
GOSUB Ready
OWOUT owio, 0, [FNDNEW|FWD|BRTEDG, 32, 64] '
GOSUB Ready
OWOUT owio, 0, [FNDNXT|FWD|DRKEDG]
GOSUB Ready
OWOUT owio, 0, [DUMPADR, RESULTS + 5]
OWIN owio, 2, [lft_edge, rgt_edge]
IF (rgt_edge) THEN
DEBUG "Object found starting at ", DEC lft_edge, " and ending at ", DEC rgt_edge - 1
ELSE
DEBUG "No object found."
ENDIF
There are several things to talk about in the above code:
First, once we've located the first edge, we want to continue from where we left off to find the
second one, so we use FNDNXT for the second, leaving off the Begin and End locations.
Second, since we've chained two commands in a row, after the ACQBIN, our results will be
found sequentially, beginning at location RESULTS + 5.
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
11111111000000001111110000111111
31 32
11111111000000001111110000111111
31 32
object
1111100000 ...
64 65
highlighted
1111100000 ...
64 65
in the same region. A bright object is one that
'___ Chained finds
'
'
:
Page 37 of 52

Advertisement

loading