ColorPAL documentation

© Parallax, Inc. • ColorPAL (2009.06.15) Page 3 of 12
The sensor outputs a voltage proportional to
all
the light that it sees, weighted by the above curve.
Therefore, when a subject is illuminated with a red LED only, it will respond with a voltage proportional
to the red component of the subject’s color, and similarly with blue and green. When there is ambient
light mixed in with the LED’s illumination, its effect can be eliminated by sampling first without any LEDs
turned on, then subtracting this reading, in turn, from each of the red, green, and blue components. This
reference measurement should be taken before each color measurement to eliminate any effects from
varying ambient conditions. In the paragraphs that follow, it will be assumed that an ambient reference is
taken and subtracted from each measurement discussed.
Because the LED and sensor sit next to each other on the ColorPAL’s circuit board, and because the
plastic snorkel itself reflects some light back (primarily from its threads), the light response from a
completely black subject will be non-zero. For this reason, the black response for each color component
has to be determined experimentally, so that it, too, can be subtracted from the overall response. The
three components thus measured (with an ambient reference subtracted), Kr, Kg, and Kb, are known as
the “black reference”. A black reference is typically obtained only once before each measurement session.
The TSL13T light sensor does not respond equally to the red, green, and blue LEDs, and those LEDs
don’t put out equal amounts of light at the red, green, and blue wavelengths. So, in addition to the
ambient reference and black reference, it is also necessary to take a “white reference”, wherein the
ColorPAL is presented with a completely white surface. Again, after subtracting the ambient lighting, the
red, green, and blue components of this reference will be called, Wr, Wg, and Wb.
Now we have a way of determining a subject’s actual color as a percentage of the difference between the
white and black references. This percentage can be expressed as a value between 0 (0%) and 255
(100%), as follows for red, say:
Cr = 255 · (Ur – Kr) / (Wr – Kr) , where
Ur is the uncorrected (except for ambient) reading, and Cr is the corrected reading.
Because the ColorPAL uses an integrated RGB LED to emit the sampling colors, it is also capable of
generating a wide range of colors in the visible spectrum by means of its onboard microcontroller, which
pulse-width modulates the LED segments to produce 24-bit RGB color.
Comparison to TCS230-DB
The ColorPAL and TCS230-DB (Parallax #28302) are both capable of detecting colors in the RGB color
space. The ColorPAL is designed as an inexpensive sensor for hobby and educational use, whereas the
TCS230-DB also finds use in professional and OEM color detection applications. The following chart will
help to illustrate the similarities and differences between the two devices, as an aid to selecting the
proper one for a given application. The more stars in a given column, the more applicable or desirable
the feature will be.