Colour reading is a real issue for industrial models.
I’ve been working on it for more than 12 months now, since December 2009.
After many months of hard work,
• starting with the standard colour reader (season 1 ) with features a red LED,
• adding extra light from bulb lamps (season 2 ),
• using a powerful external white LED lamp (season 3 ),
• changing the built-in standard red LED for a white LED (season 4 ),
• I decided to go digital with an I2C 4 channels 10 bits sensor.
There are two challenges:
• manage the I2C sensor on Arduino,
• pass the information on to the fischertechnik controller.
Step 1: Technical Solution
On the Arduino side, I’m using:
• Inventor’s Kit for Arduino (Sparkfun KIT-10173 )
• Logic Level Converter (Sparkfun BOB-08745 )
• Color Light Sensor Evaluation Board (Sparkfun SEN-08663 ) based on Avago ADJD-S371-Q999
• Opto-isolator Breakout (Sparkfun BOB-09118 )
The Avago ADJD-S371-Q999 is a four channels, red, green, bleu and clear, 10 bits colour sensor with built-in white LED.
On the fischertechnik side, I’m using
• a Robo TX controller (here or there )
• one switch
• three lamps
The Robo TX controller is I2C capable but, as at today, this feature is under development. So connecting the Avago sensor directly can’t work!
See here for a short comparison between the Arduino and the Robo TX controller.
Step 2: Arduino Side – Hardware
I use the following colours:
• red cable for 5V
• black cable for ground
• blue cable for I2C SCL
• green cable for I2C SDA
• white cable for D0
• yellow cable for D1
I provide the step-by-step cabling:
1• empty board
2• power and I2C connections between Arduino and logic level connector
3• power connections between colour sensor and logic level convertor and 5V for the built-in LED
4• I2C connections between colour sensor and logic level convertor
5• digital connections between Arduino and opto-isolator
6• cables from opto-isolator to the fischertechnik TX controller
Step 3: Arduino Side – Software
I highlight the most interesting parts from the four sections of the Arduino sketch:
1• Call of libraries
#include <Wire.h>#include “I2C_RGBC_Reader.h”
2• Definition of variables and constants
I2C_RGBC_Reader myRGBC_Reader;
3• the setup() procedure launches the colour reader and calls the standard calibration
myRGBC_Reader.begin ();
myRGBC_Reader.standard ();
I2C address is set and standard calibration are sent to the colour sensor.
4• the loop() procedure includes two key parts: a memorise() function learns the colours
Serial.println(“0..3 learn”);
Serial.print(“> colour object required\n”);
while (!Serial.available());
myRGBC_Reader.memorise ((command – 0x30));
and a getRGBC() function reads the cylinder while a recognise() function identifies the colour.
myRGBC_Reader.getRGBC (r, g, b, c);
myRGBC_Reader.recognise (n, p);
Recognition is based of distance calculation: the nearest memorised colour from the read colour is selected. A proximity index is also provided: it should be smaller than 100%, otherwise returned colour confidence is low.
Read more: Arduino + fischertechnik TX-C – Connecting I2C True Colour Sensor