© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Page 31 of 52
All of the acquire commands send out a not-busy bit in immediate execution mode when they have
completed their work. The exception is the
ACQGRAY
command, which sends the not-busy bit ahead of
outputting the 128 bytes of grayscale pixel data. In any case, it is necessary to poll for this bit after
sending any acquire command to the AVR.
The image acquisition commands all result in 255 bits of subpixel-resolution image data in the AVR’s
internal data buffer. You can access this data using the
DUMPADR
command described later. However,
this is seldom necessary, given the firmware’s internal image analysis functions, also described later.
Here’s a code snippet that sets the exposure time to 30, the threshold and hysteresis to a fixed 64 and
10 respectively, causes the AVR to wait for
P3
to transition low, then acquires a binary image. It then
waits for the image acquisition to complete by calling the
Ready
subroutine (defined in the code
template) that polls the AVR for a not-busy condition:
OWOUT owio, 0, [SETEXP, 30, SETBIN, 64, 10, FIXED|LEVEL, ACQBIN|XTRIG]
GOSUB Ready
This also demonstrates how commands can be chained in a single
OWOUT
statement.
The
ACQGRAY
command is unique in that it gives you access to the gray-level pixel values as it reads
them out from the TSL1401R. Since there isn’t enough memory in the AVR to store all these values, they
have to be sent to the BASIC Stamp on the fly. For this reason, any PBASIC program that uses
ACQGRAY
should read these 128 bytes of data and do something with them as quickly as possible.
Slowing down acquisition from the TSL1401R chip could result in “pixel droop”, as the internal charge
storage capacitors self-discharge. The two plots below illustrate this effect. For this test, the lens and lens
housing were removed in order to illuminate the TSL1401R chip as evenly as possible. In the first, the
pixels are read out at and transmitted to the host PC at maximum speed (about 1.4 mS/pixel). The pixel
intensities are all within 14 of each other (8% of the maximum), as indicated by the threshold cursors. In
the second, an additional 20mS was added to each pixel time (2.56 seconds overall) to read out the scan.
You can see the droop near the end that results from the internal caps discharging – very unevenly – as
they await their turn to be read. And the band between the highest and lowest pixels increases to 48, or
27% of the maximum. Of course, two and a half seconds to read out the pixels would be quite extreme.
But it illustrates quite graphically what happens if they’re read out to slowly. Also, bear in mind that this
effect can only occur with
ACQGRAY
and not with any of the binary acquisition commands.