0

TCS34725 Efficiency compensation
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

TCS34725 Efficiency compensation

by Beatrice94 on Fri Sep 14, 2018 9:56 am

Hi all,

I am performing some color measurments involving analizing reflected light from a sample. The light is analyzed by Adafruit TCS34275 sensor and the light is provided by a single through hole NeoPixel.
I have two major questions I could not solve by googling around:

1) How do I compensate for the TCS photodiodes efficiencies to different wavelengths? The datasheet is being pretty obscure about how the measurements can be translated. I understand that where the Clear channel has 100% efficiency (@755nm), the Red channel has say, 65% efficiency, to get the true Red light reading I should multiply the Red reading by 100 and divide by 65. Same goes with G and B
But what if the NeoPixel Illuminates with light ar 625nm (eg Red)? Then the clear channel has an efficiency of about 90% and the red one 80%, how do I manage to get the true reading?

2) I know (sort of) know the wavelegths corresponding to R, G, B components of the NeoPixel, but what if I write (127, 0, 127), that is magenta? (half red and half blue) How do I find out the wavelength for that?

Can anybody point me in the right direction to solve these? Any suggestion will be helpful!
Thanks a lot!

Beatrice94
 
Posts: 18
Joined: Wed Jun 06, 2018 7:00 am

Re: TCS34725 Efficiency compensation

by adafruit_support_bill on Fri Sep 14, 2018 10:26 am

It might help if you can explain in more detail what kind of data you are expecting to get from the sensor. Color measurement can be quite complicated since there are many variables.

1) Calculations based on numbers and charts in the spec sheet can easily lead you astray. In addition to the natural variability from device to device, the data in those documents was derived from the manufacturer's test conditions which may-or-may-not be comparable to yours.

A more practical approach is to calibrate your own system based on some standard reference samples. https://learn.adafruit.com/calibrating-sensors

2) Neopixels are not single-wavelength emitters. The wavelength range from the spec sheet is just the peak wavelength for the part of the spectrum emitted by that LED. Combining red and blue does not give you a different wavelength, it just adds the output spectrums of the two leds together. But based on the way our eyes work, we see it as a different color.

see 'metamerism' https://en.wikipedia.org/wiki/Metamerism_(color)

Image

adafruit_support_bill
 
Posts: 70085
Joined: Sat Feb 07, 2009 10:11 am

Re: TCS34725 Efficiency compensation

by Beatrice94 on Fri Sep 14, 2018 10:38 am

Hi,

I'm trying to find a way to assert colors more objectivly than looking at a color panel and choosing the one that bets matches what you think. I though the most objective measure I could do was the relative reflectivity for some visible wavelengths, but I cannot really quantify the amount of light received by the sample over the reflected one. Also, I did not find so far a way to map the components of the R, B, G, readings into something similar to human eye response, e.g. CIE components.
I think maybe for the moment I can just list raw data values a do some kind of cluster analysis on it but I do need to compensate for that.

Beatrice94
 
Posts: 18
Joined: Wed Jun 06, 2018 7:00 am

Re: TCS34725 Efficiency compensation

by adafruit_support_bill on Fri Sep 14, 2018 11:35 am

For that application, I would suggest starting with a different illumination source. The 3 main factors in color measurement are: The spectral distribution of the illumination source, the nature of the pigments in the sample, and the spectral sensitivity of the sensor.

The sample is a given. The sensor you are using is quite good as RGB sensors go. Your weakest link is the light source. RGB LEDs have a horrible spectral distribution for color rendering. The CRI of a typical RGB source is typically in the low 20's - worse than the worst fluorescent bulbs.

An incandescent source is a pretty good approximation of an ideal blackbody emitter with a nice continuous spectrum. While not quite continuous like an incandescent source, there are some high-quality white LEDs that have a fairly smooth spectrum with good color rendering capability.

Given a test fixture with good quality, controlled illumination, you should be able to calibrate your system using reference samples to get good repeatable results.

See this thread for a similar project using this sensor: viewtopic.php?f=19&t=140232&p=693769

adafruit_support_bill
 
Posts: 70085
Joined: Sat Feb 07, 2009 10:11 am

Re: TCS34725 Efficiency compensation

by Beatrice94 on Fri Sep 14, 2018 12:05 pm

