OSRAM SFH7773

SFH 7773
(IR-LED + Proximity Sensor + Ambient Light Sensor)
Application note
preliminary
1. Introduction
The SFH 7773 combines a digital ambient
light sensor and a proximity sensor (emitter
+ detector) within one package. Additionally
the sensor provides an I2C-bus interface and
an interrupt pin to connect it to an e.g.
microcontroller.
This application note describes the basic
technical features and the components
operation, allowing the user to achieve the
full functionality of the sensor. At the end a
simple software code illustrates an example
for the implementation of the SFH 7773 into
a mobile phone environment.
Please note that this guide is only a brief
introduction. For more detailed information
and the latest products and updates please
visit www.osram-os.com or contact your
local sales office to get technical assistance
during your design-in phase.
2. Applications
Typical application areas are mobile
phones, PDAs, notebooks, cameras and
other consumer products. Common tasks for
the integrated ambient light sensor are
display brightness adjustments, whereas the
proximity sensor is usually employed to
detect objects and motions. This single
component integrates several distinct
functionalities and greatly simplifies the
design-in process in consumer as well as
industrial applications. The dark black look
of the SFH 7773 makes it ideally suitable for
implementation behind a cover glass.
The ultra-low power consumption of the
SFH 7773 makes the devices especially
suited for mobile applications, where
conservation of battery power is a critical
point.
December 12, 2011
Fig. 1: Photography and orientation of the
SFH 7773.
3. The SFH 7773
The SFH 7773 (see Fig. 1) consists of an
850 nm infrared (IR) LED and an ultra-low
power ASIC which performs the signal
processing and provides the I2C-bus
interface as well as an interrupt alert
function. Additionally the ASIC contains the
two photodiodes for proximity resp. ambient
light sensing. The functional block diagram
can be found in Fig. 2. The pinning of the
devices is stated in Tab. 1. The key features
of the SFH 7773 include:
Proximity Sensor (PS)
- detection-range up to 150 mm
- optimized for the integrated 850nm emitter
- superior ambient light suppression
(> 50 klx)
- immunity to crosstalk
- fast access to PS signal
- high power (stacked) emitter version for
extended detection range are available
on request
Ambient Light Sensor (ALS)
- 0.03 lx – 65 000 lx
- excellent linearity
page 1 of 23
4. Ambient Light Sensor
VDD
3
5
INT
SDA
7
SCL
6
ASIC
I2C
Command Register
Data Register
Internal
Power
Supply
Proximity
PD
Oscillator
1
VLED
CATH
Signal
Processing
Analog
Amplifier
LED
Driver
8
Ambient Light
PD
IR LED
2
GNDLED
4
GNDDD
Fig. 2: SFH 7773 functional block diagram.
Pin No.
1
2
3
4
5
6
7
8
Pin
Label
VLED
GNDLED
VDD
GNDDD
INT
SCL
SDA
CATH
Description
LED Supply Voltage
Ground VLED - LED Driver
Digital Supply Voltage
Ground (Digital)
Interrupt Pin
I2C-Bus Clock Line
I2C-Bus Data Line
Must not be Connected
Tab. 1: Pin configuration of the SFH 7773
- spectral sensitivity to mimic the human eye
(V-lambda)
I2C-Bus Interface
- Slave Address 0111 000X
- 100kHz / 400kHz and 3.4MHz mode
- programmable operation modes
(stand-by, triggered, free-running)
- low current consumption (< 5μA)
in stand-by mode
- configurable interrupt output with
programmable threshold levels for
PS and ALS
December 12, 2011
The ambient light sensor is intended to
provide ambient light measurement, e.g. to
control and adjust the display brightness. To
support this functionality the SFH 7773
provides a convenient user interface.
The ambient light sensor delivers output
values in the range from 0 to 65535 (16 bit).
Low output values correspond to a low
illumination of the sensor, while high values
indicate high illumination. The range of the
ambient light sensor sensitivity can be set
by the user and covers more than 4 ½
decades. Two threshold levels for the
ambient light sensor can be set via the I2Cbus, a lower and an upper threshold. In the
case of exceeding these thresholds an
interrupt is generated automatically, allowing
e.g. the microcontroller to act accordingly
(see Sec. 8.3 for the relevant registers and
settings).
4.1 Spectral Sensitivity of the ALS
The human eye’s wavelength range of
significant sensitivity is between 400 nm and
700 nm with its peak at around 555 nm
(often called V-lambda characteristic).
The spectral sensitivity of the SFH 7773
aims to mimic the sensitivity of the human
eye as close as possible and provides a real
improvement compared to standard siliconphotodetectors (see Fig. 3).
Fig. 4 compares the ALS count readings
with different light sources and relates them
to the human eye sensitivity (V-lambda),
assuming the same illuminance value.
Values are normalized to the standard light
source A (2856 K). Due to the high IR and
UV suppression the sensor shows only
minor deviation compared to the perception
of the human eye for different light sources.
Please note that the use of coloured cover
glasses might influence the accuracy,
depending on the spectral transmission
characteristics (visible plus infrared range)
of the cover glasses.
page 2 of 23
Directional Sensitivity of the Ambient Light Sensor
+
100
0,8
0,6
0,4
Si-Photodetector
V-lambda
SFH 7773
0,2
0,0
400 500 600 700 800 900 1000 1100
Wavelength / nm
-
50
40°
30°
45°
0
-90
Fig. 3: Spectral sensitivity of the SFH 7773
vs. the human eye (V-lambda) and standard
Si-photodetectors.
Short Axis
Long Axis
ALS
-
+
Sensitivity / %
Normalized Sensitivity
1,0
-60
-30
0
30
Angle / °
60
90
Fig. 5: Directional characteristics of the
ambient light sensor.
Ambient Light Sensor Count vs. Illumination
(Standard Light A)
10000
Human Eye Level
1000
80
ALS Count
Rel. ALS Count / %
100
60
40
100
10
1
20
0.1
0
Standard
Light A
(2856 K)
Flourescent
Lamp
Light
Bulb
Sunlight
Halogen
Lamp
1
10
100
1000 10000 100000
Illumination / Lux
Fig. 6: Ambient light sensor count vs.
illumination (integration time = 100 ms).
Fig. 4: Ambient light sensor accuracy vs.
different light sources. Normalized to 100 lux
and standard light A.
4.2 Directivity of the ALS
tint
10 ms
20 ms
50 ms
100 ms
200 ms
500 ms
1000 ms
ALS
Range
3.0 lx - 65535 lx
1.5 lx - 32767 lx
0.60 lx - 13106 lx
0.30 lx - 6553 lx
0.15 lx - 3277 lx
0.06 lx - 1311 lx
0.03 lx - 655 lx
ALS
Resolution
1.00 lx/count
0.50 lx/count
0.20 lx/count
0.10 lx/count
0.05 lx/count
0.02 lx/count
0.01 lx/count
Tab. 2: ALS integration time settings tint and
their relation to ALS range and resolution
(default: tint = 100 ms).
December 12, 2011
Fig. 5 presents the directivity of the ALS.
This is an important point for considering the
design of a potential cover glass (please
refer to Sec. 10.1 for more details).
4.3 Sensitivity Range of the ALS
The range of the ALS can be programmed
by the user via the ALS integration time
(register 0x26). Per default (integration time
= 100 ms) the range covers 0.3 lx to 6.5 klx
with a resolution of typ. 0.1 lx/count. A
doubling of the integration time changes the
sensitivity range by a factor of two. Please
page 3 of 23
set via the I2C-bus (see Sec. 8.3 for the
relevant registers and settings).
5.1 Functionality of the PS
Fig. 7: LED drive current and timing during
one proximity measurement cycle (PS
integration time tburst is set to 750 us).
refer to Tab. 2. Also note: To access the
ALS integration time register (0x26) the
integration time access register (0x20) has
to be set accordingly.
Please note: To achieve flicker-free
measurements (e.g. 50 / 60 Hz driven light
bulbs) integration times with a multiple of 50
ms are recommended (i.e. 50 ms, 100 ms
aso.). By choosing 10 ms or 20 ms OSRAM
recommends
averaging
several
measurements to achieve flicker-free ALS
values.
4.4 Output Count and Linearity of the
ALS
The sensors output count is linear vs. the
illumination level EV over a wide range (see
Fig. 6). This conversion between the ALS
count and the illumination is typ. 0.1 lx/count
(standard light A) for the default ALS
integration time of 100 ms (please refer to
Tab. 2 for different ALS integration time
settings). For an exact absolute calibration it
is recommended that the user performs a
measurement within the application for each
device. Deviation from the linearity is usually
within ± 5 % (normalized to 100 lx).
5. Proximity Sensor
The proximity sensor delivers output values
within the range from 0 up to 254 (8 bit,
pseudo-logarithmic). Low output values
correspond to low irradiance of the sensor,
while high values indicate high irradiance. A
threshold level for an interrupt alert can be
December 12, 2011
To achieve the outstanding high ambient
light suppression, the SFH 7773 uses 667
kHz LED bursts with a programmable
duration (default value of the PS integration
time tburst is 750 us). The PS integration time
can be set via register 0x27 (please refer to
Sec. 8.3 for details). Fig. 7 illustrates the
burst signal during a complete measurement
cycle. After the initial e.g. I2C-bus triggered
request, the proximity data are available
after 10 ms. Measurement repetition time in
the free running mode can be selected
between 10 ms and 2000 ms. The proximity
measurement operates at 850 nm.
5.2 Proximity Count and Detection Range
The maximum switching range depends –
among target properties like size and
reflectivity - on the IR-LED pulse current in
combination with the setting of the PS
integration time tburst. To reach a maximum
detection range the recommended values
are for the LED drive current are 100 mA,
150 mA or 200 mA with a PS integration
time tburst of 750 us or 1000 us. Fig. 8 and 9
present the proximity values vs. target
distance for a 100 x 100 mm2 Kodak White
(90 %) target (no cover glass). As indicated
by Fig. 8 and 9 the typ. maximum detection
range for the SFH 7773 is in the range of up
to 100 mm (by using 200 mA LED current
and a PS integration time of 750 us – 1000
us and setting a threshold level for the
interrupt alert at 80 - 100 counts). However,
OSRAM recommends for the SFH 7773 to
set the threshold level not below 80 counts
to avoid interference with noise.
As a general rule OSRAM recommends for
a robust design the setting of the threshold
levels to be up to around 10 times above
any noise level. The factor 10 corresponds
to around 60 counts in PS signal due to the
pseudo-logarithmic relationship.
page 4 of 23
Proximity Count vs. Target Distance
2
Kodak White, 90 %, 100 x 100 mm
200
Proximity Sensor Count
Proximity Sensor Count
Proximity Count vs. Target Distance
2
Kodak White, 90 %, 100 x 100 mm
200 mA
100 mA
50 mA
150
100
50
0
25
50
75
100 125
Target Distance / mm
25
50
75
100
125
150
Fig. 9: Proximity sensor signal count vs.
target distance and integration time (LED
drive current = 200 mA).
Radiation Characteristics of the IR-LED
Short Axis
Long Axis
100
+
± 50°
50
0
-90
± 30°
-60
Eq. (1)
-30
0
30
Angle / °
+
LED
60
-
-
90
Fig. 10: Radiation characteristics of the
proximity sensor LED.
The sensor’s design ensures that a touch of
human skin directly onto the sensor (no
airgap) delivers the maximum sensor count
(which depends on LED drive current and
integration time). This ensures that even in
this rare case a reliable operation is
ensured.
5.3 Radiation Characteristics of the PSLED
Fig. 10 presents the radiation characteristics
of the IR-LED. The characteristics might
influence the design of the cover glass
(aperture). The directional sensitivity of the
proximity sensor photodiode (detector) is
December 12, 2011
50
Target Distance / mm
Norm. Radiation Characteristics / %
⎞ μW
⎟ 2
⎟ cm
⎠
100
0
As a rule of thumb, 30 counts result in
almost a quadrupling in irradiance (PS
signal level) whereas 10 counts represent
roughly a factor of 1.55 in analog signal
level.
The digital proximity count signal is
correlated to the detected irradiance Ee.
There is an approximate logarithmic
relationship between the digital PS signal
the analog signal level (irradiance):
⎛
Ee ≈ ⎜⎜10
⎝
300 us
750 us
1000 us
1500 us
150
150
Fig. 8: Proximity sensor signal count vs.
target distance and LED drive current
(integration time tburst = 750 us).
1
0.017 ⋅counts + 0.11− 370.4 ⋅t burst
s
200
very similar to the emitter’s radiation
characteristics.
Please refer to Sec. 10.1 for a more detailed
discussion.
5.4 Crosstalk
In general, most proximity sensors are
hidden behind a cover glass. However, the
cover glass causes reflections which might
make it impossible for the sensor to
differentiate between a target reflection (e.g.
human skin) and the reflections from the
page 5 of 23
Cover Glass Distance from Package Top
(Airgap) / mm
Cover Glass Distance from Package Top
(Airgap) / mm
1.00
external Separator recommended
Boundary for Cover Design
without Aperture
0.75
0.50
SFH7773
0.25
"Crosstalk-free" - Range
0.00
0.00
0.25
0.50
0.75
1.00
1.00
external Separator recommended
0.75
Boundary for
C'over Design
with Aperture
0.50
0.25
SFH7773
"Crosstalk-free" - Range
0.00
0.00
0.25
0.50
0.75
1.00
Cover Glass Thickness / mm
Cover Glass Thickness / mm
Fig. 12: Crosstalk-free range: Cover glass
thickness vs. airgap. The device is
“crosstalk-free” for e.g. 1.0 mm cover glass
and an airgap of 0.7 mm.
Fig. 11: Crosstalk-free range: Cover glass
thickness vs. airgap. The device is
“crosstalk-free” for e.g. 0.2 mm cover glass
and an airgap of 0.5 mm. To achieve
optimized performance a two-hole aperture
design is recommended (see Fig. 12).
December 12, 2011
Proximity Sensor Count
cover glass. A common and proven solution
is the use of an external separator to avoid
the reflections from the cover glass.
However, such a separator causes
additional design-in effort.
Due to its design the SFH 7773 is crosstalkinsensitive for a range of typical
applications. Fig. 11 and 12 present this
range as a function of cover glass thickness
vs. the spacing between the bottom of the
cover glass and the SFH 7773 (airgap).
Typical applications where the SFH 7773
works without an external separator are e.g.
0.8 mm cover glass and an airgap of 0.7
mm. Note that the crosstalk-free range
depends on the actual design of the cover
glass aperture. To utilize the full potential of
the SFH 7773 it is recommended to use an
aperture design within the cover glass
(please refer to Sec. 10.1 for more details).
Beyond the “crosstalk-free” indicated area a
separator is recommended. In any case it is
recommended to verify the actual design.
Please note that beyond the proposed
“crosstalk-free”-range the sensor works as
well, but might experience a certain offsetlevel, dependent, among other issues, on
the type of glass. Please note that coloured
(dark) cover glasses might reduce the
ILED = 200 mA, tburst = 1000 us
250
Kodak White 90 %, 100 x 100 mm2
50k lx at SFH 7773 from Halogen Lamp
200
0 lx
50k lx Halogen Lamp
150
100
50
0
25
50
75
100
125
150
Target Distance / mm
Fig. 13: Proximity signal in different ambient
light conditions. Even in a high brightness
environment (50k lx on SFH 7773, ILED =
200 mA) the sensor shows no significant
changes.
“crosstalk-free”-range, depending on the
type/quality of the cover glass. Experimental
verification of the behaviour is mandatory
here.
5.5. Ambient Light Suppression of the
PS-Signal
Due to its design the SFH 7773 features an
excellent immunity of the proximity
measurement against even ultra-high
page 6 of 23
Mode
Standard mode (Sm)
Fast mode (Fm)
High speed mode (Hs)
the ambient light function can be used
independently from each other. The three
basic modes are:
Bit Rate
≤ 100 kbit/s
≤ 400 kbit/s
≤ 3.4 Mbit/s
Tab. 3: The I2C-bus protocol speed mode
compatibility of the SFH 7773.
ambient light levels. Fig. 13 demonstrates
this
outstanding
feature.
Even
in
environments of 50 klx the proximity signal
is completely unaffected (refer to Fig. 13) by
even illumination with a halogen lamp which
contains a high level of IR radiation.
6. Current Consumption
The following equations give an idea on the
total power consumption of the SFH 7773
during operation.
By operating the PS in the free-running
mode, the current consumption (including
LED current, ILED) can be approximated by
the following Eq. (depending on the
measurement interval time trep_PS and the PS
integration time tburst):
I AVG _ PS = 0.5 ⋅ t burst
(I LED + 100mA)
t rep _ PS
Eq. (2)
The current consumption during operation of
the ALS depends on the ALS integration
time tint as well as the repletion time trep_ALS
can be approximated by:
I AVG _ ALS = 1mA ⋅
t int
t rep _ ALS
Eq. (3)
Example for total PS current consumption:
ILED = 100 mA, tburst = 300 us and trep = 100
ms
=>
IAVG_PS = 300 μA.
This compares to a stand-by current
consumption of less than 5 μA (typ. 2-3 μA).
7. Operating Modes
The SFH 7773 can be operated in three
different modes, in which the proximity resp.
December 12, 2011
free-running: The sensor measures
continuously and writes the results into the
relevant registers, ready to be read via the
I2C-bus interface. Optionally the interrupt
alert function with the user-defined threshold
levels (PS and/or ALS) will be executed if
such an event takes place.
triggered: The measurements are initiated
via I2C-bus instruction. Data are available
after processing is finished (10 ms total
delay time for PS, 100 ms for ALS).
stand-by: The initial state after power-up.
The SFH 7773 is in low power mode (IDD < 5
μA), no operations are carried out, but the
device is ready to respond to I2C-bus
commands.
additionally, there is the off-state:
off: The SFH 7773 is inactive, supply
current is below 2 μA. The SDA, SCL and
INT pins are in Z-state (high impedance). All
register entries are reset to the default
values.
The transition time between the modes, ttrans,
is < 10 ms. The delay time between standby
and start of measurement is < 10 ms. The
voltage VDD to switch the SFH 7773 into the
off-state is < 1.4 V. To reach the stand-by
mode at least 2.0 V are required.
8. I2C – Bus Communication
The address of the SFH 7773 is 0x38.
8.1 I²C - Bus Environment
The SFH 7773 is a digital ambient light and
proximity sensor. The communication is
performed via a 2-wire I²C bus interface, so
the device can be integrated into a typical
multi-master
/
multi-slave
I²C
bus
environment. A typical I²C bus network
consists of a master and different I²C bus
slave devices. For a more detailed
discussion on the topic of I2C-bus please
refer to [2].
page 7 of 23
1. Activate Ambient Light Sensor
S
SFH7773 Address
ALS Control
Activate Free Running
W A
A
A P
(0x38)
Register (0x80)
Mode (0x03)
2. Activate Proximity Sensor
S
SFH7773 Address
PS Control
Activate Free Running
W A
A
A P
(0x38)
Register (0x81)
Mode (0x03)
S
SFH7773 Address
I_LED Register
W A
A
(0x38)
(0x82)
Set LED Current to
200mA (0x1E)
A P
3. Wait
4. Read Out PS Data
S
SFH7773 Address
PS Data Register
W A
A P
(0x38)
(0x8F)
S
SFH7773 Address
R A
(0x38)
N
P
A
PS Data
5.1 Read Out ALS Data (LSB)
S
SFH7773 Address
ALS Data Register
W A
A P
(0x38)
LSB - (0x8C)
S
SFH7773 Address
R A
(0x38)
ALS Data (LSB)
N
P
A
5.2 Read Out ALS Data (MSB)
S
SFH7773 Address
ALS Data Register
W A
A P
(0x38)
MSB - (0x8D)
S
SFH7773 Address
R A
(0x38)
ALS Data (MSB)
Communication from Master to SFH 7773
Communication from SFH 7773 to Master
W: Master Writes
N
P R: Master Reads
A
A: Acknowledge
NA: Not Acknowledge
S: Start Condition
P: Stop Condition
Fig. 14: I2C-bus communication for the example described below.
The built-in I2C-bus interface is compatible
with all common I2C-bus modes (see Tab.
3). The logic voltage (VIO) of the SFH 7773
ranges from 1.6 V – 2.0 V (according to I2Cbus specification [2]).
8.2 I²C - Bus Communication
By embedding the SFH 7773 in an I²C-bus
network and after applying VDD = 2.5 V, the
communication can start as follows (Fig. 14
illustrates this I²C-bus conversation):
1. Activation of the ALS:
The default mode of the sensor is STANDBY and the SFH 7773 needs to be activated
by the master (e.g. microcontroller).
December 12, 2011
Each I²C bus communication begins with a
start command “S” of the Master (SDA line
is changing from “1” to “0” during SCL line
stays “1”) followed by the address of the
slave (SFH 7773 address is 0x38). After the
7bit slave address the read (1) and write (0)
R/W bit of the master will follow. The R/W bit
controls the communication direction
between the master and the addressed
slave. The slave is responding the proper
communication with an acknowledge
command. Acknowledge “A” (or not
acknowledge “NA”) is performed from the
receiver by pulling the SDA line down (or
leave in “1” state).
For the activation of the sensor the master
needs to write an activation command
(0x03) into the corresponding control
page 8 of 23
Fig. 15: Combined mode structure.
register for the ALS (0x80). Each command
needs to be acknowledged by the slave.
After activation the master ends the
communication with a STOP command “P”
(SDA line is changing from LOW to HIGH
during SCL line stays HIGH). In this
example the measurement interval time is
kept at the default value (500 ms).
2. Activation of the PS:
For the activation of the PS sensor the
master needs to write the activation
command (0x03) into the corresponding
control register (0x81). By writing 0x1E into
the I_LED register (0x82) the LED current is
set to 200 mA. The measurement interval is
left at the default value (100 ms). After
activation
the
master
ends
the
communication with a STOP command.
3. Wait time:
After activation, the sensor will change from
STAND-BY to FREE-RUNNING mode. After
a delay of 100 ms for ALS / 10 ms for PS
the first measurement value is available and
can be read via the I²C-bus.
4. PS value: reading data
The PS value is accessible via the output
register (0x8F). After reading the 8-bit word,
the communication can be ended by the
master with a not acknowledge “NA” and the
stop command “P”. The PS output reading
of the SFH 7773 can then be converted from
hexadecimal to decimal.
5. ALS value: reading data (LSB and MSB)
The sensor’s 16bit ALS measurement value
is composed of 2 bytes (LSB & MSB). The
December 12, 2011
bytes are accessible via the two output
registers (0x8C, 0x8D). After addressing the
LSB (least significant byte) resp. the MSB
(most significant byte) output register, the
communication direction has got to be
changed from the slave to the master by
repeating the address and the R/W byte with
a changed R/W bit. After reading LSB and
MSB, the communication is ended by the
master with a not acknowledge “NA” and the
stop condition “P”. The conversion of the
ALS output data of the SFH 7773 from
hexadecimal to decimal can easily be
calculated:
ALS_DATA_LSB = F0 (1111 0000)
ALS_DATA_MSB = 83 (1000 0011)
Final result (hexadecimal): 83 F0 counts
Final result (decimal): 33776 counts, which
correspond to around 30.4 klx (based on a
conversion factor of typ. 0.9 lux/count).
After finishing the measurement, the SFH
7773 mode may be changed to STAND-BY
via the control register.
Combined mode
To ensure interference free communication
the I²C-bus combined mode should be used.
Instead of performing two independent read
or write commands (COM 1 & COM 2) the
commands can be combined by a repeated
start condition “Sr” (Fig. 15 illustrates the
combined mode structure).
The start and repeated start commands
(“Sr”) are the same: the SDA line is
changing from “1” to “0” during SCL line “1”.
The “Sr” condition is placed behind “A” or
“NA”. The combined mode is not limited to 2
read/write commands, so the addressing of
the sensor and reading/writing of multiple
register values can be performed within one
block.
Block read mode
The Block read mode of the SFH 7773 can
be used to read all output registers in cyclic
manner.
page 9 of 23
I²C Addr.
0x20
0x26
0x27
0x80
0x81
0x82
0x83
0x84
0x85
0x86
0x8A
0x8B
0x8C
0x8D
0x8E
0x8F
0x90
0x91
0x92
0x93
0x94
0x95
0x96
0x97
0x98
0x99
Type Name
RW
INT_ACCESS
RW
ALS_INT_TIME
RW
PS_INT_TIME
RW
ALS CONTROL
RW
PS CONTROL
RW
I_LED
RW
ALS & PS TRIG
RW
PS INTERVAL
RW
ALS INTERVAL
R
PART_ID
R
MAN_ID
R
ALS_DATA_LSB
R
ALS_DATA_MSB
R
ALS_PS STATUS
R
PS_DATA
RW
INT_SET
RW
PS_THR LED
RW
ALS UP_THR LSB
RW
ALS UP_THR MSB
RW
ALS LO_THR LSB
RW
ALS LO_THR MSB
Description
Integration time access
ALS integration time
PS integration time (burst length)
SW reset , ALS operation mode control
PS operation mode control
Setting LED pulse current
not intended for use
Forced mode ALS and PS measurement triggering
PS measurement rate in stand-alone mode
ALS measurement rate in stand-alone mode
Part number and revision IDs
Manufacturer ID
ALS measurement data, least significant bits
ALS measurement data, most significant bits
Status of meas. data (ALS and PS)
PS measurement data
not intended for use
not intended for use
Interrupt settings
PS interrupt threshold level
not intended for use
not intended for use
ALS interrupt upper threshold level, least significant bits
ALS interrupt upper threshold level, most significant bits
ALS interrupt lower threshold level, least significant bits
ALS interrupt lower threshold level, most significant bits
Tab. 4: SFH 7773 control and data registers.
After addressing and reading an output
register (e.g. LSB) in normal mode, the
master is not placing the stop condition, but
sends an acknowledge and continues to
read the output registers. The SFH 7773 will
automatically increase the register address
and the content of the next sensor output
register can be read following the register
addresses:
80Æ81Æ…Æ98Æ99Æ80Æ81Æ...
For register addresses and content see Sec.
8.3 and Tab. 3.
December 12, 2011
The block read mode can be ended by
placing a not acknowledge (NA) with the
subsequent stop condition from the master.
8.3 Registers
The SFH 7773 has 21 different registers
(see Tab. 4). Additionally there are 5 more
registers which are not intended to be used
by the user - but they are addressed
automatically
by
block
read/write
procedures.
The following pages will describe the
registers and their structure resp. content.
page 10 of 23
INTEGRATION TIME ACCESS: Allows access to reg. 0x26, 0x27 (ALS_INT_TIME, PS_INT_TIME)
Note: After setting bit ‘0’ there must be a stop condition to confirm writing. It is recommended to set the bit ‘0’ back to ‘0’ after the
changes in the integration registers 0x26 and 0x27 have been made.
R/W-Register 0x81
Bit
7
6
5
4
3
2
1
0
not used
Integration Time Access:
default XXXXXXX
0 Not Accessible
1 Accessible
ALS INTEGRATION TIME: Ambient light measurement integration time:
The ALS integration time is responsible for setting the ALS sensitivity range and the lx/count value. An increase of the ALS
integration time by a factor of 10 increases also the ALS sensitivity level by a factor of 10. The default setting of 100 ms results in a
range from approximately 0.3 lx to 6553 lx with a resolution of 0.1 lx/count.
0x26 is only accessible if the access-bit in register 0x20 is set to ‘1’. It is recommended to set this access bit back to ‘0’ after changes
have been made. When reading or writing in block-read/-write mode, it is recommended to start at register 0x26 and stop at 0x27, as
there are other registers accessible which are not intended to be accessible by the user. Afterwards set 0x20 back to ‘0’.
R/W-Register 0x26
Bit
7
6
5
4
3
2
1
0
not used
ALS INTEGRATION TIME
default XXXXX
000 100 ms
001 200 ms
010 500 ms
011 1000 ms
100 10 ms
101 20 ms
110 50 ms
111 50 ms
PS INTEGRATION TIME (BURST LENGTH): Proximity measurement integration time
An increase in PS integration time results in an increased PS signal level. E.g. an increase in PS integration time by a factor of 10
increases the PS counts by around 50 counts (due to pseudo-logarithmic relationship).
0x27 is only accessible if access-bit in register 0x20 is set to ‘1’. It is recommended to set this access bit back to ‘0’ after changes
have been made. When reading or writing in block-read/-write mode, it is recommended to start at register 0x26 and stop at 0x27, as
there are other registers accessible which are not intended to be accessible by the user. Afterwards set 0x20 back to ‘0’.
R/W-Register 0x27
Bit
7
default XXXXX
6
5
not used
4
3
100
000
001
010
011
100
101
110
111
2
1
0
PS INTEGRATION TIME
750 us
100 us
200 us
300 us
500 us
750 us
1000 us
1500 us
2500 us
ALS CONTROL: Software reset and control of ambient light sensor
SW reset (bit #2 „1“) sets all registers to default (same as POWER-UP). Afterwards it is automatically set back to „0“ by the
SFH7773.
R/W-Register 0x80
Bit
7
6
5
4
3
2
1
0
not used
complete SW reset
mode of ambient light sensor
default 00000
0
00 STAND-BY
1 SW reset
00 STAND-BY
01 STAND-BY
10 TRIGGERED (by MCU)
11 FREE-RUNNING (internally triggered)
December 12, 2011
page 11 of 23
PS CONTROL: Control of proximity sensor
R/W-Register 0x81
Bit
7
6
5
4
not used
3
2
default XXXXXX
00
00
01
10
11
1
0
mode of Proximity Sensor
STAND-BY
STAND-BY
STAND-BY
TRIGGERED by MCU
FREE-RUNNING (internally triggered)
I_LED: Emitter (LED) current setting
R/W-Register 0x82
Bit
7
6
5
activation of LEDs
Not used
Default 00
011
00 LED active
bit #7 and #6
must not be changed
to other values
4
3
2
1
0
setting LED pulse current
011
50 mA
000
5 mA
001
10 mA
010
20 mA
011
50 mA
100
100 mA
101
150 mA
110
200 mA
ALS & PS TRIG: MCU-triggered measurement (for ambient light sensor and proximity sensor)
2
If „1“ is set a new measurement will start after I C stop command from MCU. As soon as the measurement is finished the
corresponding bit of the register will automatically be set to „0“ by the SFH7773.
R/W-Register 0x84
Bit
7
6
5
4
not used
default XXXXXX
3
2
1
trigger ambient light
1
0
trigger proximity
1
PS INTERVAL: Proximity measurement: time interval setting (repetition time) for FREE-RUNNING mode
R/W-Register 0x85
Bit
7
6
5
4
3
not used
2
1
time-interval
default XXXX
0101 100 ms
0000
10 ms
0001
20 ms
0010
30 ms
0011
50 ms
0100
70 ms
0101 100 ms
0110 200 ms
0111 500 ms
1000 1000 ms
1001 2000 ms
December 12, 2011
page 12 of 23
0
ALS INTERVAL: Ambient light measurement: time interval setting (repetition time) for FREE-RUNNING mode
R/W-Register 0x86
Bit
7
6
5
not used
4
3
default XXXXX
2
1
time-interval
500 ms
100 ms
200 ms
500 ms
1000 ms
2000 ms
0
2
1
Revision ID
0
2
0
010
000
001
010
011
100
PART_ID: Part number and revision Identification
R-Register 0x8A
Bit
7
6
5
4
Part number ID
1001
MAN_ID: Manufacturer Identification
R-Register 0x8B
Bit
7
6
5
0000
3
0100
4
3
Manufacturer Identification
0011
1
ALS_DATA_LSB: Ambient light measurement data (0x8C: LSB)
The result of the ambient light sensor is a 16bit word with MSB and LSB. It is stored in two registers. The binary data can be
converted directly to decimal „lx“ values (max. 65535lx).
R-Register 0x8C
Bit
7
6
5
4
3
2
1
0
2
1
0
LSB data
00000000
default
ALS_DATA_MSB: Ambient light measurement data (0x8D: MSB)
R-Register 0x8D
Bit
7
6
5
default
4
3
MSB data
00000000
ALS_PS STATUS: Status of measurement data for ambient light sensor (ALS) and proximity sensor (PS)
After the measurement data is available in the register (0x8E), the corresponding statusbit (bit #6 for ALS; bit #0 for PS) is set to „1“.
After data has been read by the MCU the statusbit is automatically reset to “0” by the SFH 7773.
Bit #7 is set „1“, if the measured ALS value is outside the threshold level settings (register 0x96... 0x99). Bit #1 is set to “1” if the
measured PS value is above the threshold level (register 0x93). The status of register 0x8E will always be updated if new
measurement data is available.
R-Register 0x8E
Bit
7
ALS
6
ALS
Threshold
default
5
4
3
2
Not used
data
00
December 12, 2011
1
PS LED
0
PS LED
threshold
0000
page 13 of 23
data
00
PS_DATA: Proximity measurement data (8bit, logarithmic scale)
R-Register 0x8F
Bit
7
6
5
4
3
2
1
0
data
00000000
default
INT_SET: Interrupt register / INT output.
In bit #6 and #5 the trigger source for the last interrupt event is stated. Data from status register (0x8E) are used. In latched mode
(set by bit #3) this remains unchanged until the interrupt register has been read by the MCU. Afterwards the bits are reset
automatically to “0” by the SFH 7773. In unlatched mode it is updated after every measurement. The output polarity of the interrupt
function can be changed by bit #2. The interrupt can be triggered by an ambient light sensor event and / or by a proximity sensor
event (bit #1 and bit #0). Z-state means the output is in high-impedance state.
R/W-Register 0x92
Bit
7
6
5
4
3
2
1
0
not
Interrupt
not
Output mode
Output
Interrupt mode
used
trigger source
used
polarity
(triggered by..)
R/W
not
R only
not
R/W
R/W
R/W
used
used
default
X 00
X
1
0
00
00 ALS
0 latched
0 active L
00 Z state
01 PS
1 not latched
1 active H
01 only PS
10 only ALS
No other values
allowed
11 PS and ALS
PS_THR LED: Threshold level for proximity sensor
RW-Register 0x93
Bit
7
6
5
4
3
2
1
0
1
0
1
0
1
0
1
0
data
11111111
default
ALS UP_THR LSB: Upper threshold level for ambient light sensor (LSB)
RW-Register 0x96
Bit
7
6
5
default
4
3
2
LSB data (upper threshold)
11111111
ALS UP_THR MSB: Upper threshold level for ambient light sensor (MSB)
RW-Register 0x97
Bit
7
6
5
default
4
3
2
MSB data (upper threshold)
11111111
ALS_LO_THR LSB: Lower threshold level for ambient light sensor (LSB)
RW-Register 0x98
Bit
7
6
5
default
4
3
2
LSB data (upper threshold)
11111111
ALS_LO_THR MSB: Lower threshold level for ambient light sensor (MSB)
RW-Register 0x99
Bit
7
default
December 12, 2011
6
5
4
3
2
LSB data (upper threshold)
11111111
page 14 of 23
9. Interrupt Alert
The SFH 7773 provides an interrupt pin,
which can be configured completely by the
user. The register 0x92 allows configuring
the interrupt as active low or active high.
Additionally, the interrupt function can be
configured to operate in latched or normal
mode. In normal mode the interrupt
event/signal is updated after every
measurement, whereas in the latched mode
it is guaranteed that even short peaks are
detected (e.g. the interrupt is held as long as
the microcontroller reads out the interrupt
register).
The interrupt can be set for a PS (PS
threshold) and/or ALS (upper and lower ALS
threshold) event. For the exact interrupt
event definition please refer to Tab. 4. This
is especially valuable as it allows the SFH
7773 to operate as stand alone device in the
free-running mode, independent from the
main microcontroller. This functionality
relieves the microcontroller from active
involvement in the PS / ALS monitoring
resp. measurement cycle and reduces
significantly the I2C-bus traffic, thus reducing
the overall power consumption of the
system. Only if the user-defined thresholds
are violated, the interrupt signal will inform
the microcontroller and the predefined
actions can be executed (e.g. after read-out
of the interrupt and PS / ALS data registers
to get the actual data - if desired).
10 Design-in Guidelines
10.1 Implementation behind Cover Glass
By implementing the SFH 7773 behind a
Interrupt Event Definition
proximity
PS data > PS threshold
sensor
ambient
ALS data > ALS upper threshold
light sensor ALS data < ALS lower threshold
Tab. 5: Interrupt event definition.
December 12, 2011
cover glass, two issues need to be taken
into account:
• crosstalk
• aperture
The second issue concerning a fully
functional design is the necessary aperture
to ensure a maximum of performance. This
concerns the ALS as well as the PS.
Please refer to Fig. 10 for the radiation
characteristics of the IR-LED (emitter). To
achieve the maximum switching distance,
the recommended minimum aperture (IRtransmissive cover glass) of the IR-LED
should be ± 50°. This value has been
minimized in order to reduce the cover
window opening size required for maximum
performance.
Similar considerations are valid for the
detector side (PS photodiode + ALS
photodiode). Please refer to Fig. 5 for the
ALS directivity. An aperture of ± 45° is
Cover
Transmission
(visible light)
100 %
50 %
20 %
10 %
corresponding
ALS range
outside
Cover
0.3 lx – 6553 lx
0.6 lx– 13000 lx
1.5 lx– 32500 lx
3.0 lx– 65535 lx
corr. ALS
resolution
outside
Cover
0.1 lx
0.2 lx
0.5 lx
1.0 lx
Tab. 6: Impact of cover glass transmission on
ALS range and resolution (based on an
integration time setting of 100 ms, resulting in
a conversion factor of typ. 0.1 lx/count of the
sensor).
Cover
Transmission
(at 850 nm)
100 % (no glass)
90 % (clear glass)
80 %
70 %
corresponding
detection distance
(approximation)
100 %
90 %
80 %
70 %
Tab. 7: Impact of cover glass
transmission on PS detection range.
page 15 of 23
(IR-)
recommended for the window opening (IR
and visible light transmissive) to get
maximum ALS also under tilted situations.
Fig.
16
illustrates
the
above
recommendations by utilizing a Ø 1.8 – 2.0
mm aperture (minimum recommended). In
case where larger airgaps are used OSRAM
recommends apertures of Ø ≥ 2.0 mm. Note
that the proximity sensor alone works also
with a smaller aperture (the PS detector
aperture is the same as the IR-LED (emitter)
but a too small aperture might impact the
detection distance).
The proposed design values do not count
for any manufacturing tolerances concerning
the placement of the component vs. cover
glass tolerances. Additionally it is worth to
mention, that the sensor works also if this
geometric guidelines are not followed.
However, this might lead - under worst case
circumstances - to some performance
reductions. It is also important to mention
that a reduced IR transmission of the cover
glass (at 850 nm) might also reduce the
maximum
switching
distance.
To
compensate for, it is recommended to either
increase the LED current or/and reduce the
PS threshold level in the relevant register.
As a rule of thumb, a 25 % one way
transmission loss at 850 nm reduces the
signal at the sensor site by a factor of 0.56
resp. the PS signal by around 13 counts and
results in a reduction of the detection range
by around a factor of 1.4 (note the pseudologarithmic scale of the counts vs. detector
irradiance, see also Sec. 5.2). Please refer
to Tab. 7 for an overview.
By implementing dark cover glasses in front
of the SFH 7773 one has to take into
account
the
spectral
transmission
characteristics of the glass in order to get
the correct readings from the ALS. E.g. a
dark cover glass (90 % attenuation) means
that the measured ALS count of 100
corresponds now to 1000 lx in front of the
cover vs. 100 lx at the sensor (see also Tab.
6). The overall spectral transmission
characteristics of the cover glass might also
impact the accuracy concerning different
light sources (different attenuation of IR vs.
visible light). Please contact your local
OSRAM technical team for more support on
these issues.
For
optimized
performance
OSRAM
recommends to avoid placing the sensor
close to other components or objects as
their
reflections
might
impair
the
performance of the sensor. It is
recommended to have black, low reflective
structures next to the sensor.
Fig. 16: Aperture design for cover glass. The above values represent an arrangement, without
considering mechanical tolerances. Performance evaluation is recommended in any case to
verify the viability of the design. Note that the sensor also performs in a less than ideal
environment (e.g. smaller apertures). For larger airgaps a larger aperture diameter is
recommended. Low reflective structures are recommended in the vicinity of the sensor for
optimized performance.
December 12, 2011
page 16 of 23
CATH
VLED
SDA
SCL
INT
SCL
SDA
INT
VDD
GNDDD
GNDLED
C3 100 nF
C1 100 nF
C4 4.7 uF
C2 1.0 uF
VLED GNDLED VDD GNDDD
Fig. 17: Suggested setup for evaluation of
the SFH7773 in a laboratory environment. R
and C improve the dynamics of the power
supply. C1 and C3 should be placed next to
the respective supply pins (same for C2 and
C4). Special considerations should be paid
to separate the supply circuits (VDD and
VLED).
10.2 Power Supply Circuit
This section is especially important for
evaluation/operation of the SFH 7773 in a
laboratory environment. Especially as
regulated laboratory power supplies behave
different compared to batteries (like used in
e.g. mobile phones). This needs to be
considered if the SFH7773 is operated with
regulated laboratory power supplies.
In general, regulated voltage supplies
should be avoided. Especially as the LED
current bursts can influence the overall
stability of the supply circuit. This instability
can deteriorate the operating characteristics
of the proximity sensor. This effect is not
observed to occur during normal operation
of the sensor with batteries, storage
batteries, or stabilized voltage supplies.
The LED is driven with a current between 5
mA to 200 mA in burst mode (667 kHz).
Therefore any series resistor between the
VLED / GNDLED pins and the power supply
causes a voltage drop during the IR-LED
pulse. In general, any voltage drop within
the VLED circuit during the LED burst current
must be minimized. A capacitor in the range
of few µF as close to the supply pins of the
SFH 7773 may help to overcome this issue,
as mentioned in Sec. 10.3. The same
December 12, 2011
Fig. 18: Layout suggestion for a single
sided pcb: The power supply circuits must
be decoupled to achieve a low noise
operation of the PS with high LED drive
current. C1 and C3 need to be placed next
to the respective pins (as well as C2 and
C4).
principle applies for the VDD circuit (ASIC
supply).
To support the user the SFH 7773 provides
separated GND connections. One for the
LED current driver (pin 2, GNDLED), one for
the supply of the ASIC (pin 4, GNDDD). For
proper operation this ground lines have to
be separated and decoupled, like depicted
in Fig. 17 and 18. In general we recommend
buffering a laboratory power supply directly
with some 1000 μF and use a load resistor
in parallel to increase the dynamics of the
power supply to best emulate a battery-like
environment like in e.g. mobile phone (see
Fig. 16).
10.3 Circuit and Layout Considerations
To achieve maximum sensitivity concerning
the proximity functionality it is mandatory to
have a stable (battery-like) power supply
(see also Sec. 10.2).
The recommendation therefore is to connect
VLED directly to the battery. This ensures the
necessary LED current during the burst
operation (up to 200 mA peak, depending
on the actual settings of the proximity
sensors LED current). It is further
recommended to use capacitors as close to
the component as possible. This ensures
minimum voltage drops at the supply pins of
page 17 of 23
Fig. 19: Recommended implementation into
a mobile phone environment.
20: Recommended soldering pad design.
the SFH 7773 and provides the necessary
peak burst current. Typ. values are 100 nF ||
4.7 µF at the VLED side (for up to 200 mA
burst current) and 100 nF || 1.0 µF for the
VDD circuit (ASIC supply). The 4.7 µF
capacitor can be reduced if the LED burst
circuit is reduced to lower levels, e.g. 50
mA.
Fig. 18 illustrates an arrangement for a
single sided pcb layout. Using a double
sided pcb and placing the capacitors directly
beneath the resp. pin is also recommended.
The separation/decoupling of the VDD / VLED
via separate ground pins provide the
necessary stability during the high emitter
current bursts (up to 200 mA peak, 667
kHz). Additionally it ensures the stability of
the VDD circuit during the LED current bursts.
Additionally the capacitors are necessary to
isolate the sensor from other possible noise
sources on the same power line and
guarantee a low noise operation. This is
especially important in a laboratory
environment, if regulated power supplies are
used, which often have poor pulse current
capabilities – see recommendation above.
e.g. 10 kΩ). Please note the actual value of
the pull-up resistor depends - among other
issues - on the total load and
communication speed of the I2C-bus.
Fig. 19 illustrates a recommendation for
implementing the SFH 7773 into a mobile
phone environment.
The SCL, SDA and INT lines require pull-up
resistors to the logic voltage (VIO). The limits
for the logic levels are according to the I2Cbus specification (1.6 V to 2.0 V) [2]. The
recommended value for Rp is 560 Ω (up to
December 12, 2011
Fig. 20 presents a reference soldering-pad
design. Please refer to the SFH 7773
datasheet
for
the
most
up-to-date
recommendation.
11. Device Handling and Cleaning
In order to protect the semiconductor chips
from environmental influences, e.g. in the
soldering environment, a tape based
encapsulant is used. Since this tape is very
elastic and soft, mechanical stress or
damage to the tape should be avoided
during processing/assembly. The tape must
not be removed under any circumstances.
Excessive force applied to the cover (tape)
can lead to a spontaneous failure of the
component (damage to the contacts). To
prevent damaging or puncturing the tape,
the use of all types of sharp objects should
be avoided both in the laboratory and
factory environments.
Cleaning
In general, OSRAM Opto Semiconductors
does not recommend a wet cleaning
process for components like the SFH 7773
as the package is not hermetically sealed.
Due to the open design, all kind of cleaning
liquids can infiltrate the package and cause
page 18 of 23
degradation or a complete failure of the
component. It is also recommended to
prevent penetration of organic substances
from the environment which could interact
with the hot surfaces of the operating chips.
Ultrasonic cleaning is generally not
recommended for all types of LEDs (see
also the application note "Cleaning of
LEDs").
As is standard for the electronic industry,
OSRAM Opto Semiconductors recommends
using low-residue or no-clean solder paste,
so that PCB cleaning after soldering is no
longer required.
In any case, all materials and methods
should be tested beforehand in order to
determine whether the component will be
damaged in the process.
12. Sample Software Code
Below are simple C-codes which can be
used to operate the SFH 7773 in connection
with a microcontroller (e.g. PIC18F46J50
from Microchip). The program consists of
the commented main micro C-code for the
microcontroller, using the two subroutines
I2C_w_3:
3 write statements
I2C_w_2_r_1: 2 write and 1 read statement.
The main program can be implemented into
a repeating loop to get the actual PS resp.
ALS data or operate in interrupt mode.
12.1 Operating the ALS
12.1.1 C-code in main program:
sfh_address = 0x38;
I2C_w_3 (sfh_address*2, 0x80, 0x03);
I2C_w_2_r_1 (sfh_address*2, 0x8C);
lux = Content;
I2C_w_2_r_1 (sfh_address*2, 0x8D);
lux = (lux + Content* 256);
// address of SFH 7773
// initialize ALS of the SFH 7773
// read low byte of ALS, register 0x8C
// read high byte of ALS, register 0x8D
// combining low+high byte to decimal value
12.1.2 I2C_w_3 subroutine
void I2C_w_3
(unsigned char addw, unsigned char com, unsigned char daw)
{
unsigned char var;
OpenI2C (MASTER, SLEW_ON);
// Configures I2C bus module, 100 kHz transfer
SSP1ADD = 0x27;
// setting I2C 100 kHz frequency with f osc = 16 MHz
StartI2C ();
// Generates I2C bus start condition
IdleI2C ();
// Loop till I2C bus is idle
var = WriteI2C(addw);
// Microchips’ Write command to write device address
if (var == 0) write_s++;
// var = 0: no bus error
if (var == -1) write_c++;
// var = -1: slave did not acknowledge write
if (var == -2) write_ac++;
// var=-2:write collision (bus not ready to tx)
if (var < 0) goto stop;
// stop further transmission if error occurred
var = WriteI2C(com);
if (var == 0) write_s++;
if (var == -1) write_c++;
if (var == -2) write_ac++;
if (var < 0) goto stop;
//
//
//
//
var = WriteI2C(daw);
if (var == 0) write_s++;
if (var == -1) write_c++;
if (var == -2) write_ac++;
// write register content
stop:
StopI2C ();
CloseI2C ();
write device register address
counting of good transmissions
counting of no acknowledge errors
counting of write collision errors
// generates I2C bus stop condition
// master I2C module disabled
}
December 12, 2011
page 19 of 23
12.1.3 Subroutine I2C_w_2_r_1
void I2C_w_2_r_1 (unsigned char addr, unsigned char com)
{
unsigned char var;
OpenI2C (MASTER, SLEW_ON);
SSPADD = 0x27;
StartI2C ();
IdleI2C ();
var = WriteI2C(addr);
if (var == 0) read_s++;
if (var == -1) read_c++;
if (var == -2) read_ac++;
if (var < 0) goto stop;
var = WriteI2C(com);
if (var == 0) read_s++;
if (var == -1) read_c++;
if (var == -2) read_ac++;
if (var < 0) goto stop;
RestartI2C ();
IdleI2C ();
var = WriteI2C(addr+1);
if (var == 0) read_s++;
if (var == -1) read_c++;
if (var == -2) read_ac++;
if (var < 0) goto stop;
Content = 0;
Content = ReadI2C ();
SSPCON2bits.ACKDT = 1;
SSPCON2bits.ACKEN = 1;
PIR1bits.SSPIF = 0;
while (SSPCON2bits.ACKEN == 1);
PIR1bits.SSPIF = 0;
stop:
StopI2C ();
CloseI2C ();
// generates I2C bus restart condition
// No master Acknowledge to terminate sequence
// sending No Acknowledge bit
// waiting till NA causes interrupt
}
12.2 Operating the PS
Below is a small C-code for the main program to operate the proximity sensor of the SFH 7773.
The two subroutines, I2C_w_3 and I2C_w2_r1 are the same as above (see Sec. 12.1.2 and
12.1.3).
C-code for main program:
sfh_address = 0x38;
I2C_w_3 (sfh_address*2, 0x81, 0x03);
I2C_w_3 (sfh_address*2, 0x82, 0x1E);
I2C_w_2_r_1 (sfh_address*2, 0x8F);
PS = Content;
//
//
//
//
address of SFH 7773
initialize PS of the SFH 7773
set PS LED current to 200 mA
read data byte of PS, register 0x8F
12.3 Operating the ALS and PS in Interrupt Mode
The small C-code below operates the SFH 7773 in the interrupt mode. The ALS and PS are in
free-running mode. The interrupt event can occur through an ALS or PS event. The limits for
ALS (LB_LL, HB_LL, LB_HL, HB_HL) and PS (Prox_Limit) are set within the program.
After the interrupt has triggered the microcontroller the relevant sensor is determined and the
ALS or PS value is read out.
December 12, 2011
page 20 of 23
C-code for main program:
// ALS:
I2C_w_3
I2C_w_3
I2C_w_3
I2C_w_3
I2C_w_3
I2C_w_3
(0x38*2,
(0x38*2,
(0x38*2,
(0x38*2,
(0x38*2,
(0x38*2,
0x80,
0x86,
0x98,
0x99,
0x96,
0x97,
0x03);
0x00);
LB_LL);
HB_LL);
LB_HL);
HB_HL);
//
//
//
//
//
//
ALS free running mode
new data every 100 ms
setting low byte of low ALS limit
setting high byte of low ALS limit
setting low byte of high ALS limit
setting high byte of high ALS limit
(0x38*2,
(0x38*2,
(0x38*2,
(0x38*2,
0x81,
0x82,
0x85,
0x93,
0x03);
0x1E);
0x00);
Prox_Limit);
//
//
//
//
Prox free running mode
IR LED with 200 mA
new data every 10 ms
setting byte for high prox limit
// Prox:
I2C_w_3
I2C_w_3
I2C_w_3
I2C_w_3
I2C_w_3
(0x38*2, 0x92, 0x03);
latched and ground when active
// interrupt triggered by PS and ALS,
// Interrupt routine:
// called when interrupt happened
I2C_w_2_r_1 (0x38*2, 0x8E);
// reading Status Register, Function returns register value as variable Content
if ( (Content & 0x80) == 0x80)
// &=bitwise AND,check whether ALS triggered interrupt
{
I2C_w_2_r_1 (0x38*2, 0x8C);
// read low byte of ADC, register 0xC
Content1 = Content;
I2C_w_2_r_1 (0x38*2, 0x8D);
// read high byte of ADC, register 0xD
Lux = Content * 256 + Content1;
}
Else
sensor
{
// Interrupt must be caused by prox
I2C_w_2_r_1 (0x38*2, 0x8F);
Prox = Content;
// read Prox data register 0x8F
// Value in uW/cm^2 =10power(Content/51)
}
// end of interrupt routine
12.4 Implementation into a Mobile Phone
Environment
Below are two example flowcharts,
describing how the SFH 7773 can be
implemented into a microcontroller based
mobile phone environment. The interrupt
function allows for low-power stand-alone
operation of the device.
The first flowchart illustrates a possible
operation of the ambient light sensor, the
second flowchart relates to the operation of
the proximity sensor.
12.4.1 Operation of the ALS
Fig. 21 illustrates a flowchart for a
microcontroller based ambient light sensing
example. The interrupt (set to active low)
December 12, 2011
alerts the microcontroller only in case the
actual ambient light value is outside of the
defined ALS window. Using the interrupt
functionality and operating the SFH 7773 in
the free-running mode helps to minimize
traffic on the I2C-bus as well as to relieve the
microcontroller from unnecessary work load.
This arrangement helps to save valuable
battery power.
By adapting dynamically new thresholds
(with hysteresis) relative to the actual ALS
value (after an interrupt event took place) it
is possible to define very fine steps for
adapting the display brightness (quasicontinuous).
By inverting the interrupt polarity (register
0x92) the interrupt alert function can be
inverted from outside the ALS window to
page 21 of 23
inside the ALS window (only in non-latched
mode).
Like
stated
above,
it
is
recommended to use a hysteresis by
defining the thresholds in order to avoid
flickering of the interrupt event.
12.4.2 Operation of the PS
Fig. 22 illustrates the flowchart for a
microcontroller based proximity sensing
example. Operating the SFH 7773 in the
stand alone mode plus using the interrupt
functionality helps to save battery power.
The interrupt (set to active low) alerts the
microcontroller only in case an object
passes a certain distance threshold
(towards the sensor, e.g. in a mobile
phone). This allows the mobile phone to
turn-off the display e.g. during a call to save
battery power.
A new threshold (with hysteresis) and the
inverting of the interrupt logic of the SFH
7773 - after an event has taken place - allow
to adapt the sensor to detect the motion in
the opposite direction (only for non-latched
interrupt mode). By adapting dynamically
new thresholds it is recommended to set a
certain hysteresis level to avoid flickering of
the interrupt event.
Fig. 21: Flowchart for a microcontroller based ambient light sensing example.
December 12, 2011
page 22 of 23
Fig. 22: Flowchart for a microcontroller based proximity sensing example.
13. Literature
[1] OSRAM-OS: http://www.osram-os.com.
[2] “UM10204 I2C-bus specification and user manual” from NXP Rev. 03 – 19 June 2007
Author: Dr. Hubert Halbritter
About Osram Opto Semiconductors
Osram Opto Semiconductors GmbH, Regensburg, is a wholly owned subsidiary of Osram GmbH,
one of the world’s three largest lamp manufacturers, and offers its customers a range of solutions
based on semiconductor technology for lighting, sensor and visualisation applications. The
company operates facilities in Regensburg (Germany), Sunnyvale (USA) and Penang (Malaysia).
Further information is available at www.osram-os.com.
All information contained in this document has been checked with the greatest care. OSRAM Opto
Semiconductors GmbH can however, not be made liable for any damage that occurs in connection
with the use of these contents.
December 12, 2011
page 23 of 23