Shop OBEX P1 Docs P2 Docs Learn Events
Trouble sampling output from ColorPal — Parallax Forums

Trouble sampling output from ColorPal

ramrezramrez Posts: 3
edited 2011-05-23 09:18 in Accessories
Hello everyone,

I'm having difficulty sampling output from my ColorPal sensor. When I sample ambient light I get 0x334641 using a multimeter on the ColorPal sig output. When I sample black and white (for references) I get 0x303039 and 0x304139 respectively. Then when I try to determine the reference colors for black and white I get 0x000507 and 000600 respectively which are relatively close.

I'm trying to establish references (will I have to store them in EEPROM at the start of my code?) to get some color recognition.

If anyone could clarify any misunderstandings it would be GREATLY appreciated; I've been stuck on this issue for too long...

Comments

  • kwinnkwinn Posts: 8,697
    edited 2011-05-21 17:51
    The ColorPal sends data out as serial so I am wondering what you were measuring with the multimeter. Can you post the details of how you were taking the measurements. Keep in mind that it generates it's own light (as detailed below) and measures the light reflected back so if you allow ambient light to reach the sensor it will affect the readings. The shroud around the sensor should make adequate contact with the sample to prevent ambient light entering.

    The ColorPAL is a miniature color and light sensor which, through its RGB LED, doubles as a color generator. For sensing color, the ColorPAL uses its LED to illuminate a sample, one color component at a time, along with a broad-spectrum light-to-voltage converter to measure the light reflected back. The amount of light reflected from the sample under illumination from each red, green, and blue LED can be used to determine the sample’s color.
  • ramrezramrez Posts: 3
    edited 2011-05-21 20:16
    Hi, thanks for your quick reply!

    Sorry what I meant to say was that I'm actually using a logic analyzer to read the hex bytes sent out by the ColorPal signal line.

    Its sending me the bytes at the documented baud rate of around 4800. I am using "= X s #00" followed by "= R s #02" to store on the EEPROM. Then when I run the program by powering up the Sensor, I read 0x30 x032 0x34 AND 0x30 x032 0x36 on the sig line through the Logic Analyzer. I am not sure why I get the same bytes when the LED is off and when the LED is red? I have been reading about the Ambient Light and the Black/White references but that does not make much sense from the provided documentation. Could you please clarify how to detect colors, for example to get the color Green when Green is illuminated and reflected from a Green object.

    Thanks and I have been stuck on the same issues for 3 weeks. Your reply seems like a green light at the end of the tunnel. Pardon the pun.

    regards,
    Ramrez
  • kwinnkwinn Posts: 8,697
    edited 2011-05-22 09:04
    Ramrez, I hope it is the green light and not the train. To get a good color measurement the sensor needs to be placed against a sample so that no (or very little) ambient light gets to the sample. The individual diodes of the rgb led are then lit in turn and an intensity reading is taken for each color (ie the red led is lit, the photosensor signal is measured, and the result is stored in the red byte and the procedure is repeated for the green and blue leds).

    The black sample measurement should give fairly low intensity readings (if no ambient light gets in to the sensor), and the white measurement should give high intensity readings.
  • captainvipcaptainvip Posts: 5
    edited 2011-05-22 12:24
    Hi Ramrez,
    Seems like you are having the same issue I had resolved this morning. Do not look at each reading as an RR GG BB reading, rather convert it to a 3 digit ASCII. In your case, it would be

    0x024 AND 0x026 for your Ambient and Red readings. Now why are they so close, I am not sure, its probably because you are taking a reading with lots of ambient light for your RED sample. Ideally the object should be right against the sensor so no ambient light gets in like kwinn explained. I am not sure if you can detect something far away as well, unless there are tricks to do that such as Sensitivity settings etc.

    Hope this helps,
    Vipin
  • kwinnkwinn Posts: 8,697
    edited 2011-05-22 17:27
    Hope this info helps. Let me know if you have any questions.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-05-22 20:27
    kwinn,

    Thank you for that very helpful calibration PDF! One suggestion: be sure to stress that the multiplication by 100 or 255 has to occur before the division by the white-minus-black factor.

    And please send Parallax a note to see if they will include your doc on the ColorPAL product webpage.

    -Phil
  • ramrezramrez Posts: 3
    edited 2011-05-22 22:59
    Thanks guys, the doc was very useful. This resolves my issue.
  • kwinnkwinn Posts: 8,697
    edited 2011-05-23 09:18
    kwinn,

    Thank you for that very helpful calibration PDF! One suggestion: be sure to stress that the multiplication by 100 or 255 has to occur before the division by the white-minus-black factor.

    And please send Parallax a note to see if they will include your doc on the ColorPAL product webpage.

    -Phil

    Done and done.
Sign In or Register to comment.