Warning: Declaration of Db::query($query) should be compatible with mysqli::query($query, $resultmode = NULL) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 29

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Warning: Cannot modify header information - headers already sent by (output started at /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php:0) in /var/www/u1300519/data/www/acoptex.com/_config/config.php on line 168

Warning: session_start(): Cannot start session when headers already sent in /var/www/u1300519/data/www/acoptex.com/_config/config.php on line 169

Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 92

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 92

Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64
jobs.html_title
1

member

Easy Basics: Project 078a TCS230 or TCS3200 color sensor

of Lex C. in UNO

Basics: Project 078a

Project name: TCS230/TCS3200 color sensor

Tags: Arduino, Arduino Uno, TCS230, TCS3200 color sensor, programmable color light-to-frequency converter, GY 31, color sensor module, MANOLINS, TCS3200D, Color Recognition Sensor Detector Board, RGB Module for Arduino,

Attachments: sketch1 or sketch2

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1.Arduino Uno R3 (you can also use the other version of Arduino)

2. Arduino IDE ( you can download it from here  )

4.Jumper cables F-M, M-M

5. TCS230 or TCS3200 color sensor 1 pc

6. Breadboard 1 pc

General

We will learn how to connect TCS230 or TCS3200 color sensor to Arduino board and use it.

We are going to use TCS3200 color sensor in this project.

Our sensor uses a TAOS TCS3200 RGB sensor chip to detect color and contains four white LEDs that light up the object in front of it.

Understanding the TCS230 or TCS3200 color sensor

The TCS3200 and TCS3210 programmable colorlight-to-frequency converters that combine configurable silicon photodiodes and a current-to-frequencyconverter on a single monolithic CMOS integrated circuit. The output is a square wave(50% duty cycle) with frequency directly proportional to light intensity (irradiance).The full-scale output frequency can be scaled by one of three preset values via two control input pins. Digital inputs and digital output allow direct interface to a microcontroller or other logic circuitry. Output enable (OE) places the output in the high-impedance state for multiple-unit sharing of a microcontroller input line. In the TCS3200, the light-to-frequency converter reads an 8 x 8 array of photodiodes. Sixteen photodiodes haveblue filters, 16 photodiodes have green filters, 16 photodiodes have red filters, and 16 photodiodes are clear with no filters. In the TCS3210, the light-to-frequency converter reads a 4 x 6 array of photodiodes. Six photodiodes have bluefilters, 6 photodiodes have green filters, 6 photodiodes have red filters, and 6 photodiodes are clear with nofilters.The four types (colors) of photodiodes are interdigitated to minimize the effect of non-uniformity of incidentirradiance. All photodiodes of the same color are connected in parallel. Pins S2 and S3 are used to select whichgroup of photodiodes (red, green, blue, clear) are active. Photodiodes are 110 μm x 110 μm in size and are on 134-μm centers.

The TCS230 programmable color light-to-frequency converter combines configurable silicon photodiodes and a current-to-frequency converter on single monolithic CMOS integrated circuit. The output is a square wave (50% duty cycle) with frequency directly proportional to light intensity (irradiance). The full-scale output frequency can be scaled by one of three preset values via two control input pins. Digital inputs and digital output allow direct interface to a microcontroller or other logic circuitry. Output enable (OE) places the output in the high-impedance state for multiple-unit sharing of a microcontroller input line. The light-to-frequency converter reads an 8 x 8 array of photodiodes. Sixteen photodiodes have blue filters, 16 photodiodes have green filters, 16 photodiodes have red filters, and 16 photodiodes are clear with no filters. The four types (colors) of photodiodes are interdigitated to minimize the effect of non-uniformity of incident irradiance. All 16 photodiodes of the same color are connected in parallel and which type of photodiode the device uses during operation is pin-selectable. Photodiodes are 120 µm x 120 µm in size and are on 144-µm centers.

  • High-resolution conversion of light intensity to frequency
  • Programmable color and full-scale output frequency
  • Communicates directly with a microcontroller
  • Working voltage: 2.7V~5.5V
  • Working current: 1.4mA
  • Output frequency: 10KHz~12KHz
  • Duty cycle: 50%
  • Detection state: Static detecting
  • The best detection distance: 10mm
  • Working temperature: -40'C~85'C

Functional Block Diagram


Output-frequency scaling is controlled by two logic inputs, S0 and S1. The internal light-to-frequency converter generates a fixed-pulsewidth pulse train. Scaling is accomplished by internally connecting the pulse-train output of the converter to a series of frequency dividers.

Divided outputs are 50%-duty cycle square waves with relative frequency values of 100%, 20%, and 2%. Because division of the output frequency is accomplished by counting pulses of the principal internal frequency, the final output period represents an average of the multiple periods of the principle frequency.

The output-scaling counter registers are cleared upon the next pulse of the principal frequency after any transition of the S0, S1, S2, S3, and OE lines. The output goes high upon the next subsequent pulse of the principal frequency, beginning a new valid period. This minimizes the time delay between a change on the input lines and the resulting new output period. The response time to an input programming change or to an irradiance step change is one period of new frequency plus 1 μs. The scaled output changes both the full-scale frequency and the dark frequency by the selected scale factor.

