Kart/sensors/VCNL4000

From FSI
Jump to: navigation, search

Contents

Proximity sensor

The VCNL4000 is a fully integrated proximity and ambient light digital 16 bit resolution sensor in a miniature lead less package (LLP) for surface mounting. It communicates via an I2C bus. Four connectors are provided on the kart I/O board.

I2C communication

The chip I2C address is 13h. The address is fixed so there is no direct way to connect several distance sensors on the same I2C bus.

For reading out 2 (or more) subsequent registers like the result registers, it is not necessary to address each of the registers separately. After one read command the internal register counter is increased automatically and any subsequent read command is accessing the next register.

The maximal SCL clock rate is 3.4 MHz.

Registers

The registers are:

Address access register
0x80 R/W command
0x81 R product and revision id
0x82 <unsused>
0x83 R/W LED current
0x84 R/W acquisition parameters
0x85 R ambient light H
0x86 R ambient light L
0x87 R proximity H
0x88 R proximity L
0x89 R/W acquisition frequency
0x8A R/W acquisition timings

System setup

The system setup is done by writing to the different control registers:

[start] 0x26 0x83 0x14 0x08 [stop] # LED current=200mA, no auto-conversion, auto-offset-compensation, averaging 128 measures.
[start] 0x26 0x89 0x03 0x81 [stop] # Distance measure frequency is 390.625 kHz, delay time is 4 and dead time 1.

26h is the chip's address 13h followed by a 0b for write access. It is followed by the register address and by the data bytes. Commands with multiple data bytes allow to write data into sequential registers.

Reading data form the sensor

Read ambient light

Read ambient light (data values in hex):

 [start] 26 80 10 [stop]               # Start measure.
 [start] 26 80 [start] 27 FF [stop]    # Do this as long as (received_value and 40h) is 0.
 [start] 26 85 [start] 27 FF FF [stop] # Read the data from the two registers.

26h is the chip's address 13h followed by a 0b for write access. 85h is the base register address for the ambient light. 27h is the chip's address 13h followed by a 1b for read access. The sensor will pull down the SDA line during the FFh bytes to answer to the request.

When reading multiple bytes, the master has to pull ACK low between the FFh words.

Read distance

Read distance (data values in hex):

 [start] 26 80 08 [stop]               # Start measure.
 [start] 26 80 [start] 27 FF [stop]    # Do this as long as (received_value and 20h) is 0.
 [start] 26 87 [start] 27 FF FF [stop] # Read the data from the two registers.

The command is the same as for ambient light, only the base register address changes.

Note: the returned value corresponds to something like the inverse of the distance (datasheet, figure 3, page 3). Long distances give something like 0600h, 5 cm gives something like 0800h, and close to zero can reach more than 8000h.

Read ambient light and distance

Read both ambient light and distance (data values in hex):

 [start] 26 80 18 [stop]                     # Start measure.
 [start] 26 80 [start] 27 FF [stop]          # Do this as long as (received_value and 60h) is not 3h.
 [start] 26 87 [start] 27 FF FF FF FF [stop] # Read the data from the two registers.
Personal tools
Namespaces
Variants
Actions
Navigation
Modules / Projects
Browse
Toolbox