This is only a preview of the January 2025 issue of Silicon Chip. You can view 38 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Digital Capacitance Meter":
Items relevant to "Compact HiFi Headphone Amp":
Articles in this series:
Items relevant to "Gesture-controlled USB lamp":
Items relevant to "BIG LED clock":
Items relevant to "40A Current Probe":
Items relevant to "Battery-Powered Model Train":
Items relevant to "TCS230 Colour Sensor":
Purchase a printed copy of this issue for $13.00. |
Using Electronic Modules with Jim Rowe
TCS230-based
Colour Sensor Module
This interesting module can sense the colour components of any object or light
source in front of it. It does this using an array of 64 tiny photodiodes, and it
has four white LEDs that can illuminate a surface or object. It is compatible with
almost any microcontroller, including Arduinos.
T
hose 64 photodiodes are split
into four groups of 16: one group
to detect red light, one for green, a third
to detect blue, and the fourth to detect
white light. As you can see from the
photos, it is pretty tiny at just 33 × 33
× 30mm. That last depth dimension
includes the four LEDs at the front
and the two 5-pin headers at the rear.
The array of 64 photodiodes it uses
to detect colours are all extremely
small, all inside a single SOIC-8 SMD
device with a transparent top. It is
mounted in the centre of the module’s
PCB and surrounded by a small black
plastic ‘shroud’.
The SOIC-8 device concerned is
the TCS230, made by US firm Texas
Advanced Optoelectronic Solutions
Inc (aka TAOS). They describe it as
a “programmable colour light-to-
frequency converter”.
To give you a better idea of the size
of those 64 photodiodes, the TAOS
data sheet says that they are each only
120μm x 120μm (micrometres) in size
and arranged on 144μm centres.
So the total array of 8×8 photodiodes
measures only about 1.3mm square.
That’s pretty impressive, considering
that 48 of the diodes have their own
colour filter above them!
Inside the TCS230
Fig.1 shows what is inside the
TCS230 sensor chip. On the left, you
can see the 8×8 array of photodiodes,
with the 16 diodes for each colour
arranged in four rows of four and the
four ‘banks’ intertwined so they each
get a ‘fair share’ of the light reaching
the array. Note that the 16 photodiodes in each bank are all connected
in parallel.
The logic block shown to the right
of the array allows you to select which
colour bank you want using the control
inputs S2 and S3 (pins 7 and 8). The
logic levels used to do this are shown
in the table at upper right; for example, with S2 and S3 both low, the red
photodiode bank is selected, while
if they are both high, that selects the
green bank.
The bank select block feeds the
output from the selected photodiode
bank into the current-to-frequency
converter block to its right. It converts
the current from the selected photodiode bank into a square wave with a
frequency directly proportional to the
current level.
The current-to-frequency scaling is
programmable using control inputs S0
and S1 (pins 1 and 2). These work as
shown in the table at the lower right
of Fig.1. If S0 and S1 are both high,
the scaling is 100%, but if S1 is taken
low while S0 remains high, the scaling drops to 20% and so on. If they are
both taken low, the chip is powered
down and there is no output.
Fig.1: a block diagram of the TCS230 sensor chip. Inputs S2 & S3 can be driven low (“L”) or high (“H”) to select the a
subset of the photodiodes (which selects what colour to detect), while S0 & S1 change the current-to-frequency scaling.
80
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
Fig.2: the spectral
response curves
for each of the
photodiode
colours from the
TCS230. All of
the curves have
been normalised
such that the
‘clear’ bank of
photodiodes
has an output
frequency scaling
of 100%.
The ‘full-scale’ frequency with
S0 and S1 both high is around 500600kHz, while if S0 is high but S1 is
low, the full-scale frequency drops to
100-120kHz. If S0 is low while S1 is
high, the full-scale frequency drops to
10-12kHz. The scaled-down frequency
ranges allow the device to be used with
lower-cost microcontrollers or applications where period measurement is
more appropriate.
It’s also possible to disable the output from the TCS230 device using the
OE input (pin 3). If pulled high, this
pin turns off the chip’s output at pin
6, while if it’s taken low (to ground),
the chip works normally.
Response curves
The spectral response curves of the
TCS230 are shown in Fig.2. All four
curves are ‘normalised’ to a scaling
where the response of the ‘clear’ bank
of photodiodes is set to 1.0 (or 100%) at
a wavelength of 680nm (nanometres).
The clear bank (black plot) has a
broad response curve covering the
full range of wavelengths from 300nm
to 1100nm, while the red bank (red
plot) is similar but narrower, mainly
covering the range from 570nm to
1100nm.
The plots for the green bank (green
plot) and blue bank (blue plot) are
a bit different, consisting of ‘twin
peaks’ above and below the 680nm
wavelength of the clear and red bank
peaks. Their peaks are also significantly lower than the clear and red
bank peaks.
Visible light is generally considered
to cover wavelengths from 380nm
to 700nm. Ultraviolet light is below
380nm, while infrared is above 700nm.
As you can see, the sensor responds
quite strongly to near-infrared light on
all four banks.
Therefore, for the best accuracy
with visible light wavelengths, an
infrared filter should be placed in
front of it. That would also cut out
the secondary blue peak entirely, and
most of the secondary green peak,
so they would only respond to the
‘wanted’ ranges of 380-570nm and
450-620nm, respectively.
The shroud around the sensor on
the module is threaded; one possible
Fig.3: the TCS230 module is a simple design with few components. Transistor Q1
controls four white LEDs, which are used to illuminate the object being measured.
siliconchip.com.au
Australia's electronics magazine
reason for that is to allow an IR filter
(and/or a lens) to be screwed in.
The full module circuit
The full circuit of the TCS230-based
colour sensing module is shown in
Fig.3. As you can see, there’s not much
in it apart from the TCS230 chip and
the four white LEDs (LED1-LED4) that
can be used to illuminate objects that
do not produce light themselves.
Connections to the module are via
two 5-pin SIL headers, CON1 and
CON2. Both headers provide pins for
supply voltage Vcc (nominally +5V)
and ground, making it easy to connect
more than one module to a microcontroller. CON1 provides pins for connections to programming inputs S0
and S1, plus another pin to allow control of LEDs 1-4.
On the other side, CON2 provides
pins for controlling inputs S2 and S3,
plus the frequency output from the
TCS230.
Programming inputs S0 and S1 are
provided with 10kW pullup resistors
to the Vcc line, so if no external connections are made to these pins, the
TCS230 will operate at the 100% frequency scaling level by default. The
S2 and S3 inputs (via CON2) have no
pullup resistors because these inputs
must always be driven to select a
photodiode bank.
January 2025 81
Transistor Q1 controls the four
white LEDs (LED1-4) connected
between its collector and the Vcc line
with series 330W resistors. The base of
Q1 is connected to the LED input pin
of CON1 and the Vcc line via another
330W resistor, so the transistor will
power the LEDs by default, unless the
LED pin of CON1 is pulled to ground.
That gives you the option of leaving the LED pin unconnected for the
LEDs to be permanently lit, connecting it permanently to a GND pin to
disable them entirely, connecting a
switch between the LED pin and GND
to control them manually, or driving
the LED pin from the digital output of
a microcontroller, where a high level
will switch them on and a low level
will switch them off.
The only other things to note about
the module circuit are the 330W
resistor in series with the OUT pin
of CON2, presumably to protect the
TCS230 from damage due to excessive load current, and the 10μF and
100nF bypass capacitors between the
Vcc and ground lines to stabilise the
supply voltage.
Connecting it to an Arduino
Fig.4 shows how easily the module
can be connected to an Arduino Uno.
It should be just as straightforward to
connect it to any other versions of the
Arduino, including the new Uno R4
Minima we reviewed recently, or to
many other microcontrollers such as
the Micromite or Maximite.
All you need to do is connect
the module’s Vcc and GND pins to
the +5V and GND pins of the MCU
(microcontroller unit), connect its
S0-S3 programming inputs to four of
the MCU’s digital outputs (IO4-IO7
here) and connect its OUT pin to one
of the MCU’s digital inputs (IO8 here).
Then, if you want to turn the LEDs
on and off, you can connect a switch
as shown. It will leave the module’s
LED pin at ~0.6V when the switch is
open (LEDs on) or pull it to GND when
closed (LEDs off).
What about software?
Regarding the software needed to
use the TCS230 module with an Arduino or any other MCU, Jaycar provides
a listing of a simple sketch to put their
XC3708 module through its paces with
an Arduino Uno or similar. It is worth
a try, but note that their sketch expects
different connections between the
module and the Arduino than those
shown in Fig.4.
It also does not drive the module’s
S0, S1 or LED pins, so the sketch
allows the TCS230 to run at 100% frequency scaling and assumes that you
will have the LEDs permanently on/off
or controlled manually with a switch.
I found a couple of informative tutorials on the internet on using a TCS230
module with an Arduino, and both
provided suitable sketches:
• How To Mechatronics – https://
siliconchip.au/link/abre
• Random Nerd Tutorials – http://
siliconchip.au/link/abrf
The second of these sites provided
the listing of a simple sketch to put
the TCS230 module through its paces,
written by a chap called Rui Santos.
After checking that it expected the
The TCS230 is primarily used to
detect colours in the RGB spectrum,
there’s also the similar TCS3200
which works over a wider range.
module connections shown in Fig.4, I
copied and pasted that into the Arduino IDE, verified and compiled the
sketch and finally uploaded it to my
Arduino Uno.
I then held pieces of red, green, blue
and white card in front of the module
and checked the results in the IDE’s
Serial Monitor window. I found the
output a bit puzzling, so I decided to
analyse what was going on in Mr Santos’s sketch.
I found that in the sketch, he was
using the Arduino language function
pulseIn() to measure the frequency of
the TCS230’s output. When I looked
up that function, I discovered it actually measures the duration (length)
of pulses in microseconds, not their
frequency.
After this discovery, I decided to
adapt Mr Santos’s sketch so that it
would produce the TCS230 output
Fig.4: the wiring diagram
for the TCS230 module to
an Arduino Uno or similar.
A switch can be connected
to the circuit to allow the
four LEDs on the module to
be switched on or off.
82
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
A close-up of
the TCS230
colour sensor.
While not very
apparent on
this photo, if
you look at the
sensor with a
microscope,
you should be
able to see the
photodiode
array. A better
photo can
be seen at:
siliconchip.au/
link/abrg
frequency rather than the pulse duration. And after a bit of trial and error,
I came up with a sketch which did
just that.
A screen grab of the SerialMonitor
window when this sketch was running
is shown in Screen 1, with annotations
indicating which card was in front of
the TCS230 module when the measurements were taken.
As you can see, the colour frequencies that match the card are generally
higher than the others. With the green
card, the blue values were almost as
high as green, suggesting it was more
of an aquamarine (blue-green) colour
than a pure green. When any of the red,
green or blue cards were sensed, the
clear figure was roughly equal to the
sum of the other three figures.
Of course, this sketch is pretty basic.
If you want to use the TCS230 module
for some serious work – identifying
specific colours, for example – you
would need to improve on it considerably. But you should find this
sketch a good place to start. My sketch
is called “TCS230_coloursensormodule_checking_sketch.ino”, and you
can download it from siliconchip.com.
au/Shop/6/324
Where to buy it
The TCS230-based colour sensing
module shown in the photos is currently available from several suppliers, including Jaycar Electronics (Cat
XC3708), for $19.95 plus delivery.
A very similar module, the DFRobot
SEN0101, is also available from suppliers such as DigiKey, Mouser, element14 and RS at prices ranging from
$13.56 to $14.19. But note that the
SEN0101 module lacks the cylindrical black plastic ‘shroud’ around the
SC
TCS230 sensing device.
Output from our sketch adapted from the one by Rui Santos
RED
GREEN
BLUE
WHITE
15:33:39.996 -> Red = 1228 Green = 377 Blue = 484 Clear = 1945
15:33:40.371 ->
15:33:50.353 -> Red = 1213 Green = 377 Blue = 485 Clear = 1901
15:33:50.681 ->
15:34:00.710 -> Red = 447 Green = 729 Blue = 606 Clear = 1736
15:34:01.038 ->
15:34:11.020 -> Red = 447 Green = 729 Blue = 609 Clear = 1773
15:34:11.395 ->
15:34:21.377 -> Red = 437 Green = 1002 Blue = 1683 Clear = 3086
15:34:21.705 ->
15:34:31.687 -> Red = 436 Green = 1002 Blue = 1683 Clear = 3086
15:34:32.062 ->
15:34:42.044 -> Red = 2074 Green = 2192 Blue = 2762 Clear = 6944
15:34:42.372 ->
15:34:52.354 -> Red = 2074 Green = 2192 Blue = 2762 Clear = 6944
15:34:52.682 ->
Screen 1: the sketch produces counts for each photodiode bank that are
proportional to the frequency and thus light intensity.
siliconchip.com.au
Australia's electronics magazine
Ideal Bridge Rectifiers
Choose from six Ideal Diode Bridge
Rectifier kits to build: siliconchip.
com.au/Shop/?article=16043
28mm spade (SC6850, $30)
Compatible with KBPC3504
10A continuous (20A peak),
72V
Connectors: 6.3mm spade
lugs, 18mm tall
IC1 package: MSOP-12
(SMD)
Mosfets: TK6R9P08QM,RQ (DPAK)
21mm square pin (SC6851, $30)
Compatible with PB1004
10A continuous (20A peak),
72V
Connectors: solder pins on
a 14mm grid (can be bent
to a 13mm grid)
IC1 package: MSOP-12
Mosfets: TK6R9P08QM,RQ
5mm pitch SIL (SC6852, $30)
Compatible with KBL604
10A continuous (20A peak), 72V
Connectors: solder pins at
5mm pitch
IC1 package: MSOP-12
Mosfets: TK6R9P08QM,RQ
mini SOT-23 (SC6853, $25)
Width of W02/W04
2A continuous, 40V
Connectors: solder
pins 5mm apart
at either end
IC1 package: MSOP-12
Mosfets: SI2318DS-GE3 (SOT-23)
D2PAK standalone (SC6854, $35)
20A continuous, 72V
Connectors: 5mm screw
terminals at each end
IC1 package:
MSOP-12
Mosfets:
IPB057N06NATMA1
(D2PAK)
TO-220 standalone (SC6855, $45)
40A continuous,
72V
Connectors:
6.3mm spade lugs,
18mm tall
IC1 package: DIP-8
Mosfets:
TK5R3E08QM,S1X
(TO-220)
See our article
in the December
2023 issue for more details:
siliconchip.au/Article/16043
January 2025 83
|