The frequency-scaling function allows the output range to be optimized for a variety of measurement techniques. The scaled-down outputs may be used where only a slower frequency counter is available, such as low-cost microcontroller, or where period measurement techniques are used (from datasheet).

TCS3200 Sensor Pinout

You can see the different filters when you check it closer. The pins S0 and S1 are Output frequency scaling selection inputs, pin number 3 is Output Enable pin and also it is a active low pin normally connected with ground supply it Enable for fo.  The power supply requirement for this sensor is from 2.5V to 5.5V and it is applied through pin 4 (gnd), and pin 5 (Vdd). The Output frequency (fo) taken from pin 6, S2 and S3 are responsible for Photodiode type selection inputs.

  • Filter selection. To select the color read by the photodiode, you use the control pins S2 and S3. As the photodiodes are connected in parallel, setting the S2 and S3 LOW and HIGH in different combinations allows you to select different photodidodes. 
  • Frequency scaling. Pins S0 and S1 are used for scaling the output frequency. It can be scaled to the following preset values: 100%, 20% or 2%. Scaling the output frequency is useful to optimize the sensor readings for various frequency counters or microcontrollers. 

Take a look at the table below:

For the Arduino, it is common to use a frequency scaling of 20%. So, you set the S0 pin to HIGH and the S1 pin to LOW.

TCS 3200 color Sensor Module Circuit diagram

This Sensor contains photodiode array hence it needs light source to detect colors, so that four white LEDs are connected around the sensor. The circuit diagram represents typical TCS3200 module, it can be modified depends on requirements.

This response curve represents wavelength of color in horizontal axis and Relative responsivity in vertical axis.

Programmable color light-to-frequency converter suitable for colorimeter measurement range: color printing, medical diagnosis, computer color monitor calibration and the process control and color match of the paint, textile, cosmetic and printing material.

You can check the TCS230 sensor datasheet here.

You can check the TCS3200 sensor datasheet here.

How does the TCS3200 sensor work?

The TCS3200 has an array of photodiodes with 4 different filters. A photodiode is simply a semiconductor device that converts light into current. The sensor has:

  • 16 photodiodes with red filter – sensitive to red wavelength
  • 16 photodiodes with green filter – sensitive to green wavelength
  • 16 photodiodes with blue filter – sensitive to blue wavelength
  • 16 photodiodes without filter

By selectively choosing the photodiode filter’s readings, you’re able to detect the intensity of the different colors. The sensor has a current-to-frequency converter that converts the photodiodes’ readings into a square wave with a frequency that is proportional to the light intensity of the chosen color. This frequency is then, read by the Arduino.

Signals and connections of the TCS230 or TCS3200 color sensor

VCC - power pin +5V DC

GND - ground pin

LED - to turn on the 4 supporting LEDs

OUT - Output frequency 

S0, S1 - Output frequency scaling selection inputs

S2, S3 - Photodiode type selection inputs

OE - Enable for output frequency (active low)

Wiring

The following picture shows the needed connections with the Arduino Uno.

 

S0: digital pin 4
S1: digital pin 5
VCC: 5V
S3: digital pin 6
S4: digital pin 7
OUT: digital pin 8

TCS3200 color sensor  |  Arduino Uno  

S0                                digital pin 4

S1                                digital pin 5

VCC                              5V pin

S3                                digital pin 6

S4                                digital pin 7

OUT                              digital pin 8

Step by Step instruction

  1. Do wiring.
  2. Open Arduino IDE.
  3. Plug your Adruino Uno board into your PC and select the correct board and com port
  4. Open sketch1, verify and upload it to your Adruino Uno.
  5. Open up serial monitor and set your baud to 115200 baud
  6. Place a blue object in front of the sensor at different distances. You should save two measurements: when the object is placed far from the sensor and when the object is close to it.
  7. Check the values displayed on the serial monitor. The blue frequency (B) should be the lowest compared to the red (R) and green (G) frequency readings. You can use frequency values in your code which you get for your specific object with your own color sensor. Just save your upper and bottom frequency limits for the blue color as we need them later.
  8. Repeat this process with a green and red objects and write down the upper and bottom frequency limits for each color.
  9. Open sketch2 and modify.
  10. With sketch1 we have min/max values for blue color - 52/210. Frequency 52 corresponds to 255 (in RGB) and frequency 210 to 0 (in RGB). We will use map() function to distinguish between different colors. In the map() function you need to replace XX parameters with your own values.
  11. Verify and upload sketch2 to your Adruino Uno.
  12. Open up serial monitor and set your baud to 115200 baud.
  13. To distinguish between different colors we have three conditions: When the R is the maximum value (in RGB parameters) we know we have a red object;when G is the maximum value, we know we have a green object; when B is the maximum value, we know we have a blue object.
  14. If we place something in front of the sensor it will print in your serial monitor the color detected: red, green or blue. 

Code

1. Sketch1. Reading and displaying the output frequency on the serial monitor. 

2. Sketch2. Distinguish between different colors. Your color sensor can also detect other colors with more if statements.

Summary

We learnt how to connect TCS230 or TCS3200 color sensor to Arduino board and use it.

Libraries:

  • No libraries required

Sketch:

  • See attachment on the begining of this project


Other projects of Lex C.

jobs.published_at
jobs.viewed