Download Print this page

Parallax TSL1401-DB Instructions Manual page 43

Linescan camera module

Advertisement

Here is the program that sorts this all out and gives a pass/fail grade to each bottle it sees:
1
liq_btm VAR Byte
2
liq_top VAR Byte
3
cap_btm VAR Byte
4
cap_top VAR Byte
5
liq_lvl VAR Byte
6
cap_siz VAR Byte
7
i
VAR Byte
8
pix
VAR Byte
9
10
OWOUT owio, 1, [SETEXP, 60]
11
OWOUT owio, 0, [SETBIN, 0, 1, FLOAT|LEVEL|5]
12
DO
13
SERIN 16, 84, [WAIT(" ")]
14
OWOUT owio, 0, ["<", ACQBIN, FNDNXT|FWD|DRKEDG]
15
OWOUT owio, 0, [FNDNXT|FWD|BRTEDG, FNDNXT|BKWD|DRKEDG]
16
OWOUT owio, 0, [FNDNXT|BKWD|BRTEDG, ">"]
17
GOSUB Ready
18
OWOUT owio, 0, [DUMPADR, PIXELS]
19
DEBUG CLS
20
FOR i = 0 TO 31
21
OWIN owio, 0, [pix]
22
DEBUG BIN8 pix REV 8
23
IF (i & 7 = 7) THEN DEBUG CR
24
NEXT
25
OWOUT owio, 1, [DUMPADR, RESULTS + 5]
26
OWIN owio, 2, [liq_btm, liq_top, cap_top, cap_btm]
27
cap_siz = cap_top - cap_btm
28
liq_lvl = liq_top + liq_btm >> 1
29
IF (cap_siz > 35 AND cap_top < 206 AND liq_lvl > 110 AND liq_lvl < 130) THEN
30
DEBUG CR, "Pass"
31
ELSE
32
DEBUG CR, "Fail"
33
ENDIF
34
DEBUG ": Cap Size = ", DEC cap_siz, "
35
DEBUG "
Liquid Level = ", DEC liq_lvl
36
LOOP
Unlike the prior program, which relies on a falling edge on P3 to trigger a new scan, this one operates
more in demo mode, in that the trigger comes from tapping the spacebar in the DEBUG window. Here's a
blow-by-blow description:
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Cap Top = ", DEC cap_top
Page 43 of 52

Advertisement

loading