Download Print this page

Automatic Exposure - Parallax TSL1401-DB Instructions Manual

Linescan camera module

Advertisement

Automatic Exposure

For accurate measurements, the only thing that should ever change is the size or position of what we are
trying to measure. If a subject isn't in perfect focus or isn't lit with perfect evenness, it can seem to grow
and shrink with variations in lighting. And despite our best efforts, lighting isn't always as controlled as
we'd like it to be. So we often need to compensate by adjusting the exposure time to changing light
levels. In cases where a bright object is always within the field of view and/or light intensity changes very
slowly, this is pretty easy.
The image acquisition commands all record the intensity of the brightest pixel. This information can be
used to maintain a constant maximum brightness under varying light conditions. The simplest rule is this:
1. If the maximum brightness is greater than 220, we decrease the exposure time by one.
2. If the maximum brightness is less than 200, we increase the exposure time by one.
3. If the maximum brightness is between 200 and 220, we leave the exposure time alone.
We want to keep the brightness high, for maximum analog resolution, but we don't want it to saturate.
When brightness levels reach 255, that means the limit of the TSL1401R's voltage output has been
reached, so there's no way to tell if the actual brightness might have been higher than that. So we try to
keep the maximum brightness between 200 and 220. Here's a snippet of code that illustrates the rule in
action. It uses the LEDs on the MoBoStamp-pe to indicate the current light level: Red is too high; green is
too low; yellow (red and green together) is just right.
red
PIN 13
green
PIN 14
max_brt
VAR Byte
exp_time VAR Byte
exp_time = 30
OWOUT owio, 1, [SETEXP, exp_time]
DO
OWOUT owio, 0, [ACQBIN]
GOSUB Ready
OWOUT owio, 0, [DUMPADR, MAXPIX]
OWIN owio, 2, [max_brt]
IF (max_brt < 200) THEN
exp_time = exp_time + 1 MAX 255
OWOUT owio, 0, [SETEXP, exp_time] '
LOW green : HIGH red
ELSEIF (max_brt > 220) THEN
exp_time = exp_time - 1 MIN 1
OWOUT owio, 0, [SETEXP, exp_time] '
LOW red : HIGH green
ELSE
LOW green : LOW red
ENDIF
LOOP
Keeping the maximum brightness at a constant level is
is that brightness is being measured continuously here. In applications where images are acquired
sporadically, this approach may not work, unless acquisitions are performed between them just to
measure image brightness. If you run this program, you will notice that it responds to changes in
brightness rather slowly. In situations where brightness can vary faster than simple incrementing or
decrementing can compensate for, it may be necessary to adjust by an amount proportional to the
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
'Pin for red LED on MoBoStamp-pe.
'Pin for green LED on MoBoStamp-pe.
'Maximum brightness read from driver.
'Current exposure time.
'Establish initial exposure time,
'
and set it.
'Do repeatedly:
'
Acquire an image.
'
Wait for not-busy state.
'
Read the maximum pixel value.
'
Is it less than 200?
'
Yes: Increment exposure time (to 255 max),
and set it.
'
Indicate as green (too low).
'
Is it greater than 220?
'
Yes: Decrement exposure time (to 1 min),
and set it.
'
Indicate as red (too high).
'
Is it between these values?
'
Yes: Indicate as yellow (just right).
all
this code does, by the way. One thing to note
Page 45 of 52

Advertisement

loading