The fact is that I do not have reference samples, they do not exist. The point of this work is finding a way to obtain repeatable results from measures on biological samples (that are not reference-able, if you pass me the expression). I did a bit of research on color sensor calibration and I found that is quite is to perform (usually a 2 point) calibration for each R, G, B component by taking some measurements with a colored ligth of known characteristics reflecting on a white surface.
My sample is semi-liquid in a cuvette and stands is a cuvette in an enclosed space to avoid ambient illumination meddling. I though that maybe using the Neopixel I could use the R, G, B illumination to test a cuvette filled with a reflecting white substance (that I still have to think about, but I belive it is just necessary for it to have a higher reflectivity than my sample to avoid saturation and reflects evenly. Maybe I'll use white chalk powder or similar). I'd take a measure with no illumination and a measure with full power for R, G and B light.
Then I use the map() function of the Arduino or something similar to map my readings relative to the true sample using the values I found during calibration. But at this point I do not know what light I should use to illuminate the true sample, would the built in LED in the TCS do?
The reason I do not want to use white light and colored samples is that the reference for the colored samples depends on the procedure used to assess them and I cannot replicate it probably (as the current budjet for this master thesis is my own wallet and the lab has nearly to no instrumentation).
I doesn't have to be perfect (in the sense that perfectly matches the human eye response) but for me it is just necessary to be repeatable at the moment

Beatrice94
 
Posts: 18
Joined: Wed Jun 06, 2018 7:00 am

Re: TCS34725 Efficiency compensation

by adafruit_support_bill on Fri Sep 14, 2018 12:24 pm

I though that maybe using the Neopixel I could use the R, G, B illumination to test a cuvette filled with a reflecting white substance

That fits the definition of a 'reference sample'.

I'd take a measure with no illumination and a measure with full power for R, G and B light.

It is probably better to keep the illumination constant and use a non reflecting substance (carbon black?) for the dark reference.

But at this point I do not know what light I should use to illuminate the true sample, would the built in LED in the TCS do?

It should be the exact same source as used for the calibration. The built-in white LED works pretty well for close-range measurements. Far better than an RGB led.

One thing to watch out for in your setup is specular reflections from the glass surface of the cuvette. Since the on-board LED is mounted very close to the sensor, if the cuvette is oriented parallel to the sensor, you will get some white light reflected directly back which will skew your results. You can avoid that problem by either orienting the cuvette so that it is not parallel to the sensor - or by using a different - off-axis light source.

adafruit_support_bill
 
Posts: 70085
Joined: Sat Feb 07, 2009 10:11 am

Re: TCS34725 Efficiency compensation

by Beatrice94 on Sat Sep 15, 2018 5:01 am

Thanks bunches for the tip about the dark calibration! I figured I may use some standard printer paper as well for the white calibration (it may be more reliable than chalk powder I guess).

A couple more clarifications I need:

1) When you say "cuvette parallel to sensor" you mean that the sensor is upright (ie with the name on top) and the cuvette is standing upright in front of the sensor? In this case, would turning the sensor 90° right suffice to avoid specular reflection?
I could use the NeoPixel positioned at an angle (with (127,127,127) for example) instead?
(I was also planning to take a measure with a cuvette filled with water and do the ratio between that and the true measure to get the cuvette effect out of the way)
Please see the attached drawing, I know it is hard to understand explained this way. Imagine my cuvette is sitting upright in a squared box with sensors (and NeoPixels, if it's the case) attached to the walls looking in. Would it be better to have the TCS and the light source on the same wall by at different heights (B) or placed 90 degrees (A)? Does it change the relative height in this case?

2) So you would suggest only using white light: let me try to list a possibile calibration procedure in this case:
Take measure with white reflective sample and white light. Set the values of R,G,B,C as max. Take the measure with the black non reflective sample, Set the valued to min. Then when I take the true measure I map the R,G,B,C values I obtain in the range defined by light and dark calibration values. In all cases I use the same illumination (say, white light from the on board LED).
Now, my advisor mentioned something about measuring reflected light for the R,G,B colors (ie illuminate the sample with red light and see what reflects back, and so on). I mean, if I was to do that, I would simply use red, green and blue lighting (eg with the NeoPixel positioned in the most suitable way) instead of white and proceed as above for the calibration, doing a separate calibration for each red, green and blue illuminations.

