®
®
Web Site:
www.parallax.com
Forums:
forums.parallax.com
Sales:
sales@parallax.com
Technical:
support@parallax.com
Office:
(916) 624-8333
Fax:
(916) 624-8003
Sales:
(888) 512-1024
Support:
(888) 997-8267
Web Site:
www.taosinc.com
Sales:
sales@taosinc.com
Office:
(972) 673-0759
Fax:
(972) 943-0610
TSL1401-DB (#28317):
Linescan Camera Module
Product Overview
General Description
The TSL1401-DB is a daughterboard that provides a TAOS TSL1401R 128-pixel linear array sensor and a
lens. It is designed to plug into a motherboard (e.g. MoBoStamp-pe (p/n 28300), MoBoProp (p/n 28303,
in development), Propeller Backpack (p/n 28327)) or the DB-Expander (p/n 28325). This module will
allow its host system to “see” in one dimension. Two- dimensional vision can also be achieved by moving
either the subject or the sensor in a direction perpendicular to the sensor axis.
Features
•
•
•
•
•
•
•
•
Provides vision in one dimension with 128-pixel resolution.
Three-line serial interface with analog intensity output for each pixel.
Included 7.9mm lens provides a field of view equal to subject distance.
Plug-compatible with Parallax motherboards.
Coprocessor driver firmware for the MoBoStamp-pe available for download.
Can be interfaced directly to a BASIC Stamp for some functions.
Onboard accessory socket for strobe output or 50/60Hz fluorescent light sync input.
Runs from 3.3V or 5V supplies. (5V is needed for the optional LED strobe attachment.)
Applications
•
•
•
•
•
•
Measure height, width, diameter, thickness.
Locate objects, lines, edges, gaps, holes.
Count items; measure conveyor coverage.
Determine volume, shape, orientation.
Read simple barcodes.
Learn the principles of machine vision.
What’s Included
TSL1401-DB with lens.
What You Need to Provide
•
Parallax motherboard, or DB-Expander with BASIC Stamp and carrier board (such as the BOE).
Page 1 of 52
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Introduction
What the Module Sees
The TSL1401R chip is a linear array (linescan) sensor. It consists of a single row of 128 photodetectors.
The TSL1401-DB includes a lens to form images on the sensor array. What results is somewhat like
peering through the narrow crack of a partially opened door to see a thin slice of what lies behind it. The
illustration below helps to explain the concept:
First Pixel
TOP VIEW
The output from each observed pixel is an analog voltage proportional to light intensity. The analog
intensity curve corresponding to the image above would look something like this:
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Last Pixel
Page 2 of 52
Here, you can see not only the edges of the bagel and the hole in the middle, but also the intensity
variations caused by the seeds and herbs on its surface.
The overall width (field of view) seen by the TSL1401-DB, using the included 7.9mm lens, is
approximately equal to the subject distance. So, for example, if the module is 1 meter away from the
subject, it will see a linear slice of the subject that’s 1 meter wide and 1/128
th
of a meter high.
Focusing the TSL1401-DB’s lens is accomplished by screwing it in or out. When screwed almost all the
way in, distant subjects will be in focus. To focus on closer subjects, the lens needs to be screwed out a
bit. Once proper focus is achieved, it may be necessary to secure the lens from vibration by wrapping
tape around the lens bezel and lens holder barrel. If the lens is screwed in far enough, a small O-ring
snapped into the crevice between the lens bezel and lens holder barrel will serve the same purpose.
Note:
The use of a thread locker (e.g. Loc-Tite) or any cyanoacrylic adhesive (e.g. Super Glue) is
not
recommended near lens elements, as the fumes can destroy any optical coatings that may be
present.
If you are using the TSL1401-DB with a Parallax MoBoStamp-pe, you can use the PC-hosted monitor
program, described later in this document, as an aid to focusing.
Interface and Basic Operation
Refer to the schematic on the last page of this document for the TSL1401-DB’s pinout, and to TAOS’s
TSL1401R-LF datasheet (available from
www.taosinc.com)
for the sensor chip’s particulars. For normal
operation (i.e. without external strobing or syncing), there are only three signals that need to be
considered:
SI
(digital output to the sensor: begins a scan/exposure),
CLK
(digital output to the sensor:
latches
SI
and clocks the pixels out), and
AO
(analog pixel input from the sensor: 0 – Vdd, or tri-stated if
beyond pixel 128). The TSL1401 datasheet describes these signals in detail, so that description won’t be
repeated here, except as it relates to the BASIC Stamp.
If you are using the TSL1401-DB with Parallax’s DB-Expander (p/n 28325), the pin correspondences are
as follows:
TSL1401R Pin
AO
SI
CLK
DB-Expander Pin
A
B
C
The TSL1401R is a
light-integrating
device. It’s a bit like photographic film in that regard: the longer you
expose it, the brighter the resulting image. Also, like film, it can saturate, such that if exposed too long,
everything – even the darkest subjects – will look completely white. The exposure time (also called
“integration time”) is the time interval between
SI
pulses. (Well, actually, the exposure doesn’t
really
begin until 18 clocks
after
SI;
but it’s often convenient to ignore that detail if those clocks occur quickly
enough.) During each exposure, all the pixels need to be clocked out of the device to prepare it for the
next exposure. However, the exposure interval for each pixel begins and ends with the
SI
pulse, not with
the moment it’s clocked out, as with some other sensors. Therefore, all the pixels get exposed
simultaneously, and the acquired image represents the same interval in time for each of them.
There are two ways to acquire images with the TSL1401R: continuous and one-shot. In continuous
imaging, the
SI
pulses occur in a steady stream, with 129 or more pixel clocks in between, during each
exposure interval. To acquire an image, you need to wait for the next
SI
pulse time before clocking out
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Page 3 of 52
the pixels that constitute the image. These pixels will represent the light received during the previous
exposure interval. Waveforms illustrating this method are shown below:
Clock out scan n-1
Integrate scan n
SI
CLK
1
2 3 4 5 6 7 8 9 10
...
129
1
2 3 4 5 6 7 8 9 10
...
129
Clock out scan n
Integrate Scan n+1
AO
Tri-
Stated
Tri-
Stated
Tri-
Stated
In one-shot imaging, the TSL1401R is left idle until it’s time to snap a picture. Then
SI
clocked in, and
128 pixels are rapidly clocked out and discarded. Then you simply wait until the desired exposure time
(since the
SI
pulse) has elapsed and pulse
SI
again. At this point, you can clock out the pixels resulting
from the timed exposure. Here is a sample waveform:
Clock out garbage
Integrate scan
SI
CLK
IDLE
Clock out scan
IDLE
1
129
1
2 3 4 5 6 7 8 9 10
...
129
Tri-
Stated
Tri-
Stated
Tri-
Stated
AO
In all the discussion that follows, we will be using one-shot imaging.
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Page 4 of 52
Operation with the BASIC Stamp
This section explains how to use the TSL1401-DB directly with a BASIC Stamp. If you have the
MoBoStamp-pe BASIC Stamp 2pe motherboard, you can skip this section and proceed to the section
titled “Operation with the MoBoStamp-pe”.
Connection
The following illustration shows how to connect the TSL1401-DB to a BASIC Stamp, using Parallax’s
Board of Education and a DB-Expander board:
Vdd
Vin
Vss
P15
P14
P13
P12
P11
P10
P9
P8
P7
P6
P5
P4
P3
P2
P1
P0
The signal pinouts and port usage shown above are consistent with the examples to follow in this section.
You can also use the DB-Extension Cable (p/n 500-28301) to separate the TSL1401-DB from the DB-
Expander board if you need to.
Image Acquisition
The output of the TSL1401R is an analog signal, but the BASIC Stamp does not have analog input
capability (except via RCTIME, which isn’t fast enough to read 128 pixels). How, then, is it possible to use
this device with a BASIC Stamp? We do it by connecting the
AO
signal directly to one of the Stamp’s
digital inputs. When done this way, the BASIC Stamp will threshold the analog input. Anything over about
2 volts will read as a
1;
anything under, as a
0.
By treating the signal this way, it’s possible to input a
string of
1s
and
0s
that represent light and dark portions of the “scene” being recorded. A complete
scan, then, would require 128 bits of data (i.e. 16 bytes, or 8 words), which the BASIC Stamp can
accommodate handily.
Once these bits have been read in, it’s possible to analyze “features” of the scene by looking for groups
of light and dark pixels. For example, if you wanted to measure the width of a light object against a dark
background, you could read in the image, then count the number of “1” bits in the data. Likewise, if you
wanted sense the edge of a “web” (e.g. paper in a paper mill) to keep the web on track, you would look
for the first occurrence of a light or dark pixel in each scan.
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Page 5 of 52