Shop OBEX P1 Docs P2 Docs Learn Events
colorpal — Parallax Forums

colorpal

jay-zjay-z Posts: 1
edited 2010-07-31 18:36 in Accessories
does anyone have tips for saving color readings to the eeprom on my basic stamp. or is it better to run it of the pc.· this is for color sorting machine.

Comments

  • SamuelAaronWardSamuelAaronWard Posts: 1
    edited 2010-07-31 16:53
    Hi, Jay-Z!

    I came to this forum to find out about a couple other issues with the ColorPal.· But since you've posted the only question so far, I'll offer some input·and then ask my questions.

    First of all, you and I are using different microprocessors, so my answers might not be immediately helpful.· I'm using a Microchip PIC16F684, and you're using a Basic Stamp (which actually has a PIC chip for a brain).· Also, I write my code in PIC Assembly language, and you're probably using PBasic.

    That said, you're going to want to light up the Red, Green, and Blue dyes of the RGB LED one at a time and take a sample of the analog voltage produced by the light-to-voltage sensor.· The ColorPal will do an analog-to-digital conversion of the analog voltage, and then it will send an 8-bit binary (or digital) representation of that analog voltage back to your Basic Stamp with values ranging between 0 and 255 (2^8 = 256).· Or maybe it takes a 10-bit sample; I don't know because I haven't used it yet.· Anyway, then you do the same thing with the Green and Blue dyes.· Each time you take a sample, you'll want to save that digital value to a file register (or variable).· Then once you have sample values for the Red, Green, and Blue reflective intensities, you can use those to determine the color of whatever it is your ColorPal is looking at.·

    If you're sorting objects one at a time, based on their color, then you really only need three variables for the RGB values.· ...I guess I'm not understanding your dilemma.·

    In addition to taking samples of the reflected light intensities, two other issues need to be accounted for:

    1)· Weighting the current output (via PWM) to the separate dyes of the RGB LED, based on their spectral responsivity (see page 2 of the ColorPal's documentation).

    and...

    2) Compensating for ambient light, white reference, and black reference - which can skew your sample readings, making them incorrect (or at the very least, inaccurate).·

    I know how to do the spectral responsivity weighting, but the ambient/white/black compensation is what I'm confused about.· I understand it conceptually, but the explanation / formula on page 3 of the ColorPal documentation are a little ambiguous.· Where is the variable for ambient light in that equation?· Or are the black and white references collectively considered ambient compensation?· Or???· A detailed explanantion would be greatly appreciated!

    Thanks!

    Samuel Aaron Ward roll.gifhop.gifroll.gif
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-07-31 18:36
    The black reference is largely unnecessary now. During the development of the ColorPAL, a snorkel was being used that permitted crosstalk between the LED and sensor due to reflective threads and due to the fact there was no baffle between the two components. Both these sources of crosstalk have now been largely eliminated with a custom-molded snorkel that has a baffle and no threads. Also, when you use the "multi-sample RGB colors" command, the ambient light is automatically subtracted from each color component, so the data it returns is solely from reflected LED illumination. This leaves only the white balance to be considered in most situations.

    When you measure the RGB components of a color, what you really want is the value of each component, divided by its value when viewing something white. So the "white-balanced" results will be:

    ····Rbalanced = Rraw / Rwhite * 100%
    ····Gbalanced = Graw / Gwhite * 100%
    ····Bbalanced = Braw / Bwhite * 100%

    Or, instead of 100%, you can multiply by 255 to get a range that fills a byte of data for each component:

    ····Balanced = Raw * 255 / White

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 7/31/2010 6:41:07 PM GMT
Sign In or Register to comment.