Download Print this page

Parallax TSL1401-DB Instructions Manual page 42

Linescan camera module

Advertisement

Here's one way to do it:
1
lft_edge VAR Byte
2
rgt_edge VAR Byte
3
area
VAR Word
4
5
6
OWOUT owio, 1, [SETEXP, 30]
7
OWOUT owio, 0, [SETBIN, 128, 10, FIXED|LEVEL]
8
9
DO
10
OWOUT owio, 0, ["<", ACQBIN|XTRIG, FNDNXT|FWD|BRTEDG]
11
OWOUT owio, 0, [FNDNXT|BKWD|BRTEDG, ">"]
12
IF (rgt_edge) THEN
13
area = area + rgt_edge - lft_edge + 1
14
ELSEIF (area) THEN
15
DEBUG "Bagel area: ", DEC area, CR
16
area = 0
17
ENDIF
18
GOSUB Ready
19
OWOUT owio, 0, [DUMPADR, RESULTS + 5]
20
OWIN owio, 2, [lft_edge, rgt_edge]
21
LOOP
This is very similar to the previous example, except that the statement order has been changed. We've
buffered the acquire and finds in the loop first, but then look what happens: we start computing with
data that hasn't yet been read. In PBASIC, all variables are initialized to zero; So the first time through
the loop, neither the IF nor the ELSEIF conditions will be true, and that section, between lines 12 and
17, will simply be skipped.
data, which we do on lines 19 and 20. Now, when we loop back, we can prime the next exposure right
and then
away,
get on with our area calculations and, possibly, output. This has the effect of overlapping
the coprocessor's work with the PBASIC program's in the most efficient manner possible. Of course, in
any real application, you also have to make sure there's enough time between encoder pulses to get
everything done! The illustration below shows the timeline of events:
PBASIC
>
Compute
Driver
Waiting
Encoder (P0)
In the monitor program section, we looked at bottles – some full, some not-so full, some with caps, and
some without. What we want to do is pass the bottle if all of the following conditions prevail:
1. The liquid level is detected between pixels 111 and 129, and
2. The cap is detected, and it has a size of at least 36 pixels.
3. The top of the cap is no higher than pixel 205 (i.e. it's pushed on all the way).
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Then
comes the call to Ready, because right then we want to read some new
Waiting in Ready
Acquire Image
Find Edges
Read < ... >
Compute & Output
Send Buffer
Waiting
In Ready
Acquire Image
Find Edges
Page 42 of 52

Advertisement

loading