Designing VCNL3020 into an Application

VISHAY SEMICONDUCTORS
www.vishay.com
Optical Sensors
Application Note
Designing VCNL3020 into an Application
INTRODUCTION AND BASIC OPERATION
The VCNL3020 is a proximity sensor with I2C interface. It
combines an infrared emitter, PIN photodiode, and signal
processing IC in a single package with a 16 bit ADC. With a
range of up to 20 cm (7.9"), this stand-alone, single
component greatly simplifies the use and design-in of a
proximity sensor in consumer and industrial applications
because no mechanical barriers are required to optically
isolate the emitter from the detector. The VCNL3020
features a miniature leadless package (LLP) for surface
mounting in a 4.9 mm x 2.3 mm package with a low profile
of 0.83 mm designed specifically for the low height
requirements of smart phone, mobile phone, digital camera,
and tablet PC applications. Through its standard I2C bus
serial digital interface, it allows easy access to a “Proximity
Signal” measurement without complex calculations or
programming. The programmable interrupt function offers
wake-up functionality for the microcontroller when a
proximity event occurs which reduces processing overhead
by eliminating the need for continuous polling.
SCL
INT
SDA
VDD
Cathode
PD
22640
VSS
Cathode
Emitter
Anode
Emitter
Fig. 1 - VCNL3020 Top View
Fig. 2 - VCNL3020 Bottom View
COMPONENTS (BLOCK DIAGRAM)
The major components of the VCNL3020 are shown in the block diagram.
IRED
IR Anode 1
10 IR Cathode
9 GND
INT 3
VCNL 3020
ASIC
8 GND
SCL 4
VDD 5
7 nc
Proxi PD
6 nc
Fig. 3 - VCNL3020 Detailed Block Diagram
Revision: 13-Aug-14
Document Number: 84139
1
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
APPLICATION NOTE
SDA 2
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
The integrated infrared emitter has a peak wavelength of
890 nm. It emits light that reflects off an object within 20 cm
of the sensor. The infrared emitter spectrum is shown in
Figure 4.
Ie, rel - Relative Radiant Intensity
1.1
IF = 100 mA
1.0
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
750
800
850
900
950
1000
1050
λ - Wavelength (nm)
Fig. 4 - Relative Radiant Intensity vs. Wavelength
22305
The infrared emitter has a programmable drive current from
10 mA to 200 mA in 10 mA steps. The infrared light emitted
is modulated at one of four user defined carrier frequencies:
390.625 kHz, 781.25 kHz, 1.5625 MHz (not recommended),
or 3.125 MHz (not recommended).
The PIN photodiode receives the light that is reflected off
the object and converts it to a current. It has a peak
sensitivity of 890 nm, matching the peak wavelength of the
emitter. It is insensitive to ambient light. It ignores the DC
component of light and “looks for” the pulsed light at one of
the two recommended frequencies used by the emitter.
Using a modulated signal for proximity provides distinct
advantages over other sensors on the market.
APPLICATION NOTE
The application specific integrated circuit or ASIC includes
an LED driver, I2C bus interface, amplifier, integrating analog
to digital converter, oscillator, and Vishay’s “secret sauce”
signal processor. For proximity, it converts the current from
the PIN photodiode to a 16-bit digital data output value.
PIN CONNECTIONS
Figure 3 shows the pin assignments of the VCNL3020.
The connections include:
• Pin 1 - IR anode
• Pin 2 - SDA to microcontroller
• Pin 3 - INT to microcontroller
• Pin 4 - SCL to microcontroller
• Pin 5 - VDD to the power supply
• Pin 6, pin7 - must not be connected
• Pin 8, pin 9 - GND
The power supply for the ASIC (VDD) has a defined range
from 2.5 V to 3.6 V. The infrared emitter may be connected
in the range from 2.5 V to 5.0 V. It is best if VDD is connected
to a regulated power supply and pin 1, IR Anode, is
connected directly to the battery. This eliminates any
influence of the high infrared emitter current pulses on the
VDD supply line. The ground pins 8 and 9 are electrically the
same. They use the same bottom metal pad and may be
routed to the same stable ground plane. The power supply
decoupling components shown in Figure 5 are optional.
They isolate the sensor from other possible noise on the
same power rail but in most applications are not needed. If
separate power supplies for the VDD and the infrared emitter
are used and there are no negative spikes below 2.5 V, only
one capacitor at VDD could be used. The 100 nF capacitor
should be placed close to the VDD pin. The SCL and SDA as
well as the interrupt lines need pull-up resistors. The resistor
values depend on the application and on the I2C bus speed.
Common values are about 2.2 kΩ to 4.7 kΩ for the SDA and
SCL and 10 kΩ to 100 kΩ for the Interrupt.
2.5 V to
5.0 V
C1
1.7 V .. 5.0 V
C2
22 μF 100 nF
2.5 V to
3.6 V
R1
10R
10 μF
C4
C3
R2 R3 R4
IR_Anode (1)
VDD (5)
Host
Micro
Controller
100 nF
VCNL3020
INT (3)
SCL (4)
GND (8, 9) SDA (2)
GPIO
I2C bus clock SCL
I2C bus data SDA
Fig. 5 - VCNL3020 Application Circuit
MECHANICAL DESIGN CONSIDERATIONS
The VCNL3020 is a fully integrated proximity sensor. Some
competing sensors use a discrete infrared emitter which
leads to complex geometrical calculations to determine the
position of the emitter. Competing sensors also require a
mechanical barrier between the emitter and detectors to
eliminate crosstalk; light reflecting off the inside of the
window cover which can produce false proximity readings.
The VCNL3020 does not require a mechanical barrier.
The signal processor continuously compensates for the light
reflected from windows ensuring a proper proximity reading.
As a fully integrated sensor, the design process is greatly
simplified.
The only dimensions that the design engineer needs to
consider are the distance from the top surface of the sensor
to the outside surface of the window and the size of the
window. These dimensions will determine the size of the
detection zone.
• Pin 10 - IR cathode
Revision: 13-Aug-14
Document Number: 84139
2
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
The angle of half intensity of the emitter and the angle of half
sensitivity of the PIN photodiode are ± 55° as shown in
Figure 6 and Figure 7.
20°
1.0
0.9
40°
0.8
0.7
60°
0.6
ϕ - Angular Displacement
Irel - Relative Radiant Intensity
0°
The center of the sensor and center of the window should be
aligned. Assuming the detection zone is a cone shaped
region with an angle of ± 40°, the following are dimensions
for the distance from the top surface of the sensor to the
outside surface of the glass, d, and the width of the window,
w. The distance from the center of the infrared emitter to the
center of the PIN photodiode is 3.46 mm. The height of the
sensor is 0.83 mm.
w
x
3.46
D
d
α
80°
0.83
0.5 0.4 0.3 0.2 0.1 0
22306
Fig. 9 - Window Dimensions
Fig. 6 - Angle of the Half Intensity of the Emitter
20°
1.0
0.9
40°
0.8
0.7
60°
0.6
ϕ - Angular Displacement
Srel - Relative Sensitivity
0°
80°
0.5 0.4 0.3 0.2 0.1 0
22308
d
(mm)
x
(0.84 d)
w
(3.46 + 2 x)
0.5
0.42
4.30
1.0
0.84
5.14
1.5
1.26
6.02
2.0
1.68
6.82
2.5
2.10
7.66
3.0
2.52
8.50
The results above represent the ideal width of the window.
The mechanical design of the device may not allow for this
size.
Fig. 7 - Angle of the Half Sensitivity of the PIN Photodiode
APPLICATION NOTE
PROXIMITY SENSOR
α = ± 55°
3.46
The main DC light sources found in the environment are
sunlight and tungsten (incandescent) bulbs. These kinds of
disturbance sources will cause a DC current in the detector
inside the sensor, which in turn will produce noise in the
receiver circuit. The negative influence of such DC light can
be reduced by optical filtering. Light in the visible range,
400 nm to 700 nm, is completely removed by the use of an
optical cut-off filter at 800 nm. With filtering, only longer
wavelength radiation above 800 nm can be detected. The
PIN photodiode therefore receives only a limited band from
the original spectrum of these DC light sources as shown in
Figure 10.
Fig. 8 - Emitter and Detector Angle and Distance
Revision: 13-Aug-14
Document Number: 84139
3
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
S(λ)rel - Relative Spectral Sensitivity
1.1
1.0
Reflected signal
0.9
0.8
0.7
0.6
0.5
0.4
Offset
-
Noise floor
=
Proximity count
22382
Fig. 12 - Proximity Calculation
0.3
0.2
0.1
0
400
500
600
700
800
900
1000 1100
λ - Wavelength (nm)
Fig. 10 - Spectral Sensitivity of Proximity PIN Photodiode
22307
As mentioned earlier, the proximity sensor uses a
modulated carrier signal on one of four user selected
frequencies. These frequencies are far from the ballast
frequencies of fluorescent lights ensuring that the sensor is
unaffected by them. The infrared emitter sends out a series
of pulses, a burst, at the selected frequency and the PIN
photodiode which features a band pass filter set to this
same frequency, receives the reflected pulses, Figure 11.
153 μs
100 mA
100 ms
LED ON time = 164 μs - 11 μs = 153 μs
Fig. 11 - Emitter Pulses
APPLICATION NOTE
-
Offset
• distance to the cover
• proximity of surrounding
components
• tolerances of the sensor
• defined IRED current
• ambient temperature
• type of cover material used
• ambient light
In addition to DC light source noise, there is some reflection
of the infrared emitted light off the surfaces of the
components which surround the VCNL3020. The distance
to the cover, proximity of surrounding components, the
tolerances of the sensor, the defined infrared emitter
current, the ambient temperature, and the type of window
material used all contribute to this reflection. The result of
the reflection and DC noise produces an output current on
the proximity and light sensing photodiode. This current is
converted in to a count called the offset count.
Results typically do not need to be averaged. If an object
with very low reflectivity or at longer range needs to be
detected, the sensor provides a register where the customer
can define the number of consecutive measurements above
a user-defined threshold before producing an interrupt. This
provides stable results without requiring averaging.
PROXIMITY CURRENT COSUMPTION
The standby current of the VCNL3020 is 1.5 μA. In this
mode, only the I2C interface is active. In most consumer
electronic applications the sensor will spend the majority of
time in standby mode. For proximity sensing, the current
consumption of the VCNL3020 is primarily a function of the
infrared emitter current and, secondarily, signal processing
done by the ASIC. Example current consumption
calculations are shown below for the range of IRED current
and measurement rates. The current between burst pulse
frames is equivalent to the standby mode. The duty cycle of
the emitter is 50 %.
10 measurement per second, emitter current = 100 mA
ASIC: 2.71 mA x 164 μs x 10/1 s =
4.45 μA
IRED: 100 mA x 153 μs/1 s x 0.5 x 10/1 s =
76.50 μA
total:
80.95 μA
250 measurement per second, emitter current = 200 mA
ASIC: 2.71 mA x 164 μs x 250/1 s =
111.0 μA
IRED: 200 mA x 153 μs x 0.5 x 250/1 s =
3.825 mA
total:
3.936 mA
In addition to the offset, there is also a small noise floor
during the proximity measurement which comes from the
DC light suppression circuitry. This noise is in the range from
± 5 counts to ± 20 counts. The application should “ignore”
this offset and small noise floor by subtracting them from the
total proximity readings. The application specific offset is
easily determined during the development of the end
product.
Revision: 13-Aug-14
Document Number: 84139
4
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
PROXIMITY INITIALIZATION
The VCNL3020 contains fourteen 8-bit registers for
operation control, parameter setup and result buffering. All
registers are accessible via I2C communication. The built in
I2C interface is compatible with all I2C modes: standard, fast
and high speed. I2C H-Level voltage range is from 1.7 V to
5.0 V.
There are only three registers out of the fourteen that
typically need to be defined:
performed. The sensor starter kit allows you to perform
evaluation tests and properly set the registers for your
application. The kit is available from any of Vishay’s
distributors. It comes with the VCNL4020 sensor board. The
VCNL3020 sensor board can be requested by sending an
e-mail to [email protected].
Timing
2. Proximity Measurement Rate = 1.95 … 250 meas/s
Proximity Rate Register #2 [82h]
For an I2C bus operating at 100 kHz, an 8-bit write or read
command which includes the start, stop and acknowledge
bits takes 100 μs. When the device is powered on, the
initialization with just these 3 registers needs 3 write
commands, each requiring 3 bytes: slave address, register
and data.
3. Proximity number of
above/below threshold:
Power Up
1. IRED Current = 10 mA… 200 mA
IR LED Current Register #3 [83h]
consecutive
measurements
- int_count_exceed = 1…128
enabling interrupt generation, int_thres_en = 1
The release of internal reset, the start of the oscillator and
signal processor needs
2.5 ms
Interrupt Control Register # 9 [89h].
Initialize Registers
To define the infrared emitter current, evaluation tests
should be performed using the least reflective material at the
maximum distance specified.
Write to 3 registers
Figure 13 shows the typical digital counts output versus
distance for three different emitter currents. The reflective
reference medium is the Kodak Gray card. This card shows
approximately 18 % reflectivity at 890 nm.
- Proximity rate
100 000
900 μs
- IR LED current
- Interrupt control
Once the device is powered on and the VCNL3020
initialized, a proximity measurement can be taken. Before
the first read out of the proximity count, a wait time is
required. Subsequent reads do not require this wait time.
LED current 200 mA
Proximity Value (cts)
10 000
1000
300 μs
170 μs
Wait time prior to first read
400 μs
Read out of the proximity data
LED current 100 mA
100
LED current 20 mA
1
1
10
100
Distance to Reflecting Card (mm)
Fig. 13 - Proximity Value vs. Distance
The proximity measurement rate determines how fast the
application reacts when an object appears in, or is removed
from, the proximity zone. Reaction time is also determined
by the number of counts that must be exceeded before an
interrupt is set.
To define these register values, evaluation test should be
Revision: 13-Aug-14
1470 μs
INTERRUPT
Media: Kodak gray card
0.1
600 μs
Total:
10
APPLICATION NOTE
Start measurement
Measurement being made
The VCNL3020 features an interrupt function. The interrupt
function enables the sensor to work independently until a
predefined proximity threshold is met. It then sets an
interrupt which requires the microcontroller to awaken. This
helps customers reduce their software effort, and reduces
power consumption by eliminating polling communication
traffic between the sensor and microcontroller. The interrupt
pin, Pin 3 of the VCNL3020, should be connected to a
dedicated GPIO of the controller. A pull-up resistor is added
to the same power supply to which the controller is
connected. This INT pull-up resistor may be in the range of
1 kΩ to 100 kΩ. Its current sinking capability is greater than
8 mA, typically 10 mA, and less than 20 mA.
Document Number: 84139
5
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
The events that can generate an interrupt include:
1. A lower and an upper threshold for the proximity value
can be defined. If the proximity value falls below the lower
limit or exceeds the upper limit, an interrupt event will be
generated. In this case, an interrupt flag bit in one of the
registers of the device will be set and the interrupt pad of
the ASIC will be pulled to low by an open drain pull-down
circuit. In order to eliminate false triggering of the
interrupt by noise or disturbances, it is possible to define
the number of consecutive measurements that have to
occur before the interrupt is triggered.
2. An interrupt can be generated when a proximity
measurement is ready.
For each of these conditions a separate bit can activate or
deactivate the interrupt. This means that a combination of
different conditions can occur simultaneously.
When an interrupt is generated, the information about the
condition that has generated the interrupt will be stored and
is available for the user in an interrupt status register which
can be read out via I2C. Each condition that can generate an
interrupt has a dedicated result flag. This allows
independent handling of the different conditions.
For example, if the interrupt is generated by the upper
threshold condition and a measurement ready condition,
both flags are set.
To clear the interrupt line, the user has to clear the enabled
interrupt flag in the interrupt status register, register #14.
Resetting the interrupt status register is done with an I2C
write command. One interrupt bit can be cleared without
affecting another. If there was a second interrupt source, it
would have to be cleared separately. With a write command
where all of the interrupt bits are set to “1” all these bits and
the interrupt line is cleared or reset.
REGISTER FUNCTIONS
Register #0 Command Register
Register address = 80h
Register #0 is for starting proximity measurements. The register contains a flag bit for data ready indication.
TABLE 1 - COMMAND REGISTER #0
BIT 7
config_lock
BIT 6
BIT 5
BIT 4
BIT 3
BIT 2
BIT 1
BIT 0
n/a
prox_data_ rdy
n/a
prox_od
n/a
prox_en
selftimed_en
DESCRIPTION
config_lock
Read only bit. Value = 1
prox_data_rdy
Read only bit. Value = 1 when proximity measurement data is available in the result registers. This bit will
be reset when one of the corresponding result registers (reg #7, reg #8) is read.
prox_od
R/W bit. Starts a single on-demand measurement for proximity.
Result is available at the end of conversion for reading in the registers #7 (HB) and #8 (LB).
prox_en
R/W bit. Enables periodic proximity measurement
selftimed_en
R/W bit. Enables state machine and LP oscillator for selftimed measurements; no measurement is
performed until the corresponding bit is set.
For periodic measurements, the selftimed_en bit must be set first, then the prox_en bit can be set. On-demand measurement
modes are disabled when the selftimed_en bit is set.
APPLICATION NOTE
To avoid synchronization problems and undefined states between the clock domains, changes to the proximity rate in register
#2 can be made only when there are no selftimed measurements being made, b0 (selftimed_en bit) = 0.
Register #1 Product ID Revision Register
Register address = 81h. This register contains information about product ID and product revision.
Register data value of current revision = 21h.
TABLE 2 - PRODUCT ID REVISION REGISTER #1
BIT 7
BIT 6
BIT 5
BIT 4
PRODUCT ID
BIT 3
BIT 2
BIT 1
BIT 0
REVISION ID
DESCRIPTION
Product ID
Read only bits. Value = 2
Revision ID
Read only bits. Value = 1
Revision: 13-Aug-14
Document Number: 84139
6
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
Register #2 Rate of Proximity Measurement
Register address = 82h. This register contains the rate of proximity measurements to be carried out within 1 second.
TABLE 3 - PROXIMITY RATE REGISTER #2
BIT 7
BIT 6
BIT 5
BIT 4
BIT 3
BIT 2
BIT 1
BIT 0
Rate of proximity measurement
(no. of measurements per second)
n/a
DESCRIPTION
R/W bits.
000 - 1.95 measurements/s (default setting)
001 - 3.90625 measurements/s
010 - 7.8125 measurements/s
Proximity rate
011 - 16.625 measurements/s
100 - 31.25 measurements/s
101 - 62.5 measurements/s
110 - 125 measurements/s
111 - 250 measurements/s
Again, if selftimed measurements are being made, any new measurement rate written to this register will not be made until
selftimed_en measurement is stopped.
Register #3 LED Current Setting for Proximity Mode
Register address = 83h. This register is to set the current of the infrared emitter for proximity measurements. The value is
adjustable from 0 mA to 200 mA in 10 mA steps. This register also contains information about the used device fuse program ID.
TABLE 4 - IR LED CURRENT REGISTER #3
BIT 7
BIT 6
BIT 5
BIT 4
BIT 3
Fuse prog ID
BIT 2
BIT 1
BIT 0
Infrared emitter current
DESCRIPTION
Fuse prog ID
Read only bits. Information about fuse program revision used for initial setup/calibration of the device.
R/W bits. IR LED current = Value (dec.) x 10 mA.
Valid Range = 0 - 20d (00 - 14h)
0 = 0 mA
1 = 10 mA
APPLICATION NOTE
2 = 20 mA (default setting)
Infrared emitter current value
.
.
20 = 200 mA
LED Current is limited to 200 mA. If higher values than 20 (20d) are written, the current will be set to
200 mA.
Revision: 13-Aug-14
Document Number: 84139
7
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
Register #7 and #8 Proximity Measurement Result Register
Register address = 87h and 88h. These registers are the result registers for proximity measurement readings. The result is a
16 bit value. The high byte is stored in register #7 and the low byte in register #8.
TABLE 8 - PROXIMITY RESULT REGISTER #7
BIT 7
BIT 6
BIT 5
BIT 4
BIT 3
BIT 2
BIT 1
BIT 0
BIT 3
BIT 2
BIT 1
BIT 0
DESCRIPTION
Read only bits. High byte (15:8) of proximity measurement result
TABLE 9 - PROXIMITY RESULT REGISTER #8
BIT 7
BIT 6
BIT 5
BIT 4
DESCRIPTION
Read only bits. Low byte (7:0) of proximity measurement result
Register #9 Interrupt Control Register
Register address = 89h.
TABLE 10 - INTERRUPT CONTROL REGISTER #9
BIT 7
int_count_exceed
BIT 6
BIT 5
BIT 4
BIT 3
BIT 2
BIT 1
BIT 0
int_DCkill_en
int_prox_ready_en
n/a
int_thres_ en
int_thres_ sel
DESCRIPTION
R/W bits. These bits contain the number of consecutive measurements needed
above/below the threshold
000 - 1 count (default setting)
001 - 2 counts
010 - 4 counts
int_count_exceed
011 - 8 counts
100 - 16 counts
101 - 32 counts
110 - 64 counts
APPLICATION NOTE
111 - 128 counts
int_DCkill_en
R/W bit.If set to 1 it blanks every proximity interrupt while IR [4:0]
(register #16 b4-b0) is 31
int_prox_ready_en
R/W bit. Enables interrupt generation when proximity data is ready
int_thres_en
R/W bit. Enables interrupt generation when upper or lower threshold is exceeded
int_thres_sel
R/W bit. Set to 0 for thresholds to be applied to proximity measurements
Revision: 13-Aug-14
Document Number: 84139
8
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
Register #10 and #11 Low Threshold
Register address = 8Ah and 8Bh. These registers contain the low threshold value. The value is a 16-bit word. The high byte is
stored in register #10 and the low byte in register #11
TABLE 11 - LOW THRESHOLD REGISTER #10
BIT 7
BIT 6
BIT 5
BIT 4
BIT 3
BIT 2
BIT 1
BIT 0
BIT 3
BIT 2
BIT 1
BIT 0
DESCRIPTION
R/W bits. High byte (15:8) of low threshold value
TABLE 12 - LOW THRESHOLD REGISTER #11
BIT 7
BIT 6
BIT 5
BIT 4
DESCRIPTION
R/W bits. Low byte (7:0) of low threshold value
Register #12 and #13 High Threshold
Register address = 8Ch and 8Dh. These registers contain the high threshold value. The value is a 16-bit word. The high byte is
stored in register #12 and the low byte in register #13
TABLE 13 - HIGH THRESHOLD REGISTER #12
BIT 7
BIT 6
BIT 5
BIT 4
BIT 3
BIT 2
BIT 1
BIT 0
BIT 3
BIT 2
BIT 1
BIT 0
DESCRIPTION
R/W bits. High byte (15:8) of high threshold value
TABLE 14 - HIGH THRESHOLD REGISTER #13
BIT 7
BIT 6
BIT 5
BIT 4
DESCRIPTION
R/W bits. Low byte (7:0) of high threshold value
Register #14 Interrupt Status Register
Register address = 8Eh. This register contains information about the interrupt status for proximity measurement and indicates
a threshold was exceeded.
TABLE 15 - INTERRUPT STATUS REGISTER #14
BIT 7
n/a
BIT 6
BIT 5
BIT 4
BIT 3
BIT 2
BIT 1
BIT 0
int_prox_ ready
n/a
int_th_lo
int_th_hi
APPLICATION NOTE
DESCRIPTION
int_prox_ready
R/W bit. Indicates a generated interrupt for proximity
int_th_lo
R/W bit. Indicates a low threshold was exceed
int_th_hi
R/W bit. Indicates an upper threshold was exceed
Once an interrupt is generated, the corresponding status bit goes to 1 and stays there until it is cleared or overwritten by writing
a 1. For example, when an upper threshold is exceeded, an interrupt is generated. The int_th_hi status bit goes to 1. It will
stay at 1 until it is overwritten by writing a 1 in the int_th_hi bit. The interrupt pad will be pulled down as long as one of the status
bit is 1.
Revision: 13-Aug-14
Document Number: 84139
9
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
Register #15 Proximity Modulator Timing Adjustment
Register address = 8Fh.
TABLE 16 - PROXIMITY MODULATOR TIMING ADJUSTMENT REGISTER #15
BIT 7
BIT 6
MODULATION DELAY TIME
BIT 5
BIT 4
BIT 3
PROXIMITY FREQUENCY
BIT 2
BIT 1
BIT 0
MODULATION DEAD TIME
DESCRIPTION
Modulation delay time
R/W bits. Sets a delay time between infrared emitter signal and infrared input signal
evaluation. This function is to compensate for delays between the emitter and photo
diode when external emitters are used and may also be used with the faster proximity
frequencies. It is used to optimize the measurement signal level.
Proximity frequency
R/W Bits. Sets the proximity infrared signal frequency
The proximity measurement uses a square signal as measurement signal. Four
different frequencies are possible:
00 = 390.625 kHz (Default Setting)
01 = 781.25 kHz
10 = 1.5625 MHz (not recommended)
11 = 3.125 MHz (not recommended)
Modulation dead time
R/W bits. Sets a time period when the reflected infrared signal is not read. This
compensates for the rise time slope of the emitter and resulting slope of the reflected
signal. Values of 0 to 7 are allowed. The default value is 1. This function reduces
possible disturbance effects but also can reduce signal levels.
User access for this register was maintained for applications using external infrared emitters. For applications using only the
internal emitter, the default register values are already optimized for proximity operation: delay time = 0, proximity frequency =
390 kHz, and dead time = 1.
Modulation Delay Time
The proximity function works with a modulated signal. The proximity signal demodulator is frequency and phase sensitive and
references to the transmitted signal. In case of external infrared emitters with additional driver stages, there might be signal
delays that could cause signal loss. By adjusting the “delay time” setting, this additional delay can be compensated. The delay
time can be set to values between 0 and 7. Using external infrared emitters the optimum setting is determined by trying different
settings. The setting with highest readings for proximity at a certain reflection condition should be selected. Since most
applications will use the internal emitter, the default value is 0.
Proximity Frequency
This parameter was used during the development of the VCNL3020. The default setting of f = 390 kHz is the optimum setting.
APPLICATION NOTE
Modulation Dead Time
Due to the emitter rise and fall times, the modulation signal is not a perfect square wave. Instead a slight slope occurs at the
start and end of the signal. The modulation dead time defines a time window or range where the slopes from the received
modulated signal are blanked out. This function eliminates effects from slow slopes, glitches and other noise disturbances on
the received signal. If the modulation dead time is set too long, a portion of the reflected signal will be lost in addition to the rise
time slope. The modulation dead time can be set to values between 0 and 7. The default setting is 1. This setting is sufficient
to suppress noise transients. It is NOT recommended to use the value “0” as a “dead time” setting. When using an external
driver and emitters, it might be necessary to adjust this parameter. An external driver might cause slow slopes, unstable
readings or higher noise. Such effects could be reduced by adjusting this parameter.
Revision: 13-Aug-14
Document Number: 84139
10
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
APPLICATION EXAMPLE
The following example will demonstrate the ease of
using the VCNL3020 sensor. Customers are strongly
encouraged to purchase a sensor starter kit and request a
VCNL3020 sensor board from:
[email protected]
Offset
During development, the application-specific offset counts
for the sensor were determined. As previously mentioned,
the offset count is affected by the components surrounding
the VCNL3020, the window or cover being used, the
distance from the sensor to the cover and emitter intensity
which is controlled by the forward current. In the following
example, with a cover over the sensor and setting the
emitter current to 100 mA, the offset counts are
5400 counts, Figure 14. Offset counts vary by application
and can be anywhere from 1000 counts to 20 000 counts. It
is important to note that the offset count may change slightly
over time due to, for example, the window becoming
scratched or dirty, or being exposed to high temperature
changes. If possible, the offset value should occasionally be
checked and, if necessary, modified.
Time 0 to A: Power up
• Lower interrupt threshold = 0
• Upper interrupt threshold = FFFF (65535)
• Interrupt flag = 0, interrupt line low
• High limit and low limit flags = 0
FFFF
(65535)
Time A: μC Sleep
• Lower interrupt threshold = 5300
• Upper interrupt threshold = 5500
• Interrupt flag = 0, interrupt line low
• High limit and low limit flags = 0
Upper
threshold
157C h
(5500)
Upper
threshold
(OC: 5400)
Lower
threshold
14B h
(5300)
0
Interrupt flag
τ
A
τ
0
Fig. 15
Time B: Single Event Above Upper Threshold
• Lower interrupt threshold = 5300
• Upper interrupt threshold = 5500
• Interrupt flag = 0, interrupt line low
• High limit and low limit flags = 0
Time C: Single Event Below Lower Threshold
FFFF
(65535)
0
Interrupt flag
τ
0
τ
Fig. 14
APPLICATION NOTE
16 bit value
16 bit value
Offset
1518 h
(5400)
Power Up
As mentioned, there are three variables that need to be set
in the register when the sensor is powered up: the emitter
current, the number of occurrences that must exceed a
threshold to generate an interrupt and the number of
proximity measurements per second. For the application the
sensor should detect an object at 5 cm distance.
Development testing determined that a current of 100 mA
produces adequate counts for detection. The proximity
measurement rate is set to 7.8125 measurements per
second and the number of occurrences to trigger an
interrupt is set to 4. Based on development testing, with an
Revision: 13-Aug-14
For smart phone applications it would be typical to initially
set only an upper threshold. However, in other sensing
applications, a lower threshold may also be set. This creates
an operating band where any change in the objects position
would trigger a threshold as shown in Figure 15.
By setting the number of occurences before generating an
interrupt to 4, a single proximity value above or below the
thresholds will have no effect as shown in Figure 16.
16 bit value
FFFF
(65535)
object approximately 5 cm above the window cover, the
resulting count is 5500. This will be used as the upper
threshold.
Upper
threshold
157C h
(5500)
(OC: 5400)
Lower
threshold
14B4 h
(5300)
0
Interrupt flag
A
B
C
τ
τ
0
Fig. 16
Once an object is detected, the sensor can be switched to
continuous polling or the thresholds can be reprogrammed.
A smartphone application will use a proximity sensor to
detect when the phone is brought to the user’s ear and
disable the touch screen and turn off the backlight. For
other applications, the action taken when an object is
detected is very application specific. For example, soap
may be dispensed, paper towels may be unrolled, a blower
turns on, or a lid is opened.
Document Number: 84139
11
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
16 bit value
Time D: Upper Threshold Exceeded
Time E: Number of Occurenence > 4
• Interrupt is generated
• Upper interrupt threshold = 5500
• Interrupt flag, int_th_hi, is set to 1
• Interrupt line goes low
FFFF
(65535)
Upper
threshold
157C h
(5500)
(OC: 5400)
Lower
threshold
14B4 h
(5300)
0
Interrupt flag
A
B
C
D
τ
E
FFFF
(65535)
Time G: Call Ends
• Interrupt is generated
• Interrupt flag, int_th_lo is set to 1
• Interrupt line goes low
New Upper
threshold
FFFF
(OC: 5400)
New Lower
threshold
154A h
(5450)
16 bit value
0
Interrupt flag
A
B
C
τ
0
D
E
F
G
t
t
0
Fig. 17
Fig. 19
In smart phone applications, the thresholds will be
reprogrammed and the sensor will wait for another interrupt
signal. In this case, the upper threshold should be set to a
maximum value since the phone is already next to the user’s
ear and a lower threshold set so when the phone call is
complete and the phone brought away from the ear, the
backlight and touch screen will be turned back on.
The upper threshold needs to be set as high as possible
since an interrupt has already been generated. In actual
applications the threshold will be set to FFFF (65535). The
lower threshold is set to 5450 counts; a value that is higher
than the offset but low enough to indicate the removal of the
phone from the users ear, Figure 18.
Time F: μC Awake, Threshold Reset
• Interrupt is cleared
• Interrupt flag, int_th_hi = 1
• Lower interrupt threshold = 5450
• Upper interrupt threshold = FFFF
• Interrupt flag = 0, interrupt line high
16 bit value
APPLICATION NOTE
FFFF
(65535)
New Upper
threshold
FFFF
New Lower
threshold
154A h
(5450)
(OC: 5400)
0
Interrupt flag
A
B
C
D
E
F
t
t
0
Fig. 18
When the object is removed, the sensor counts will return to
5400 counts and the lower threshold will generate an
interrupt, int_th_lo = 1.
Revision: 13-Aug-14
Document Number: 84139
12
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
EXAMPLE REGISTER SETTINGS
When the sensor is powered-up the first time, the default register settings are made for the application.
ACTION
REGISTER SETTING
Set infrared emitter current to 100 mA
Register #3 [83h]: 26, 83, 0A
Set proximity measurement rate to 7.8125 measurements/s
Register # 2 [82h]: 26, 82, 02
Set number of consecutive measurements that must occur to initiate an interrupt to 4:
Register # 9 [89h]: 26, 89, 42
42 h: int_count_exceed = 4
int_thres_en = 1
int_thres_sel = 0
Generate an interrupt when the threshold is exceeded . . . . . . . . . . . . . . . . . . . . . . . . .
Thresholds are for proximity measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DEFAULT VALUE SET-UP ONLY AS HEXADECIMAL CODE IS:
26, 83, 0A
write: IRED current = 10
26, 82, 02
write: Prox rate = 02
26, 89, 42
write: Int cntr reg = 42
(= 100 mA)
(= 8 measure/s)
(= int_count_exceed = 4, int_thres_en = 1, int_thres_sel = 0)
Set an upper threshold for detecting an object and do not set a lower threshold.
ACTION
REGISTER SETTING
Set lower threshold value to 0 counts
Register #10 (8Ah): 26, 8A, 00
Register #11 (8Bh): 26, 8B, 00
Set upper threshold value to 5860 counts - 16E4 (hex)
Register #12 (8Ch): 26, 8C, 16
Register #13 (8Dh): 26, 8D, E4
Start periodic proximity measurements
Register #0 (80h): 26, 80, 03
Read interrupt status register
Register #14 (8Eh): 26, 8E, 27, xx
THIS PROXIMITY SET-UP SHOWN ONLY AS HEXADECIMAL CODE IS:
26, 8A, 00
write: L_TH_HB = 00
26, 8B, 00
write: L_TH_LB = 00
26, 8C, 16
write: H_TH_HB = 16
26, 8D, E4
write: H_TH_LB = E4
26, 80, 03
write: 3: prox_en = 1, selftimed_en = 1
WAIT
at least 400 μs
26, 8E, 27, xx
read: xxxxxxx1, indicates int_th_hi = 1
APPLICATION NOTE
Assuming an object was detected, the interrupt was cleared and the software reprograms the thresholds to be able to respond
when the object is no longer present. The upper threshold is reset to FFFF counts while the lower threshold is set to 5810 counts.
ACTION
REGISTER SETTING
Set lower threshold to 5810 counts - 16B2 (hex)
Register #10 (8Ah): 26, 8A, 16
Register #11 (8Bh): 26, 8B, B2
Set upper threshold to maximum counts - FFFF (hex)
Register #12 (8Ch): 26, 8C, FF
Register #13 (8Dh): 26, 8D, FF
Start periodic proximity measurements
Register #0 (80h): 26, 80, 03
Read interrupt status register
Register #14 (8Eh): 26, 8E, 27, xx
Revision: 13-Aug-14
Document Number: 84139
13
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
THIS PROXIMITY SET-UP SHOWN ONLY AS HEXADECIMAL CODE IS:
26, 8A, 16
write: L_TH_HB = 16
26, 8B, B2
write: L_TH_LB = B2
26, 8C, FF
write: H_TH_HB = FF for the highest upper threshold
26, 8D, FF
write: H_TH_LB = FF for the highest upper threshold
26, 80, 03
write: 3: prox_en = 1, selftimed_en = 1
WAIT
at least 400 μs
26, 8E, 27, xx
read: xxxxxx1x, indicates int_th_lo = 1
PROGRAMM FLOW CHART
Default Set-Up for VCNL3020
Initial setup for proximity sensor. Note that default values do not need to be programmed.
Start Proximity Sensor Set Up
Infrared Emitter Current Reg#3: 10
Proximity Rate Reg#2: 2
Interrupt Control Reg#9: 66
Set infrared emitter current to 100 mA
Set proximity measurement rate to 8 measurements/second
Set 4 measurements above threshold to generate
an interrupt (64): 4, [b7-b5:010]
Enable interrupt when threshold value exceeded (2)
Apply threshold values to proximity (0)
APPLICATION NOTE
End Proximity Sensor Set Up
Revision: 13-Aug-14
Document Number: 84139
14
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
Defining the Upper Threshold
The upper threshold value is set so that an interrupt is generated when an object comes close enough to the sensor to create
a defined increase in counts. In this example, the offset counts are 5760 and the upper threshold is set 100 counts above the
offset.
Selftimed Proximity Measurement
OC_new = OC_old?
Check Offset Count
Clear Interrupt
(int_th_hi = 1, int_th_lo = 1)
Clear Interrupt Flags
H_TH = 5860
Set High Threshold limit
TH = OC + H_TH = 5760 + 100
Low Threshold (HB) Reg#10: 0
Default Value
Low Threshold (LB) Reg#11: 0
Default Value
High Threshold (HB) Reg#12: 5632
Set Threshold Registers, High Byte
High Threshold (LB) Reg#13: 228
Set Threshold Registers, Low Byte
Command Reg#0: 3
Enable Selftimed Measurement (2),
Define and Start for Proximity (1)
μC Enters Sleep Mode
APPLICATION NOTE
When an object does come close enough to the sensor to generate 100 counts and 4 consecutive measurements occur at or
above this level, the interrupt line will go LOW and the interrupt can be read by the microcontroller in register #14 where int_th_hi
will equal 1.
Revision: 13-Aug-14
Document Number: 84139
15
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
Redefine Thresholds
Once the counts have surpassed the initial high threshold, a low threshold needs to be set to generate an interrupt when the
object is removed. The upper threshold is redefined to the maximum value. With the offset counts equal to 5760 counts and the
initial upper threshold equal to 100 counts, the lower threshold will be set to half the initial upper threshold value or 50 counts.
Selftimed Proximity Measurement
Clear Interrupt
(int_th_hi = 1, int_th_lo = 1)
L_TH = 5810
Clear Interrupt Flags
Set Low Threshold L_TH
Offset + L _TH = 5760 + 100/2 = 5810
Low Threshold (HB) Reg#10: 5632
Set Low Threshold Register, High Byte
Low Threshold (LB) Reg#11: 178
Set Low Threshold Register, Low Byte
High Threshold (HB) Reg#12: FF
Set High Threshold Registers, High Byte
High Threshold (LB) Reg#13: FF
Set High Threshold Registers, Low Byte
Command Reg#0: 3
Enable Selftimed Measurement (2),
Define and Start for Proximity (1)
μC Enters Sleep Mode
APPLICATION NOTE
When the object is removed and 4 consecutive measurements occur at or below the lower threshold, the interrupt line will go
LOW and the interrupt can be read by the microcontroller in register #14 where int_th_lo will equal 1.
Revision: 13-Aug-14
Document Number: 84139
16
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000
Application Note
www.vishay.com
Vishay Semiconductors
Designing VCNL3020 into an Application
Complete Flow Chart
Selftimed Proximity Measurement
Selftimed Proximity Measurement
OC_new = OC_old?
Clear Interrupt
(int_th_hi = 1, int_th_lo = 1)
Clear Interrupt
(int_th_hi = 1, int_th_lo = 1)
L_TH = 5810
Start Proximity Sensor Set Up
H_TH = 5860
Low Threshold (HB) Reg#10: 5632
Infrared Emitter Current Reg#3: 10
Low Threshold (HB) Reg#10: 0
Low Threshold (LB) Reg#11: 178
Proximity Rate Reg#2: 2
Low Threshold (LB) Reg#11: 0
High Threshold (HB) Reg#12: FF
Interrupt Control Reg#9: 66
High Threshold (HB) Reg#12: 5632
End Proximity Sensor Set Up
High Threshold (LB) Reg#13: 228
High Threshold (LB) Reg#13: FF
Command Reg#0: 3
Command Reg#0: 3
int_line = L
int_th_lo = 1
int_line = L
int_th_hi = 1
μC Enters Sleep Mode
μC Enters Sleep Mode
APPLICATION NOTE
Interrupt
(int_th_hi = 1)
Revision: 13-Aug-14
Interrupt
(int_th_lo = 1)
Document Number: 84139
17
For technical questions, contact: [email protected]
THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE. THE PRODUCTS DESCRIBED HEREIN AND THIS DOCUMENT
ARE SUBJECT TO SPECIFIC DISCLAIMERS, SET FORTH AT www.vishay.com/doc?91000