TSL2562, TSL2563
LOW-VOLTAGE
LIGHT-TO-DIGITAL CONVERTER
TAOS066J − MAY 2007
#define K4C 0x010a // 0.520 * 2^RATIO_SCALE
#define B4C 0x0282 // 0.0392 * 2^LUX_SCALE
#define M4C 0x03df // 0.0605 * 2^LUX_SCALE
#define K5C 0x014d // 0.65 * 2^RATIO_SCALE
#define B5C 0x0177 // 0.0229 * 2^LUX_SCALE
#define M5C 0x01dd // 0.0291 * 2^LUX_SCALE
#define K6C 0x019a // 0.80 * 2^RATIO_SCALE
#define B6C 0x0101 // 0.0157 * 2^LUX_SCALE
#define M6C 0x0127 // 0.0180 * 2^LUX_SCALE
#define K7C 0x029a // 1.3 * 2^RATIO_SCALE
#define B7C 0x0037 // 0.00338 * 2^LUX_SCALE
#define M7C 0x002b // 0.00260 * 2^LUX_SCALE
#define K8C 0x029a // 1.3 * 2^RATIO_SCALE
#define B8C 0x0000 // 0.000 * 2^LUX_SCALE
#define M8C 0x0000 // 0.000 * 2^LUX_SCALE
// lux equation approximation without floating point calculations
//////////////////////////////////////////////////////////////////////////////
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
Routine:
unsigned int CalculateLux(unsigned int ch0, unsigned int ch0, int iType)
Description: Calculate the approximate illuminance (lux) given the raw
channel values of the TSL2562. The equation if implemented
as a piece−wise linear approximation.
Arguments:
Return:
unsigned int iGain − gain, where 0:1X, 1:16X
unsigned int tInt − integration time, where 0:13.7mS, 1:100mS, 2:402mS,
3:Manual
unsigned int ch0 − raw channel value from channel 0 of TSL2562
unsigned int ch1 − raw channel value from channel 1 of TSL2562
unsigned int iType − package type (T or CS)
unsigned int − the approximate illuminance (lux)
//////////////////////////////////////////////////////////////////////////////
unsigned int CalculateLux(unsigned int iGain, unsigned int tInt, unsigned int ch0,
unsigned int ch1, int iType)
{
//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
// first, scale the channel values depending on the gain and integration time
// 16X, 402mS is nominal.
// scale if integration time is NOT 402 msec
unsigned long chScale;
unsigned long channel1;
unsigned long channel0;
switch (tInt)
{
case 0:
// 13.7 msec
chScale = CHSCALE_TINT0;
break;
case 1:
// 101 msec
chScale = CHSCALE_TINT1;
break;
default:
// assume no scaling
chScale = (1 << CH_SCALE);
Copyright E 2007, TAOS Inc.
The LUMENOLOGY r Company
r
r
www.taosinc.com
25