Summary of Interfacing TCS3200 Colour Sensor with AVR ATmega32
This article details a project to detect object colors using the TCS3200 color sensor and an AVR ATmega32 microcontroller. The system utilizes the sensor's photodiode array with RGB filters to convert light intensity into frequency, which is measured via Timer1. A custom PCB module includes four white LEDs for illumination, controlled by specific MCU pins to ensure accurate readings at a 1-inch distance.
Parts used in the Color Detection Project:
- TCS3200 Colour Light to Frequency Converter Chip
- AVR ATmega32 Microcontroller
- Photodiode Array (8x8 matrix)
- RED Filter Sensors
- GREEN Filter Sensors
- BLUE Filter Sensors
- CLEAR Filter Sensors
- Four White LEDs
- LED Control Circuit
- PCB Module with 0.1inch male headers
- Timer1 (16-bit timer)
Detecting colour of an object can be an interesting and useful electronic application. It can be realized using a colour sensor like TCS3200 and a general purpose microcontroller like AVR ATmega32.
TCS3200 Colour Light to Frequency Converter Chip
TCS3200 chip is designed to detect the colour of light incident on it. It has an array of photodiode (a matrix of 8×8, so a total 64 sensors). These photodiodes are covered with three type of filters. Sixteen sensor have RED filter over them thus can measure only the component of red in the incident light. Like wise other sixteen have GREEN filter and sixteen have BLUE filter. As you should know that any visible colour can be broken into three primary colours. So these three type of filtered sensors helps measure the weightage of each of primary colours in incident light. The rest 16 sensors have clear filter.
TCS3200 converts the intensity of incident radiation into frequency. The output waveform is a 50% duty cycle square wave. You can use the timer of a MCU to measure period of pulse and thus get the frequency.
The output of TCS3200 is available in single line. So you would ask how we get the intensity of RED,GREEN, BLUE and CLEAR channels? Well it has two inputs S2 and S3 that is used to select the sensor whose output need to be made available on the out line.
|
S2
|
S3
|
|
| RED |
L
|
L
|
| GREEN |
H
|
H
|
| BLUE |
L
|
H
|
| CLEAR |
H
|
L
|
So we select a channel either RED, GREEN, BLUE or CLEAR and then do the measurement of the output pulse width to get that channel’s intensity. In our library we have made these four functions to do this task.
void TCSSelectRed()
{
TCSS2Low();
TCSS3Low();
}
void TCSSelectGreen()
{
TCSS2High();
TCSS3High();
}
void TCSSelectBlue()
{ TCSS2Low();
TCSS3High();
}
void TCSSelectClear()
{
TCSS2High();
TCSS3Low();
}
The functions TCSS2High(), TCSS2Low() etc are low level functions that controls the i/o lines connected to S2 and S3 lines.
TCS3200 Module
Since TCS3200 chip is a small SMD chip and is tough to prototype designs using the surface mount chip. Thus we have made a small module that has the TCS3200 chip, four white LEDs, LED control circuit and few other basic components on a PCB. The module has the connection all the line on 0.1inch male header. This makes it easy to connect with microcontroller boards. The white LEDs throws light on the object that is placed in front of the sensor. For best performance the object should be placed 1inch away from the LEDs such that the beam from all four LEDs converge at a single point (and do not make four distinct light spots on the object). One i/o pin of MCU can be used to switch on and off the LED.
In our library we have made two functions to control the TCS3200 module’s LEDs.
Fig. TCS3200 Module.
Measuring TCS3200’s Output
For measuring the output frequency of the TCS3200 we have used TIMER1 of AVR. Which is 16 bit timer. We have clocked the TIMER1 using same frequency as the CPU that is 16MHz without any division.
The function which is used to measure the frequency of TCS3200 is named TCSMeasure() The implementation of this function is given below.
For more detail: Interfacing TCS3200 Colour Sensor with AVR ATmega32
- How does the TCS3200 chip detect color?
The chip uses a matrix of 64 photodiodes covered with RED, GREEN, BLUE, and CLEAR filters to measure the weightage of primary colors in incident light. - Can the TCS3200 output be measured directly without a microcontroller?
No, the article states the output waveform is a square wave whose period must be measured using a microcontroller timer like TIMER1. - What are the functions used to select specific color channels?
The library provides TCSSelectRed, TCSSelectGreen, TCSSelectBlue, and TCSSelectClear functions to control S2 and S3 inputs. - Why is a custom module recommended over the raw TCS3200 chip?
A module is recommended because the raw TCS3200 is a small SMD chip that is tough to prototype designs with on surface mount. - What is the optimal distance for placing an object from the sensor?
For best performance, the object should be placed 1 inch away so that the beams from all four LEDs converge at a single point. - How are the LEDs on the module controlled?
An i/o pin of the MCU is used to switch the LEDs on and off using the TCSLEDOn and TCSLEDOff functions. - Which timer is used to measure the output frequency?
Timer1 of the AVR microcontroller is used, clocked at 16MHz without any division. - What type of waveform does the TCS3200 output?
The output is a 50% duty cycle square wave representing the converted frequency of incident radiation.


