HiTechnic NXT Color Sensor Version 2 for LEGO MINDSTORMS NXT
Introduction
The new and totally redesigned HiTechnic Color Sensor Version 2 (V2) operates by using a single white LED (light emitting diode) to illuminate the target and analyses the color components of the light reflected by the target's surface and calculates a Color Number that is returned to the NXT program.
The Color Sensor V2 works best when it is positioned so that it is not too close to the surface being tested. The picture on the right should be used as a guide for proper distance and angle to the surface. The angle prevents the direct reflection of the light from the LED from coming back into the sensor element, which can prevent proper color determination.
The Color Sensor is housed in a standard MINDSTORMS sensor housing to match the other MINDSTORMS elements and connects to an NXT sensor port using a standard NXT wire and digital I2C communications protocol. The Color Number calculated by the sensor is refreshed approximately 100 times per second.
NOTE: The Color Sensor V2 must be configured to match the mains electricity frequency for your country details on how to configure the Color Sensor V2 can be found at www.hitechnic.com/colorsensor
Programming
Mindstorms NXT-G
The Color Sensor can be programmed using LEGO Mindstorms NXT Software Color Sensor Block.
The Color Sensor Block is designed to support the HiTechnic Color Sensor.
1. This plug wires the number for which of your NXT’s ports are connected to the Color Sensor.
2. This plug wires the lower limit number for the Inside/Outside compare function.
3. This plug wires the upper limit number for the Inside/Outside compare function.
4. This plug wires the Color Number.
5. This plug outputs the relative Red value.
6. This plug outputs the relative Green value.
7. This plug outputs the relative Blue value.
8. This plug outputs the Inside/Outside logical value.
Color Front Panel
Port allows you to select the NXT port the compass is plugged into.
Compare
Compares the Color Number to the range set and sets the logic value to show if the value is inside or outside the range.
Using Range
The Compare lets you set a range and easily determine if the Color Number is inside or outside the range.
The Components for using the Range function are;
Inside Range / Outside Range: Select if you want to test for a Color Number inside the range or outside the range.
A: The lower limit of the range (0 – 17)
B: The upper limit of the range (0 – 17)
To use the Range function, set the lower and upper limit of your range and whether you want to test for inside or outside the range.
Examples showing the logical result.
A |
B |
Range |
Color Number |
Logical Value |
8 |
12 |
Inside Range |
10 |
|
8 |
12 |
Inside Range |
15 |
|
8 |
12 |
Outside Range |
10 |
|
8 |
12 |
Outside Range |
15 |
|
Color Number Chart
The Color Number chart shows the relationship between the target color and the Color Number returned by the Color Sensor.
Sensor Register Layout
The color firmware supports the standard Lego company’s sensor memory model.
Address |
Type |
Contents |
00 – 07H |
chars |
Sensor version number |
08 – 0FH |
chars |
Manufacturer |
10 – 17H |
chars |
Sensor type |
18 – 3DH |
bytes |
Not used |
3E, 3FH |
chars |
Reserved |
40H |
byte |
Not used |
41H |
byte |
Command |
42H |
byte |
Color number |
43H |
byte |
Red reading |
44H |
byte |
Green reading |
45H |
byte |
Blue reading |
The Sensor version number field will report a revision number in the format “Vn.m” where n is the major version number and m is the revision level. Revision numbers will typically reflect the firmware level. The version number will be used to indicate the hardware level.
The Manufacturer field will contain “HiTechnc”.
The Sensor type field will contain “ColorPD”.
The Command field reserved for future use.
The Color number field will return a single number color estimate.
The Red, Green and Blue reading fields will return the current detection levels for the three color components.
Other Programming Environments
LabVIEW
All the features of the HiTechnic Color sensor V2 can be accessed using LabVIEW and the NXT toolkit. A LabVIEW vi is available on the HiTechnic Downloads page.
RobotC
All features of the HiTechnic Color Sensor V2 can be accessed using RobotC. For more information go to http://www-education.rec.ri.cmu.edu/robotc/.
NOTE: When programming the Color Sensor V2 with RobotC, it must be accessed using I2C standard speed. At other non-standard higher speeds the Color Sensor V2 will not consistently return accurate data.
NXC
NXC is a C programming language compiler that can access all Color Sensor features. For more information go to http://bricxcc.sourceforge.net/nbc/.
Notes:
-
The HiTechnic Color Sensor operates best when positioned straight above the target surface and not at an angle to the target surface.
-
NXT Firmware version 1.03 or later must be loaded in the NXT for the compass to operate correctly. You can check the firmware version by displaying the NXT Window in the Mindstorms software.
Downloads
New with version 2.0: This block adds support for the HiTechnic Sensor Multiplexer as well as data logging with the LEGO Mindstorms 2.0 Education software.
| Description | Version | Release Date | Size | ||
| HiTechnic Color Sensor Block for Mindstorms NXT Software | 2.0 | July 28th, 2010 | 646.03 KB | Download Now |
| Description | Version | Release Date | Size | ||
| Color Sensor VIs For LabVIEW2009 | 1.0 | October 6th, 2010 | 115.83 KB | Download Now |
| Description | Version | Release Date | Size | ||
| Color Sensor VI | 1.0 | April 2nd, 2009 | 47.21 KB | Download Now |







