Kart/sensors/VCNL4000

From FSI
(Difference between revisions)
Jump to: navigation, search
(Proximity sensor)
 
(30 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{private}}
 
 
{{TOC right}}
 
{{TOC right}}
== VISHAY - VCNL4000-GS08 - NAEHERUNGSSENSOR, PALS ==
+
== Proximity sensor ==
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 includes a signal processing IC and supports an easy to use I2C bus communication interface.
+
  
Datasheet on Farnell: http://www.vishay.com/docs/83798/vcnl4000.pdf
+
The [[Media:VCNL4000 proximity sensor.pdf|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 [[Kart/sensor board#Proximity sensors|connectors]] are provided on the kart [[Kart/sensor board|I/O board]].
  
* Manufacturer: '''VISHAY'''
+
== I2C communication ==
* Farnell: '''1870777'''
+
* Manufacturer Desc: '''VCNL4000-GS08'''
+
  
=== i2c ===
+
The chip I2C address is <code>13</code><sub>h</sub>.
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 address is fixed so there is no direct way to connect several distance sensors on the same I2C bus.
  
Addressing:command: 26h, 85h (VCNL4000_I2C_Bus_Write_Adr., Ambient Light Result Register #5 [85])
+
For reading out 2 (or more) subsequent registers like the result registers, it is not necessary to address each of the registers separately.
Read register #5:command: 27h, data (VCNL4000_I2C_Bus_Read_Adr., {High Byte Data of Ambient Light Result Register #5 [85])}
+
After one read command the internal register counter is increased automatically and any subsequent read command is accessing the next register.
Read register #6:command: 27h, data (VCNL4000_I2C_Bus_Read_Adr., {Low Byte Data of Ambient Light Result Register #6 [86])}
+
 
 +
The maximal <code>SCL</code> clock rate is 3.4&nbsp;MHz.
 +
 
 +
=== Registers ===
 +
 
 +
The registers are:
 +
 
 +
{| cellpadding="3" cellspacing="0" border="1"
 +
! 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.
 +
<code>26</code><sub>h</sub> is the chip's address <code>13</code><sub>h</sub> followed by a <code>0</code><sub>b</sub> 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 40<sub>h</sub>) is 0.
 +
  [start] 26 85 [start] 27 FF FF [stop] # Read the data from the two registers.
 +
<code>26</code><sub>h</sub> is the chip's address <code>13</code><sub>h</sub> followed by a <code>0</code><sub>b</sub> for write access.
 +
<code>85</code><sub>h</sub> is the base register address for the ambient light.
 +
<code>27</code><sub>h</sub> is the chip's address <code>13</code><sub>h</sub> followed by a <code>1</code><sub>b</sub> for read access.
 +
The sensor will pull down the <code>SDA</code> line during the <code>FF</code><sub>h</sub> bytes to answer to the request.
 +
 
 +
When reading multiple bytes, the master has to pull <code>ACK</code> low between the <code>FF</code><sub>h</sub> 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 20<sub>h</sub>) 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 <code>0600</code><sub>h</sub>,
 +
5 cm gives something like <code>0800</code><sub>h</sub>,
 +
and close to zero can reach more than <code>8000</code><sub>h</sub>.
 +
 
 +
==== 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 60<sub>h</sub>) is not 3<sub>h</sub>.
 +
  [start] 26 87 [start] 27 FF FF FF FF [stop] # Read the data from the two registers.
 +
 
 +
[[Category:Kart]]

Latest revision as of 10:26, 19 August 2021

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