TEXAS ADVANCED OPTOELECTRONIC
www.taosinc.com
SOLUTIONS
www.parallax.com
TCS230 COLOR SENSOR MODULE WITH APPMOD ADAPTER
Out of the Box
Getting Started
The TCS230 Color Sensor Module set consists of two printed circuit boards and a short length of ribbon cable. These boards are packaged plugged into one another.
Key the following BS2 program into the BASIC Stamp Editor (available for download from www.parallax.com):
!
After unpacking the two boards, separate them. Do not power them up plugged into each other. To do so could irreparably damage both boards.
The AppMod adapter board (the one having the pass-thru connector) may be plugged directly into the Parallax AppMod connector, like the one provided on the Board of Education. It should be inserted so that the pin legends on the adapter board align and agree with those on the Board of Education.
Figure 1. AppMod board correctly installed.
'{$STAMP BS2} EN con A0 con S0 con S1 con S2 con S3 con nLED con OUT con
1 2 3 4 5 6 7 8
pRED pGREEN pBLUE
con con con
12 6 5
RED GREEN BLUE
var var var
word word word
Start:
low high high low high
A0 S0 S1 nLED EN
MainLp:
gosub debug debug debug debug goto
Color "R", dec3 RED " G", dec3 GREEN " B", dec3 BLUE cr MainLp
low low count high coun unt t high coun unt t return
S2 S3 OUT, pRED, RED S3 OUT, OU T, pB pBL LUE UE, , BLU LUE E S2 OUT, OU T, pG pGR REE EEN, N, GR GRE EEN
Color:
!
Make sure all 20 pins of the AppMod adapter are inserted into their respective socket holes. Offsetting the adapter (e.g. connecting just one row of pins or shifting it up or down) can cause irreparable damage.
The sensor module is connected to the AppMod adapter using the supplied 6" (150mm) ribbon cable. This cable is keyed with a blocked connector hole on each end. These correspond to the pins missing from the 2x5 headers on both boards. So long as all nine pins are connected, you cannot attach the cable incorrectly, and either end can be connected to either board. The AppMod adapter has two headers to which the cable may be attached. They are addres add ressab sable le as 0 (J5 (J5)) an and d 1 (J1 (J1), ), wi with th the addresses screened onto the board. This is to accommodatee two sensor modules at once, if accommodat desired, or to enable various mounting orientations when when used with the BOE-Bot.
end
With th With thee se sens nsor or mo modu dule le detached an and d a se seri rial al cable connected from your PC to the Board of Education,, power up the Board of Education, Education Education, and Run the pro progra gram m you you've 've ent entere ered. d. Po Power wer down, attach the sensor module to the AppMod adapter's J5 via the ribbon cable, and power up again. Two things should now happen: 1) The white LEDs on the sensor module will come on, and 2) You will see output appear on the debug terminal that looks something like this: R123 G06 R123 G065 5 B20 B200 0 R120 R12 0 G06 G060 0 B18 B187 7
etc. These numbers are relative values for the red, green, and blue components of the color the sensor is looking at. Now, grasp the sensor module and aim it down at a light-colored piece of paper. Move the module up and
down as you watch the debug output. The numbers will increase, peaking peaking at a maximum, then decrease again. Notice where the module is at the peak. The circuit board should be about one inch above the surface of the paper. Also notice that at this point the spots from the two LEDs converge into one. This is the position at which you will always want to read color. You can easily construct a small stand for the sensor module using parts obtained from a hardware store: 4 ea. 4-40 x 1¼" (or M3 x 35mm) pan-head machine screws, 8 ea. 4-40 (or M3) hex nuts. Attach them to the sensor module as shown:
Figure 2. Adjustable stand made from machine screws.
The exact height can be set by loosening the nuts, advancing or retracting each screw, then retightening the nuts. Alternatively, the TCS230 Deluxe Mounting Alternatively, Kit contains several fixtures, brackets and spacers for mounting the sensor module in a variety of orientations (both on and off the BOE-Bot).
Hardware Notes No technical discussion of the TCS230 sensor module set would be complete without the material contained in the TAOS TCS230 datasheet. If you do not have this datasheet, you are encouraged to download it from the TAOS website, www.taosinc.com. The TCS230 has an array of photodetectors, each with either a red, green, or blue filter, or no filter (clear). The filters of each color are distributed evenly throughout the array to eliminate location location bias among the colors. Internal to the device is an oscillator which produces a square-wave output whose frequency is proportional to the intensity of the chosen color. There is one tri-statable output from this oscillator, and the color to be read is selected using two address lines: S2 and S3. In In addi addition tion,, it it is possi possible ble to program the divide rate of the oscillator
using usin g tw two o ad addi diti tion onal al li line nes, s, S0 an and d S1. Th Thee settings for these control lines and their functions are summarized below: S0 S1 S1 Di Divide 0 0 Pwr. Pwr. Down 0 1 1:50 1: 1 0 1:5 1 1 1:1
P7 for other purpo purposes. ses. Addi Addition tionall ally, y, if P8 is used us ed el else sewh wher ere, e, OUT ma may y be sw swit itch ched ed to P11 by cutting the trace on J3 and jumpering the center pin to the other outside pin.
S2 S3 S3 Co Color 0 0 Red 0 1 Blue Bl 1 0 Clear 1 1 Green
The decoding logic is shown below:
Most of the TCS230 chip's data and control lines are accessed directly via BASIC Stamp port pins through the AppMod adapter board. The only exception is the /OE (activelow output enable) line, which is decoded for each ea ch cabl blee hea eade derr (J (J11 = Unit 1, and J5 = Unit 0) us usin ing g A0 an and d EN fr from om th thee BA BASI SIC C St Stam amp. p. In addit add ition ion,, eac each h sen sensor sor mod module ule's 's /OE lin linee further gates the LED enable, so that the board's LEDs cannot be on if the output is disabled. This additional logic accomplishes two things: 1) it prevents contention on the OUT line if two sensor modules are connected to the AppMod adapter, and 2) it prevents the excess current drain that would occur from two sets of LEDs being on concurrently. The BASIC Stamp port assignments are shown in the following chart:
A0 0 0 0 1 1 1
EN 0 1 1 0 1 1
/LED 0/1 0 1 0/1 0 1
/OE0 disable enab en able le enable disable disable disable
LED0 off of on of f off of of f of f
/OE1 L ED ED1 disable of off disable off disable off di disable of off enab en able le on enable off
system is a function not only of the sensor's device response, but also of the system's optics and illumination. The combined response of this module, taking into account the lens' IR filter and the LEDs' emission curve, is shown below: 1.0
Clear y t i v i s n o p s e R e v i t a l e R
The sensor module may also be operated without the AppMod adapter. In this case, the TC TCS23 S2300 sig signa nall /OE is con contro troll lled ed dir direct ectly ly rather than through the address decoding logic shown above. LED "on" is still condit con ditio ioned ned upo upon n /OE bei being ng act active ive low low,, however. Also, even though the TCS230 chip is capable of operation from 2.7 to 5.5V supplies, the module's Vdd must be a regulated +5.0VDC.
0.8
Blue Green Red
0.6
0.4
0.2
0.0 400
500
600
700
800
Wavelength - nm
Figure 3. Sensor module color response.
Software Notes
When used with the BASIC Stamp, the TCS230's output frequency can be read using the St Staamp' p'ss COUNT st staate teme men nt, as sh sho own in the example code on the front side of this shee sh eet. t. In th this is ex exam ampl ple, e, S0 an and d S1 we were re bo both th Additionally, Additional ly, the sensor module can operate set "high", enabling the TCS230's fastest using only the outside row of pins on J2 output rate. However, this rate can be as (Vdd, S3, S2, Out, Vss ). When the inside row much as 600KHz or more at maximum light is lef leftt flo floati ating, ng, /OE is ass assert erted ed lo low, w, al along ong wit with h intensity, which is faster than the BS2 (being Sign Si gnal al De Defa faul ultt BS BS2 2 Pi Pin n Opti Op tion on float at hig high h bu butt eac each h ca can n be /LED. S0 and S1 flo EN P1 limited limi ted to 120K 120KHz) Hz) can coun count. t. So S0 and S1 strapped low individually at J2. This is to A0 P2 need to be set according to the maximum facilitate operation with the minimum S0 P3 N/C expected light intensity from the subjects required set of signals and to allow S1 P4 N/C being examined. connection via a flat flex cable (e.g. DigiKey S2 P5 part number A9BBG-0506 A9BBG-0506F-ND). F-ND). In order to save power — especially when S3 P6 battery-operated — you can operate the /LED P7 N/C Optical Data LEDs only when reading color. This works OUT P8 P11 because the LEDs come on almost instantly, With the supplied 5.3mm lens and a subject The "options" listed above are available at J2 having no warm-up time as incandescent distance of 1" (25mm) from the front surface and J3 on the AppMod board. By cutting the lamps do. This can be accomplished by of the circuit board, the sensor module will trac tr aces es at J2 fo forr S0 an and d S1, th thes esee tw two o si sign gnal alss lea eav vin ing g /LED low and st stro rob bin ing g EN hi high gh,, or "see" a square area roughly 5/32" (4mm) on a will default "high", or they may be strapped to just by strobing /LED low when EN is high. side. This means that any color variation different levels at J1 on the sensor module. within an area that size will be averaged by Additionall information and software Additiona Cutt Cu ttin ing g th thee /LED tr trac acee wi will ll de defa faul ultt th thee LE LEDs Ds the TCS230. examples, as well as a PC host program can "on" whenever the sensor module is selected. be found on both the TAOS and Parallax Cutti Cu tting ng the these se traces traces wil willl fre freee up P3, P4, and The spectral response of any color sensor websites. U1
Vdd
NC7WZ132
RP1
RP2
4 X 33K
4 X 33K
C1 EN 1
Vdd 8
U2
.1uF
TSC230 2
7
3
6
4
5
EN A0
Vss R4
R2
47K
1
S0
S3
8
2
S1
S2
7
3
/OE
Out
6
4
Vss
Vdd
5
47K
/OE0
/OE1
U1
C2
2 X NSPW500 NSPW500BS BS
TPS76301
0.1uF
LED1 1
IN
2
Gnd
Out
LED2
5
U3 74AHC1G02
R1
R3
150
150 J1 1
1
J4
Vss
J2
/ OE OE 1
Vss P0
P1
S1
S2
P2
P3
S0
S3
P4
P5
V dd dd
P6
P7
/ LE LE D
P8
J5
0 Vss
/ OE OE 0
O ut ut
S1
S2
S0
S3
/ LE LE D
J3
4
2
Vss
O ut ut
S0
P 11
P12
P 13
P14
P 15
Vdd
Vi n
3
En
FB
4
3
S1
R3
/OE
10K /LED
P9
P 10 10
R2 10K
5
J1
J2 Vss
Vdd S3 S2 Out
V dd dd
Figure 4. AppMod Adapter Schematic.
C4
C3
10uF
0.1uF
Figure 5. Sensor Module Schematic.
Texas Advanced Optoelectronic Solutions, 800 Jupiter Road, Suite 205, Plano, TX 75074, U.S.A. Parallax, Inc., 599 Menlo Drive, Suite 100, Rocklin, CA 95765, U.S.A. MADE AND PRINTED IN U.S.A. (Rev. 2003.02.26)
C1
R1
R4
10uF
39
39