Good morning to you.
I've buyed few days ago a TCS3200 sensor for obtain the RGB color value from same objects.
I've tried and modified some skatches I've found on the net, but the results are so far from the reality, in particular for the yellow color (that is the most important color I must detect).
Yesterday I had notice that exist a library, here below listed:
In all the sketches it's declared just S2 , S3 and OE pins.
The S1, S0 and OUT pin not figure in any sketches?
It's correct or I stay forgetting something?
Infact, when I try to calibrate the sensor, the RGB value are always " 0,0,0 ". Remember the OUT pin is not connected.
2)Could I gentle ask to you the pin configuration necessary to example sketches working?
I just wanna play with it and try to make something different from my previously attempt. Expecially for yellow color.
Perhaps you should not continue with this sensor.
Go to www.adafruit.com and have a look at their color sensors. The have normal sensors with i2c and libraries and tutorials. That is a good start. I think the older TCS3200 is a bad start. Is it only 4 photodiodes with frequency output ?
I have no experience with color sensors, but I trust Adafruit they picked a good one
That one from Sparkfun is with analog outputs for R, G, B.
Those 3 analog signals are very easy to read with Arduino analog inputs. But it is less accurate and it is expensive with 24.95 dollars. It might be okay for you.
The TCS3414CS is on Ebay for 16 dollars. It has digital interface with I2C. You can't use it, if you can't find a good library for it.
Adafruit has choosen the TCS34725, it has an IR blocking filter and a high dynamic range. Adafruit added some components to make it compatible with 3.3V and 5V Arduino boards. It is obvious that the Adafruit module is the better one.
@Peter_h
I will try also with this sensor from adafruit and I will report the feedback. I think it can be appreciated.
@marco_c
For sure.
The PDF as I've understand, give explication referred to PIN functions, not how to wire to arduino.
Anyway, also in the "Calibrate" sketch as in the other sketches, I can't see any PIN definition about S0,S1 and OUT.
Infact, with this configuration on my arduino wired to my TSC3200:
I can't read. The values returned are obviously the same RGB = (0,0,0).
Here the "calibrate" sketch I've tested:
// TCS230 sensor calibration and color readings
//
// Input and output using the Serial console.
//
#include <MD_TCS230.h>
#include <FreqCount.h>
#define BLACK_CAL 0
#define WHITE_CAL 1
#define READ_VAL 2
// Pin definitions
#define S2_OUT 4
#define S3_OUT 3
#define OE_OUT 7 // LOW = ENABLED
MD_TCS230 CS(S2_OUT, S3_OUT, OE_OUT);
void setup()
{
Serial.begin(57600);
Serial.print(F("\n[TCS230 Calibrator Example]"));
CS.begin();
}
char getChar()
// blocking wait for an input character from the input stream
{
while (Serial.available() == 0)
;
return(toupper(Serial.read()));
}
void clearInput()
// clear all characters from the serial input
{
while (Serial.read() != -1)
;
}
uint8_t fsmReadValue(uint8_t state, uint8_t valType, uint8_t maxReads)
// Finite State Machine for reading a value from the sensor
// Current FSM state is passed in and returned
// Type of value being read is passed in
{
static uint8_t selChannel;
static uint8_t readCount;
static sensorData sd;
switch(state)
{
case 0: // Prompt for the user to start
Serial.print(F("\n\nReading value for "));
switch(valType)
{
case BLACK_CAL: Serial.print(F("BLACK calibration")); break;
case WHITE_CAL: Serial.print(F("WHITE calibration")); break;
case READ_VAL: Serial.print(F("DATA")); break;
default: Serial.print(F("??")); break;
}
Serial.print(F("\nPress any key to start ..."));
state++;
break;
case 1: // Wait for user input
getChar();
clearInput();
state++;
break;
case 2: // start the reading process
CS.read();
state++;
break;
case 3: // wait for a read to complete
if (CS.available())
{
sensorData sd;
colorData rgb;
switch(valType)
{
case BLACK_CAL:
CS.getRaw(&sd);
CS.setDarkCal(&sd);
break;
case WHITE_CAL:
CS.getRaw(&sd);
CS.setWhiteCal(&sd);
break;
case READ_VAL:
CS.getRGB(&rgb);
Serial.print(F("\nRGB is ["));
Serial.print(rgb.value[TCS230_RGB_R]);
Serial.print(F(","));
Serial.print(rgb.value[TCS230_RGB_G]);
Serial.print(F(","));
Serial.print(rgb.value[TCS230_RGB_B]);
Serial.print(F("]"));
break;
}
state++;
}
break;
default: // reset fsm
state = 0;
break;
}
return(state);
}
void loop()
{
static uint8_t runState = 0;
static uint8_t readState = 0;
switch(runState)
{
case 0: // calibrate black
readState = fsmReadValue(readState, BLACK_CAL, 2);
if (readState == 0) runState++;
break;
case 1: // calibrate white
readState = fsmReadValue(readState, WHITE_CAL, 2);
if (readState == 0) runState++;
break;
case 2: // read color
readState = fsmReadValue(readState, READ_VAL, 1);
break;
default:
runState = 0; // start again if we get here as something is wrong
}
}
This library has a dependency on the FreqCount library for
frequency counting. FreqCount library is available at
http://www.pjrc.com/teensy/td_libs_FreqCount.html
** IMPORTANT NOTE**
FreqCount imposes a limitation that the frequency can only be
counted on specific pins and limits the use of other pins as
follows:
Board Input Pin Pins Unusable with analogWrite()
----------- --------- --------------------------------
Arduino Uno 5 3, 9, 10, 11
Arduino 2009 5 3, 9, 10, 11
Arduino Mega 47 9, 10, 44, 45, 46
Sanguino 1 12, 13, 14, 15
I do not see pin 2 listed anywhere for the frequency.
From the PDF file explaining the libraries
Initialising
MD_TCS230(uint8_t s2, uint8_t s3);
MD_TCS230(uint8_t s2, uint8_t s3, uint8_t oe);
MD_TCS230(uint8_t s2, uint8_t s3, uint8_t s0, uint8_t s1);
MD_TCS230(uint8_t s2, uint8_t s3, uint8_t s0, uint8_t s1, uint8_t oe);
Various forms of the constructor for this class. The parameters are all the Arduino pin numbers used to control the nominated pins on the TCS230. The form used will depend on the configuration of the hardware connections to the Arduino. At a minimum S2 and S3 are required for color filter selection.
In file included from C:\Program Files (x86)\Arduino\libraries\FreqCount\FreqCount.cpp:27:0:
C:\Program Files (x86)\Arduino\libraries\FreqCount\util/timers.h: In function 'void timer_shutdown()':
C:\Program Files (x86)\Arduino\libraries\FreqCount\util/timers.h:453:2: error: 'TCCR2B' was not declared in this scope
TCCR2B = 0;
^
Error compiling.
I have no experience with Leonardo, but the web site for FreqCount seems to imply that Leonardo is supported by listing the pins needed for that Arduino variation. Maybe someone else has done this and can have more useful information.
I am told my TCS230 driver works with TCS3200. Find it in my repositories site (see link below).
You can connect 2 sensors but then you will need to work out how to convert the Serial from the Arduino to RS485 and how to send it to Labview in a way that it will understand. That is more a LabView question than Arduino. On the RS232 to 485 conversion, I am sure that Google will be your friend.