TSL2581, TSL2583
LIGHT-TO-DIGITAL CONVERTER
TAOS134 − MARCH 2011
22
r
r
Copyright E 2011, TAOS Inc.
The LUMENOLOGY r Company
www.taosinc.com
// 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 TSL2583. The equation if implemented
// as a piece−wise linear approximation.
//
// Arguments: unsigned int iGain − gain, where 0:1X, 1:8X, 2:16X, 3:128X
// unsigned int tIntCycles − INTEG_CYCLES defined in Timing Register
// unsigned int ch0 − raw channel value from channel 0 of TSL2583
// unsigned int ch1 − raw channel value from channel 1 of TSL2583
// unsigned int iType − package type (1:CS)
//
// Return: unsigned int − the approximate illuminance (lux)
//
//////////////////////////////////////////////////////////////////////////////
unsigned int CalculateLux(unsigned int iGain, unsigned int tIntCycles, unsigned int ch0,
unsigned int ch1, int iType)
{
//−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
// 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;
// No scaling if nominal integration (148 cycles or 400 ms) is used
if (tIntCycles == NOM_INTEG_CYCLE)
chScale0 = (1 << CH_SCALE);
else
chScale0 = (NOM_INTEG_CYCLE << CH_SCALE) / tIntCycles;
switch (iGain)
{
case 0: // 1x gain
chScale1 = chScale0; // No scale. Nominal setting
break;
case 1: // 8x gain
chScale0 = chScale0 >> 3; // Scale/multiply value by 1/8
chScale1 = chScale0;
break;
case 2: // 16x gain
chScale0 = chScale0 >> 4; // Scale/multiply value by 1/16
chScale1 = chScale0;
break;
case 3: // 128x gain
chScale1 = chScale0 / CH1GAIN128X; //Ch1 gain correction factor applied
chScale0 = chScale0 / CH0GAIN128X; //Ch0 gain correction factor applied
break;
}
// 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
TSL2581, TSL2583
LIGHT-TO-DIGITAL CONVERTER
TAOS134 − MARCH 2011
23
The LUMENOLOGY r Company
r
r
Copyright E 2011, TAOS Inc.
www.taosinc.com
unsigned long ratio1 = 0;
if (channel0 != 0) ratio1 = (channel1 << (RATIO_SCALE+1)) / channel0;
// round the ratio value
unsigned long ratio = (ratio1 + 1) >> 1;
// is ratio <= eachBreak?
unsigned int b, m;
switch (iType)
{
case 1: // CS package
if ((ratio >= 0) && (ratio <= K1C))
{b=B1C; m=M1C;}
else if (ratio <= K2C)
{b=B2C; m=M2C;}
else if (ratio <= K3C)
{b=B3C; m=M3C;}
else if (ratio <= K4C)
{b=B4C; m=M4C;}
else if (ratio > K5C)
{b=B5C; m=M5C;}
break;
}
unsigned long temp;
unsigned long lux;
temp = ((channel0 * b) − (channel1 * m));
// round lsb (2^(LUX_SCALE−1))
temp += (1 << (LUX_SCALE−1));
// strip off fractional portion
lux = temp >> LUX_SCALE;
return(lux);
}
TSL2581, TSL2583
LIGHT-TO-DIGITAL CONVERTER
TAOS134 − MARCH 2011
24
r
r
Copyright E 2011, TAOS Inc.
The LUMENOLOGY r Company
www.taosinc.com
APPLICATION INFORMATION: HARDWARE
Power Supply Decoupling and Application Hardware Circuit
The power supply lines must be decoupled with a 0.1 μF capacitor placed as close to the device package as
possible (Figure 6). The bypass capacitor should have low effective series resistance (ESR) and low effective
series inductance (ESI), such as the common ceramic types, which provide a low impedance path to ground
at high frequencies to handle transient currents caused by internal logic switching.
TSL2581/
TSL2583
V
BUS
V
DD
0.1 F
R
P
R
P
SCL
SDA
R
PI
INT
Figure 6. Bus Pull-Up Resistors
Pull-up resistors (R
P
) maintain the SCL and SDA lines at a high level when the bus is free and ensure the signals
are pulled up from a low to a high level within the required rise time. The I
2
C bus protocol was developed by
Philips (now NXP). The pull-up resistor (R
P
) value is a function of the I
2
C bus speed, the supply voltage, and
the capacitive bus loading. Users should consult the NXP I
2
C design specification
(http://www.i2c−bus.org/references/) for assistance. With a lightly loaded bus running at 400 kbps and
V
BUS
= 3 V, 1.5 kΩ resistors have been found to be viable.
A pull-up resistor (R
PI
) is also required for the interrupt (INT), which functions as a wired-AND signal in a similar
fashion to the SCL and SDA lines. A typical impedance value between 10 kΩ and 100 kΩ can be used.

TSL2581FN

Mfr. #:
Manufacturer:
ams
Description:
Light to Digital Converters Light to Digital 30x Sensitivity
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union