Shop OBEX P1 Docs P2 Docs Learn Events
TCS3200-DB Measuring Ambient Light — Parallax Forums

TCS3200-DB Measuring Ambient Light

KitKat25KitKat25 Posts: 8
edited 2012-06-13 13:47 in Accessories
Does anyone know how I can use the TCS3200-db to measure ambient light? I know to (1) turn the LEDs off, and (from reading other posts) (2) to put a piece of white paper over the lens, but in the datasheet there is a chart called TCS3200 Relative Emissive Spectral Response with IR Filter that I'm confused about.

I want each color (red, green, blue) to have the same sensitivity/response in ambient light. To do this, can I use the same count time for each one, or does blue (for example) need a longer count time than green and red (because it has a lower relative response in the chart)?

I'm really confused, please help!!

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-06-12 10:06
    KitKat25,

    Welcome to the forum!
    I want each color (red, green, blue) to have the same sensitivity/response in ambient light.

    Let's assume that what you mean by this is that you want the responses to be the same in ambient white light. White light, by definition, is that which contains an equal measure of output at every wavelength. However, it's something that we almost never experience, since most incandescent light sources (e.g. the sun, a lightbulb, etc.) follow what's known as the "blackbody radiation curve" whose whiteness is governed by a factor known as "color temperature."

    Given any source spectrum, the response of each sensor in the TCS3200 will be the integral over all wavelengths of that spectrum multiplied the color response curve of the sensor. For an ideal white light source, this just translates to the area under the response curve. So, in order to equalize or "normalize" the responses of the individual sensors under these conditions, you would need to divide the actual response by a number proportional to the area under the sensor's response curve. You can also, as you suggested, adjust the integration time in the same way. The only catch, if you're using the TCS3200 with a BASIC Stamp, is that typical integration times tend to be small integers. So you will not get the precision you might be after by adjusting them.

    More typically, however, one will have a reference "white" standard available that can be used simply to measure the white response of each sensor, in lieu of the integration, and use this value to divide the response by for the normalization. This is what's referred to in the TCS3200 doc as doing a "white balance."

    -Phil
  • KitKat25KitKat25 Posts: 8
    edited 2012-06-12 11:53
    Yikes, lol, most of that went over my head! My nephew is a little science-nut and wanted to experiment with this sensor. I did a little computer programming in college so my sister "volunteered" me to help, but I'm afraid this color stuff is definitely beyond me. Anyway though, so if I'm understanding you correctly, I do need to "normalize" each color if we are using the same count time for each one, say 100 across the board (which we have been using). I know what you mean about BASIC Stamp only using whole numbers, but it won't be a problem to normalize them after the fact using a calculator because we are just taking a few measurements, and I think it's good math practice for him to convert them by hand.

    I guess my question is then, what should I multiply each color reading by to "normalize" them? I could be way off on this, so sorry if I am, but looking at the chart it looks like blue is .53 of the whole, green is about .65 of the whole, and red is .95 of the whole. Would it be right then to multiply blue by 1.89, green by 1.54, and red by 1.05 (rounding to the nearest hundredth)? Thank you for your help on this, I'd be lost otherwise!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-06-12 12:52
    The relative responses of the sensors, with the IR filter, and integrated over a range of 350nm to 1100nm are approximately Red: 9.79, Green: 7.25, Blue: 7.5, Clear: 20.3. This will give you some idea of the relative corrections needed to give a uniform response to white light.

    -Phil
  • KitKat25KitKat25 Posts: 8
    edited 2012-06-12 13:34
    Okay, so to "normalize" the colors to the clear value, would I divide the clear response by each colors' response, and then multiply the result by each actual readout from the sensor? So, (20.3/9.79 = 2.07 for Red); (20.3/7.25 = 2.8 for Green); and (20.3/7.5 = 2.71 for Blue)?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-06-12 13:35
    That would work.

    -Phil
  • KitKat25KitKat25 Posts: 8
    edited 2012-06-12 13:38
    Wonderful! Thank you Mr. Pilgrim!
  • KitKat25KitKat25 Posts: 8
    edited 2012-06-12 14:22
    I'm sorry, but I have one more concern. We ran the numbers I computed above against some readings we recorded a few days ago, and found that the red value exceeded the clear value. Is this possible? I'm wondering if the relative response for red was supposed to be 19.79 rather than 9.79, because the red value makes more sense then, and is also closer to the green and blue values (which have been considerably lower than the red value). I'm sorry for all the questions, but we appreciate your help! Thank you.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-06-12 14:43
    It's definitely possible (and sensible) to get higher post-correction red readings than clear ones if the light you're observing is rich in red. Don't forget that the correction factor is based upon an integration over all wavelengths. Anything other than white light will skew the readings in favor of the color that it's heaviest in. And, yes, 9.79 is the correct factor, based upon the the data I have from TAOS.

    -Phil
  • KitKat25KitKat25 Posts: 8
    edited 2012-06-13 08:52
    I guess I'm confused because on the chart red is still always below the clear response curve across the entire chart, and I guess I also thought that the clear sensor would read all wavelengths, so any red light available would still be picked up by the clear sensor too, making sure clear would always be higher than (or at least equal to) red. But like I said, I know nothing about this color stuff! Thank you again!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-06-13 09:18
    The compensation function basically adjusts each of the color curves upwards such that the areas underneath them equal that of the clear curve. When you do that to the red curve, for example, the portion of it that's in the red region will, of necessity, be higher than that of the clear curve.

    I'm not entirely sure what it is that you're trying to accomplish. Perhaps, if you supplied some more details, I could suggest other ways of handling the data.

    -Phil
  • KitKat25KitKat25 Posts: 8
    edited 2012-06-13 12:35
    I guess I wouldn't say we are trying to accomplish anything in particular, I just want to make sure the readings are an accurate representation of the light. My nephew's science class was learning about the color spectrum before summer break, and his teacher was using some fancy spectrometer or something to show the students the color spectrum in various areas/conditions (classroom, outside, etc.). My nephew wanted to experiment more, and his teacher recommended this sensor for an affordable/simple alternative to measure the light spectrum.

    We got it to work just fine, but then we started to get a little concerned when red was always the highest color, followed by green and then blue, no matter where we took readings (in the house, outside, etc.). Then I looked back at the datasheet chart and saw how the colors had different "responsiveness," and that responsiveness seemed to match up with our readings, i.e., red was the highest, then green, then blue. I got worried that the red sensor was just more sensitive than the green (and so forth), and that if we didn't compensate for this somehow, our readings of ambient light would not be accurate.

    I suppose I just want to make sure the sensors are all just as responsive or sensitive as the others, so that the readings are accurate. I hope that makes sense.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-06-13 13:24
    Probably the simplest thing to do, then, would be to expose the sensor to outdoor ambient on an overcast day and call that "white." IOW, do a white balance on a cloudy sky. Then adjust subsequent readings with the white-balanced data. The method I gave you here previously does the same thing, but with a theoretical "perfect white."

    There are other, more complicated approaches one can take. For example, you could partition the spectrum into distinct red, green, and blue sections. Then use the sensor's output to estimate how much light fell into each section. With perfect filters having non-intersecting spectral responses, this would be simply a matter of taking readings. But, since the color responses overlap and bleed into other portions of the spectrum, there would be some additional math involved. For example, because the green sensor has a small peak of sensitivity in the blue, a better estimate of how much green light it's receiving could be had by subtracting a little bit of the response from the blue sensor to compensate. But, really, I think this goes well beyond the requirements of the project at hand.

    -Phil
  • KitKat25KitKat25 Posts: 8
    edited 2012-06-13 13:47
    I agree, lol, sorry for making this more trouble than it probably needed to be. I like what you said about the "white balance," and so we put a really nice white LED that I have in a headlamp up to the sensor in a dark room to see if we could get a "white balance." The readings all got pretty close, but red was still the highest by a little bit, then came green, then blue. I think we'll just use that difference to calibrate the differences going forward.

    Thank you for all your help, this was very informative.
Sign In or Register to comment.