Shop OBEX P1 Docs P2 Docs Learn Events
Tcs 230 measurement problem — Parallax Forums

Tcs 230 measurement problem

thavathava Posts: 17
edited 2009-06-23 21:14 in Accessories
Hi guys, im currently undergoing some measurement with TCS230 light to frequency converter, its actually a cmos color sensor, so the measurement result was made in period measurement.

For white the output was not almost the same, but actually according to bitmap resolution, the R,G,B value for white is 255,255,255, but through this sensor, the output frequency is not really that similar, it actually varies. and for black its suppose to be R,G,B=0,0,0 and the output of the sensor is not really similar.

same when i place the sensor on Red which is R,G,B=255,0,0 and there is no green or blue intensity on this particular color, but still im getting output reading. so i need suggestion that what would be the problem? i feel its related to physics.
here is the link for datasheet of the sensor im using. thank you.



www.w-r-e.de/robotik/data/opt/tcs230.pdf

Comments

  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-05-11 21:09
    What exactly are you using for a test specimen/source of light? Sometimes an object or filter that looks all red, might actually have a fair amount of blue in it, etc. If you don't have somewhat "pure" test sources, then you might get some indications of the other colors. How much error are you talking about?


    Mark
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-05-11 21:54
    With any color sensor, you need to do a "white balance" and possibly a "black balance" to calibrate it before you can expect to get anywhere close to the colors you expect. Then, the corrected reading for each RGB component would be 255 * (CurrentReading - BlackReading) / (WhiteReading - BlackReading). Also, don't expect something that "looks red" to be pure red. It will still have some green and blue components mixed in.

    Finally, are you using the TCS230-DB with the white LEDs and collimating lens, or just a bare TCS230 chip? If the latter, you will be getting a lot of stray ambient light that will skew your readings.

    -Phil
  • nionio Posts: 14
    edited 2009-05-12 05:09
    hi thava,
    i have just the same problems with u.

    for phil,
    and one more problem, how should i do "white balance" ? because i don't have any color proof that valued R,G,B=255,255,255
    well so far i'm using printed ivory paper which i don't know exactly the RGB value (because i print it with CMYK printer)
    and the result is, RGB value may vary during "white balance" (R,G,B = 252, 253, 255)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    oh no..
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-05-12 05:59
    Pick something white and take a reading. Suppose it comes up R,G,B = 251, 221, 195. This will be your standard for "white", and every other color reading you take will be compared to it as a reference. So, for example, if you look at a yellow target and get a reading of R,G,B = 240, 210, 31, you will correct this using your white values to:

    ····R,G,Bcorrected = 255 * 240 / 251, 255 * 210 / 221, 255 * 31 / 195 = 243, 242, 40

    -Phil
  • nionio Posts: 14
    edited 2009-05-12 06:27
    @phil
    ok..but a little bit different with program i used(in attachment)

    my questions:
    1. i don't know the exact reason why i have to do white balance,what
    the function of that, could you explain it to me?
    i already do some experiments, the result with white balance
    routine much closer than without white balance. but still far from it should be.

    2. what should i do to make color value that viewed in PC exact same as target's color

    i'm using Visual Basic to view RGB value and the color to a PC.(pic below)

    51393277.th.jpg

    for big pic HERE

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    oh no..

    Post Edited (nio) : 5/12/2009 6:32:43 AM GMT
  • thavathava Posts: 17
    edited 2009-06-23 07:55
    Hi Phil, im currently in my final stage of my project, how is actually the white balance calculation works? 255 * (CurrentReading - BlackReading) / (WhiteReading - BlackReading). how actually this works, why have to multiply 255? i dont get the whole formula.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-23 08:37
    If the Stamp could do floating point math, (CurrentReading - BlackReading) / (WhiteReading - BlackReading) would be a number between 0 and 1. Multiplying by 255 makes the range 0 to 255 instead. To use this formula, be sure that (CurrentReading - BlackReading) is 255 or less. Otherwise you will get overflow from the multiplication.

    -Phil
  • thavathava Posts: 17
    edited 2009-06-23 11:19
    Phil, im really confused, im using period measurement technique, all the output is in microsecond. some are 700 plus and some are only 200 plus, i dont get the idea of the formula, the problem is i cant simply use the formula without getting the idea. please enhance the facts Phil, sorry for bothering, but i cant find the facts elsewhere.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-23 15:24
    Oh, sorry, I misssed that detail. The formula is for frequency measurement. Can you change your sensing to use frequency instead of width? It makes the math easier.

    -Phil
  • thavathava Posts: 17
    edited 2009-06-23 21:14
    if thats the case, i could inverse the whole formula cause period is inverse of frequency what. but actually why in that formula:
    255 * (CurrentReading - BlackReading) / (WhiteReading - BlackReading).
    Current reading need to subtract black reading, then divide with (white reading - black reading), then why should multiply 255?
Sign In or Register to comment.