TSL1401DB Automatic Exposure control using ".BS2 " Code
Hi Phil,
I use the TSL1401DB, MoBoStamp-pe, and PLX-DAQ for spectral data acquisition. Your TSL1401-DB_Manual describes automatic exposure control when using the TSL1401DB Monitor, but for the life of me I cant figure out how to implement automatic exposure control in stand alone ".bs2" code.
Can you post example code to do this please?
Thank you,
Mike
I use the TSL1401DB, MoBoStamp-pe, and PLX-DAQ for spectral data acquisition. Your TSL1401-DB_Manual describes automatic exposure control when using the TSL1401DB Monitor, but for the life of me I cant figure out how to implement automatic exposure control in stand alone ".bs2" code.
Can you post example code to do this please?
Thank you,
Mike

Comments
Here's the code that the monitor program loads into the BS2pe (autoexposure stuff highlighted in red):
' {$STAMP BS2pe} ' {$PBASIC 2.5} io PIN 6 ext PIN 3 busy VAR Bit mode VAR Byte exp VAR Byte led VAR Byte gate VAR mode.BIT7 trig VAR mode.BIT6 strobe VAR mode.BIT5 autoexp VAR mode.BIT4 sync VAR mode.BIT3 lock VAR mode.BIT2 pixno VAR Byte pixval VAR Byte char VAR Byte(16) i VAR Byte maxbrt VAR Char NUL CON $00 SOH CON $01 EOT CON $04 BAUD9600 CON 84 BAUD CON 6 mode = 0 exp = 64 led = 0 PAUSE 10 LOW 14 SEROUT 16, BAUD9600, [NUL, NUL, NUL, "R", NUL, EOT] SERIN 16, BAUD9600, 200, GoAhead, [WAIT(SOH, "M"), HEX2 mode, HEX2 exp, HEX2 led] GoAhead: pause 10 SEROUT 16, BAUD9600, [NUL, ">", NUL, EOT] OWOUT io, 1, [$EC, 128, 8, $00, $EB, strobe << 7 | led, $EE, exp] ', $A4] GOSUB Ready DO DO WHILE (gate and ext) : LOOP IF (sync) THEN IF (trig) THEN DO : LOOP UNTIL ext DO : LOOP WHILE ext ENDIF LOW 0 : INPUT 0 PULSIN 0, 0, char IF (char = 0 OR char > 96) THEN lock = 0 ELSE lock = 1 OWOUT io, 1, [$A0] ELSE OWOUT io, 1, [trig << 3 + $A0] ENDIF SEROUT 16, BAUD, [NUL, "M", HEX2 mode, HEX2 exp, HEX2 led, NUL, EOT] GOSUB Ready SEROUT 16, BAUD, [NUL, "P"] OWIN io, 8, [SPSTR 126] OWIN io, 8, [STR char\2] FOR i = 0 to 125 GET i, pixval SEROUT 16, BAUD, [pixval] NEXT SEROUT 16, BAUD, [STR char\2] SEROUT 16, BAUD, [NUL, EOT] [color=red]IF (autoexp) THEN OWOUT io, 1, [$DA, 34] OWIN io, 8, [maxbrt] exp = $E000 / (maxbrt / $FF + 1 * maxbrt) */ exp max 255 min 1 OWOUT io, 1, [$EE, exp] ENDIF[/color] LOOP Ready: DO OWIN io, 4, [busy] LOOP WHILE busy RETURN-Phil