tsl2580 ETC-unknow, tsl2580 Datasheet - Page 24

no-image

tsl2580

Manufacturer Part Number
tsl2580
Description
Light-to-digital Converter
Manufacturer
ETC-unknow
Datasheet
TSL2580, TSL2581
LIGHT-TO-DIGITAL CONVERTER
TAOS098 − MARCH 2010
// 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
//
//
//
// Arguments: unsigned int iGain − gain, where 0:1X, 1:8X, 2:16X, 3:128X
//
//
//
//
//
// Return:
//
//////////////////////////////////////////////////////////////////////////////
unsigned int CalculateLux(unsigned int iGain, unsigned int tIntCycles, unsigned int ch0,
unsigned int ch1, int iType)
{
// No scaling if nominal integration (148 cycles or 400 ms) is used
24
Copyright E 2010, TAOS Inc.
//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
// first, scale the channel values depending on the gain and integration time
// 1X, 400ms is nominal setting
unsigned long chScale0;
unsigned long chScale1;
unsigned long channel1;
unsigned long channel0;
if (tIntCycles == NOM_INTEG_CYCLE)
else
switch (iGain)
{
}
// scale the channel values
channel0 = (ch0 * chScale0) >> CH_SCALE;
channel1 = (ch1 * chScale1) >> CH_SCALE;
//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
// find the ratio of the channel values (Channel1/Channel0)
// protect against divide by zero
chScale0 = (1 << CH_SCALE);
chScale0 = (NOM_INTEG_CYCLE << CH_SCALE) / tIntCycles;
case 0: // 1x gain
case 1: // 8x gain
case 2: // 16x gain
case 3: // 128x gain
chScale1 = chScale0;
break;
chScale0 = chScale0 >> 3;
chScale1 = chScale0;
break;
chScale0 = chScale0 >> 4;
chScale1 = chScale0;
break;
chScale1 = chScale0 / CH1GAIN128X; //Ch1 gain correction factor applied
chScale0 = chScale0 / CH0GAIN128X; //Ch0 gain correction factor applied
break;
unsigned int tIntCycles − INTEG_CYCLES defined in Timing Register
unsigned int ch0 − raw channel value from channel 0 of TSL2581
unsigned int ch1 − raw channel value from channel 1 of TSL2581
unsigned int iType − package type (1:CS)
unsigned int − the approximate illuminance (lux)
channel values of the TSL2581. The equation if implemented
as a piece−wise linear approximation.
r
www.taosinc.com
// No scale.
// Scale/multiply value by 1/8
// Scale/multiply value by 1/16
Nominal setting
r
The LUMENOLOGY r Company

Related parts for tsl2580