Controlling Detector Filters with Custom 2-wavelength Colorimeter LED board



  • Hi everybody,

    I have been working to be able to use the red filter with our red LED on our device. I was looking in your code at how the ‘D1’ and ‘D2’ variables which correspond to the 1st and 2nd LEDs for the Custom 2-wavelength colorimeter LED board are defined. ‘D2’ has an assignment to ‘green’ in all of the python code I can find and I was trying to change this to ‘red’ so that I can change from,

    dev.setSensorModeIndependent()
    dev.calibrate(LED_TO_COLOR[‘D1’])
    dev.calibrate(LED_TO_COLOR[‘D2’])
    

    and

    dev.setSensorModeIndependent()
    freqD1, tranD1, absoD1 = dev.getMeasurement(LED_TO_COLOR['D1'])
    freqD2, tranD2, absoD2 = dev.getMeasurement(LED_TO_COLOR['D2'])
    

    to,

    dev.setSensorModeIndependent()
    dev.calibrate(LED_TO_COLOR['D1'])
    dev.setSensorModeSpecific()
    dev.calibrate(LED_TO_COLOR['D2'])
    

    and

    dev.setSensorModeIndependent()
    freqD1, tranD1, absoD1 = dev.getMeasurement(LED_TO_COLOR['D1'])
    dev.setSensorModeSpecific()
    freqD2, tranD2, absoD2 = dev.getMeasurement(LED_TO_COLOR['D2'])
    

    All within a forloop (used for averaging). This allows me to change back and forth between settings so that each led flash is with it's correct filter (UV with white or none and Red with Red).

    Currently when I do this it appears the default is the green symbol as stated in the colorimeter_serial.py (https://bitbucket.org/iorodeo/colorimeter/src/453156994876ed2a3cb50dd3a6eb7c0242ff384a/python/Colorimeter/colorimeter/colorimeter_serial.py?at=default) and in the constants.py (https://bitbucket.org/iorodeo/colorimeter/src/453156994876ed2a3cb50dd3a6eb7c0242ff384a/python/Colorimeter/colorimeter/constants.py?at=default) files.

    I am doing this to reduce some amount of intensity of my LED as it is saturating the detector. Any advice would be greatly appreciated.

    Thanks,

    Jordan



  • @jgarrison Originally the colorimeter was designed to work an RGB LED and so the digital lines which turned the LEDs on and off mapped to specific colors - red, green, blue, . When we later added the custom LED boards the easiest thing to do was to map the LEDs on custom LED boards to the existing 'colors'. The idea being that the custom boards would always be used with the 'clear' filter on the sensor (setSensorModeIndependent). Unfortunately, if you are using the custom LED board with the sensor color specific mode (setSensorModeSpecific) the firmware will use the filter associated with original color from the RGB LED i.e., D1 blue and D2 green.

    The easiest quick and dirty fix - so you can check out whether or not using the red filter helps with your saturation issue - - is probably to modify the firmware so that the 'green' measurement uses a different filter when in color specific mode. This can be done by modifying the getFrequencyGreen method of the Colorimeter class in the firmware. In particular change it to something like this

    uint32_t Colorimeter::getFrequencyGreen() {
        led.setGreen();
        if (sensorMode == COLOR_SPECIFIC) {
            //sensor.setChannelGreen();
               sensor.setChannelRed();
        }
        else {
            sensor.setChannelClear();
        }
        return sensor.getFrequency(numSamples);
    }  
    

    This fix isn't ideal though. A longer term (and better) solution would be to separate the LED digital IO pins from the colors in the firmware and allow uses to select the sensor's color filter independently from the LED pins.



  • @Will-Dickson

    I implemented those changes and it worked just fine for what I'm trying to do. Thanks for all the help,

    Jordan


Log in to reply