The testing of the TCS3471 predominantly involved coding the various routines to interact with the TCS3471 state machine via the defined register set/commands. On power-up the various registers of the TCS3471 are mostly 0x00 (as per table 1 of the datasheet) except for register 0x01 and 0x03 (which are 0xFF) and register 0x12 which has the device ID (0x14 for the TCS34715 being used in this case). The default power-up register values give a convenient test, upon being read/downloaded from the TCS3471, showing if the I2C interface/PIC routines are operating correctly.
For example, the TCS3471_Connected() routine reads the contents of the TCS3471 register 0x12 (the 'ID Register') and if the returned value is equal to 0x14, returns TRUE. The other C code routines for the PIC microcontroller, and how to interact/control the TCS3471, are discussed below.
PIC Microcontroller Interface Code
The PIC micrcontroller code is based upon the code provided by TAOS/AMS (1). The code has been modified to compile with the CCS C compiler, targeting specifically the TCS34715 part, and enabling interaction with PIC via RS232.
The header file contains various #define's used to specify the TCS3471 command set, control constants and the following functions:
void TCS3471_Write(int regAddr, int dataByte);
// write data to a TCS3471 command register.
int TCS3471_Read(int regAddr);
// read data from a TCS3471 register
int16 TCS3471_Read_ColorReg(int regAddr);
// returns a 16bit value from one of the registers containing data
// corresponding to a particular color channel (R,G,B or C).
void TCS3471_clearInterrupt()
// clears the RGBC interrupt
int TCS3471_Connected();
// returns TRUE if value 0x14 found in TCS3471 ID Register
void TCS3471_Init();
// sets a 'default' TCS3471 integration time 700ms, wait time 1.2 sec
int checkCommand();
// RS232 communication with PIC to receive commands from PC for TCS3471
void TCS3471_Read_Photodiodes();
// read the current value of each TCS3471 photodiodes (C,R,G,B) and
// output to PC via RS232
void main();
// continously polls for following commands from PC via RS232:
// cmd '1' - check comms, TCS3471 connected
// cmd '2' - write received data to TCS3471 register
// cmd '3' - read TCS3471 register, send to PC via RS232
// cmd '4' - 'single' read of photodiode values, send to PC
// cmd '5' - start continous readings of photodiode values, send to PC
// cmd '6' - stop continous readings of photodiode values.
// note a VB coded PC application enables the RS232 comms
Visual Basic/PC Interface
A Visual Basic application was developed to facilitate communication/control of the TCS3471 via a PC connected to the PIC/TCS3471 by RS232. The following screen-shots of the interface show the functionality possible.
I don't have the facility to test the TCS3471 with known intensity of light at various wavelengths. However, illuminating the TCS3471 with the output from a WS2812 RGB LED, using various color combinations and intensities, resulted in the TCS3471 reporting the correct color channel, and recorded channel counts increased and or decreased as expected.
The DIY spectrophotometer project provides some additional data for the TCS3471, in which a "DVD diffraction grating" is used with a 1W white LED light source (and stepper motor for angle control) to produce a colour spectrum, of which the intensity was measured with the TCS3471.
Downloads
Only Logged-In Members can add comments