MD_TCS230 Color Sensor Arduino Library  1.2
Library to control TCS230 Color Sensor
Calibration

Calibrating the Sensor

The output is a square wave (50% duty cycle) with frequency (fo) directly proportional to light intensity:

TCS230_Eq1.png

where

  • fo is the output frequency
  • fd is the output frequency for dark condition (when Ee = 0)
  • Re is the device responsivity for a given wavelength of light in kHz/(mW/cm2)
  • Ee is the incident irradiance in mW/cm2.

fd is an output frequency resulting from leakage currents. As shown in the equation above, this frequency represents a light-independent term in the total output frequency fo. At very low light levels (dark colors), this dark frequency can be a significant portion of fo. The dark frequency is also temperature dependent.

As fo is directly proportional to frequency, it is possible to map between the frequency and RGB color value (0-255 for each of R, G and B) using linear interpolation.

Two points on the RGB line are well determined – pure Black (RGB 0, 0, 0) and pure White (255, 255, 255). The values returned by the sensor can be read using easily obtainable color swatches:

  • A black color card gives us the dark condition constant fd. This is the origin (zero value) for the RGB straight line conversion.
  • A white color card gives us the extreme RGB point fw, also known as white balance. Knowing fd, this value can be used to scale all intermediate frequencies to a corresponding RGB value.

The proportional relationship is expressed by the standard straight line equation y = mx + b where

  • y is the reading obtained (in our case fo)
  • x is the normalized RGB value
  • b is the value of y when x is 0 (in our case fd)
  • m is the slope, or proportionality constant, of the line (in our case [fw - fd]/255.

The resulting equation is

TCS230_Eq2.png

or, rearranging to give us the desired RGB value

TCS230_Eq3.png

References

Yurish, Sergey Y 2005, ‘Intelligent Opto Sensors Interfacing Based on Universal Frequency-to-Digital Converter’, Sensors & Transducers Magazine (S&T e-Digest), Vol.56, Issue 6, June 2005, pp.326-334.

TAOS Inc 2003, ‘TCS230 Programmable Color Light-to-Frequency Converter’, Product Datasheet TAOS046 – February 2003.

Poynton, Charles 2005, ‘Sensing Color with the TAOS TCS230’, TAOS Inc., 2005-05-17.