Sorry I'm confusing, but I have had some contradicting requests XP
Attachments
20180915_103543.jpg
20180915_103543.jpg (877.34 KiB) Viewed 93 times

Beatrice94
 
Posts: 18
Joined: Wed Jun 06, 2018 7:00 am

Re: TCS34725 Efficiency compensation

by adafruit_support_bill on Sat Sep 15, 2018 7:30 am

1) When you say "cuvette parallel to sensor" you mean that the sensor is upright (ie with the name on top) and the cuvette is standing upright in front of the sensor?

No. I mean that the plane of the sensor board is parallel to the plane of the front surface of the sensor. This would result in a direct specular reflection from the sensor. led back to the sensor.

The diagram below is a top-down view showing the relative orientations of the sensor, light source and cuvette.

Using the on-board LED, you can avoid the problem by twisting the cuvette so that the front surface is at an angle to the sensor (2nd case in the diagram) . Or you can use an off-axis light source (3rd case).

In any case, the sensor should be located rather close to the cuvette. As with all planar sensors, the sensitivity pattern is Lambertian. So the field of view is quite wide.

So you would suggest only using white light:

Yes. That would be a much better source than a Neopixel. The two-point calibration scheme you outlined is correct. Take RGBC readings with both black and white samples and do a linear interpolation between them. The Arduino map function only works on integer values. But the formula shown here is equivalent: https://learn.adafruit.com/calibrating- ... -do-it-5-3

my advisor mentioned something about measuring reflected light for the R,G,B colors (ie illuminate the sample with red light and see what reflects back, and so on).

You would do that if you were using broad-spectrum sensor (like the 'clear' channel of the TCS34725). But you have a high-quality RGB sensor, so you might as well use it.

In theory, illuminating with a red source and reading with a clear sensor is the same as illuminating with a white source and reading through a red filter. The difference here is that the pass-bands of the red, green and blue filters of the TCS34725 evenly cover the full visual spectrum. But the emission spectra of the combined red, green and blue LEDs of the Neopixel has some very large gaps within that spectrum. So using white light and the filtered RGB readings of the sensor will give you a better reading.
Attachments
Untitled.png
Untitled.png (41.08 KiB) Viewed 88 times

adafruit_support_bill
 
Posts: 70085
Joined: Sat Feb 07, 2009 10:11 am

Re: TCS34725 Efficiency compensation

by adafruit_support_bill on Sat Sep 15, 2018 9:09 am

Looking closer at your drawings, it looks like you are using a cylindrical cuvette. That makes it trickier to avoid the specular reflections.

Instead of twisting the cuvette as shown in my previous diagram, you would need to tilt the sensor up or down. Or you could use an off-axis light source located above or below the sensor.

The diagram below is a side-view:'
Attachments
Untitled.png
Untitled.png (34.77 KiB) Viewed 82 times

adafruit_support_bill
 
Posts: 70085
Joined: Sat Feb 07, 2009 10:11 am

Re: TCS34725 Efficiency compensation

by Beatrice94 on Sat Sep 15, 2018 9:23 am

Ok, I got it! Would a good white LED do? Any suggestions?

Beatrice94
 
Posts: 18
Joined: Wed Jun 06, 2018 7:00 am

Re: TCS34725 Efficiency compensation

by adafruit_support_bill on Sat Sep 15, 2018 9:36 am

We have these 5mm size white LEDs. They are similar in output to the TCS34725 on-board LED.
https://www.adafruit.com/product/754

If powering with 5v, you would need a 100 ohm series resistor for current limiting.
If powering from 3.3v, you would need 15 ohms.

adafruit_support_bill
 
Posts: 70085
Joined: Sat Feb 07, 2009 10:11 am

Re: TCS34725 Efficiency compensation

by Beatrice94 on Sun Sep 16, 2018 9:53 am

Ok, got it.. Thank you very very much! At least now I have a better understanding of why am I doing something

Beatrice94
 
Posts: 18
Joined: Wed Jun 06, 2018 7:00 am

Re: TCS34725 Efficiency compensation

by adafruit_support_bill on Sun Sep 16, 2018 10:40 am

I just wanted to point out one more option: Depending on the nature of the sample, you might also consider back-lighting it. That avoids all the reflection issues.

This forum member ended up using a backlit sample with the TCS34725 with good results:
viewtopic.php?f=22&t=139133&p=687836

adafruit_support_bill
 
Posts: 70085
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.