Project

General

Profile

Color Board Not Acting 16-bittish

Added by Bodger about 6 years ago

I finally managed to obtain a Color Board in the US, the local vendor being a bit slow about selling them. I quickly soldered on a header and plugged it up to a known-good JeeNode and uploaded the demo sketch. It ran but the results were, frankly, weird. What I am seeing is as if the readings (all four channels) are being taken from the upper byte of a two-byte data block. The data jumps in increments of 256. Never an odd number which was what first caught my eye. I’ve run through the gain numbers and the scaling numbers and the results are no better. Just in case there was some JeeNode malfunction I tried with a second unit but the results were identical. All I can think of is that my Color Board is defective or that it is not being initialized to the proper state. I’ve looked at the CPP code for it and there seems to be no initialization going on at all but I may just be missing something. Can anyone offer some guidance about what I might try next?


Replies (4)

RE: Color Board Not Acting 16-bittish - Added by martynj about 6 years ago

Bodger - can you post your driving code please?

RE: Color Board Not Acting 16-bittish - Added by Bodger about 6 years ago

I am using the JeeLabs example sketch, both unmodified and modified to use port 4. This is the (slightly) modified version:

// Demo of the Color Plug, based on the ColorPlug class in the Ports library
// 2011-12-23  http://opensource.org/licenses/mit-license.php

#include 

PortI2C myBus (4);
ColorPlug sensor (myBus, 0x39); // Sensor address is 0x39

// gain = 3 (64x) and prescaler = 0 (1x) => most sensitive sensor setting,
//   for use in low light conditions
// gain = 0 (1x) and prescaler = 6 (64x) => least sensitive sensor setting,
//   for use in case of overflows
// gain = 0 (1x) and prescaler = 0 (1x) => default sensor setting,
//   vary according to need
byte gain = 0;      // 0..3 (multiplier => 3 most sensitive, 1/4/16/64x)
byte prescaler = 0; // 0..6 (divider => 0 most sensitive, 1/2/4/8/16/32/64x) 

void setup () {
    Serial.begin(57600);
    Serial.println("\n[colorDemo]");
    sensor.begin();
    sensor.setGain(gain, prescaler);
}

void loop () {    
    Serial.println();  

    // Get 16-bit values for R, G, B and Clear
    const word* rgbcValues = sensor.getData(); 
    Serial.print("Red: ");
    Serial.print(rgbcValues[0]);
    Serial.print(", Green: ");
    Serial.print(rgbcValues[1]);
    Serial.print(", Blue: ");
    Serial.print(rgbcValues[2]);
    Serial.print(", Clear: ");
    Serial.print(rgbcValues[3]);
    Serial.print(", Gain: ");
    Serial.print(gain, DEC);
    Serial.print(", Prescaler: ");
    Serial.println(prescaler, DEC);

    // Get chromaticity and correlared color temp (CCT)
    const word* chromacct = sensor.chromaCCT(); 
    // See http://en.wikipedia.org/wiki/Color_temperature for explanation
    if (chromacct[0] > 0 && chromacct[1] > 0) {
      Serial.print("Chromaticity x: ");
      Serial.print(chromacct[0] * 0.001, 2);
      Serial.print(", y: ");
      Serial.print(chromacct[1] * 0.001, 2);
      Serial.print(", Correlated color temp: ");
      Serial.println(chromacct[2]); // CCT of 0K means invalid
      // Note: although the CCT can be calculated for any chromaticity
      // coordinate, the result is meaningful only if the light source
      // is nearly white
    } else {
      Serial.println("Chroma overflow");
      // Try different gain/prescaler values if overflows occur
    }

    delay(1000);
}

RE: Color Board Not Acting 16-bittish - Added by martynj about 6 years ago

Bodger, what value of pull-ups are you using?

RE: Color Board Not Acting 16-bittish - Added by Bodger about 6 years ago

pull-ups I do not understand (nothing unusual in that). This is a completely integrated I2C device and is pin-compatible with the JeeNode. I simply provided a header and plugged it in. Is there something else required that wasn’t required with, for example, the I2C Analog Board? Thanks.

    (1-4/4)