RWTH - Mindstorms NXT Toolbox

CalibrateColor

Enables calibration mode of the HiTechnic color sensor

Contents

Syntax

CalibrateColor(port, mode)

CalibrateColor(port, mode, handle)

Description

Calibrate the color sensor with white balance and black value. I don't know whether calibration of color sensor makes sence Hitech doku says nothing, some internet freaks say it is necessary, but it works and has effect ;-) The sensor LEDs make a short flash after successful calibration. When calibrated, the sensor keeps this information in non-volatile memory. There are two different modes for calibration: mode = 1: white balance calibration Puts the sensor into white balance calibration mode. For best results the sensor should be pointed at a diffuse white surface at a distance of approximately 15mm before calling this method. After a fraction of a second the sensor lights will flash and the calibration is done. mode = 2: black level calibration Puts the sensor into black/ambient level calibration mode. For best results the sensor should be pointed in a direction with no obstacles for 50cm or so. This reading the sensor will use as a base level for other readings. After a fraction of a second the sensor lights will flash and the calibration is done. When calibrated, the sensor keeps this information in non-volatile memory.

The color sensor has to be opened (using OpenColor) before execution.

The given port number specifies the connection port. The value port can be addressed by the symbolic constants SENSOR_1 , SENSOR_2, SENSOR_3 and SENSOR_4 analog to the labeling on the NXT Brick.

The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call COM_SetDefaultNXT to set one).

Example

     % color must be open for calibration
     OpenColor(SENSOR_2);

     % white calibration mode
     CalibrateColor(SENSOR_2, 1);
     % pause for changing position
     pause(5);
     % black calibration mode
     CalibrateColor(SENSOR_2, 2);

See also

OpenColor, GetColor, CloseSensor,

Signature