hi,I tried a little with the HT Color Sensor, using a sample prog which I changed I little.Testing the colors I found out that the returned green and red values always are too small, compared to blue,so the colors appear "bluish".

The color "names " may be a little faulty, but at the white color you may see clearly, that the 3 color values are not identical as they should be.

how can this be corrected by calibrating?

Code:

////////////////////////////////////////////////////////////////////////////////////////////// Hitechnic Color Sensor Example// ==============================//// This file is a small application program that tests the NXT Color Sensor from HiTechnic.//// The program:// 1. Configures sensor port 'S2' as a HiTechnic color sensor.// 2. Displays the current color components (red, green, blue) on the NXT LCD.// 3. Checks to see whether the current color matches one of two predefined colors. If so// a unique tone is played on the NXT speaker to indicate which of the two colors were// matched.//// This sample provides a good framework for easy cut and paste and////////////////////////////////////////////////////////////////////////////////////////////

#pragma platform (NXT, FTC)

const tSensors kColorSensorPort = S2; // We want the color sensor to be on port "S2"

#include "AdvancedSensors.c"

// // Get the colors from the sensor and display on the NXT LCD // int nRed; int nGreen; int nBlue; short nColor; string strColor;

// // Use utility routine to see if current color detected is close enough // to a specific target color. //

// // To determine the color constants to match on, manually "watch" the output from the // color sensor and record the components of a target color. Edit the data below // // Adjust the "kRange" constant as appropriate to determine how close the target colors have to // be to detect a specific color. // const int kRedTarget1 = 20; const int kGreenTarget1 = 0; const int kBlueTarget1 = 0;

I tried to get support from Hitechnic, but unfortunately they don't support RobotC. Here is what they wrote:

Quote:

We actually don’t support RobotC as it is a third party product and is not associated with HiTechnic or LEGO. All support for RobotC is provided by the producers of RobotC. I note that you have posted on the RobotC forums with this and other questions and that is the place to get support.

Also note that RobotC uses a non-standard I2C speed to communicate with the sensors and we (HiTechnic) and LEGO do not endorse or support this method of accessing the sensors. In a number of instances we have found that reported sensor problems have been the result of this non-standard I2C speed so if you encounter any problems with any of the sensors the first thing to do is set the I2C speed to the LEGO standard.

Regards,

Steve(HiTechnic)

So this - again - is a support request specifically to the RobotC developers!

ROBOTC supports all of the features of the color sensor through I2C messaging. I would test out and see what I could do about the color sensor, except the three we have in our office no longer work for some reason.

From our communication with HiTechnic in the past regarding the color sensor, they apparently have to be shipped back to HiTechnic to be "recalibrate". DickSwan might have more information regarding that.

I got additional information on this subject, but I don't understand how to write an I²C program because for me this is far too complicated and cumbersome to do in RobotC:

Hitechnic wrote:

You can recalibrate the color sensor by using an I2C write command and write 0x43 to location 0x41 (?????????). Note that the sensor MUST be facing a white target surface at the prescribed distance before executing the calibrate otherwise the sensor may not work at all until successfully recalibrated... Once the calibrate command has been sent to the sensor it will complete the calibration in about ½ a second and then reset and be ready to use as normal.

which don't need any of those two pages full of unintelligible code (except in a library or header file)?

I have such a header file Right now it only has two functions, but I think that having two functions like yours would be a pretty simple addition. I would change the order of the parameters somewhat to make it match the rest of my functions. After all, it's *my* header file

/* ============================================================================= We wait for the I2C bus to be ready for the next message or emit a loud annoying buzz sound if there's an error. Taken from RobotC example code and modified.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum