|
|
(10 intermediate revisions by one user not shown) |
Line 1: |
Line 1: |
− | {{TOC right}}
| + | #REDIRECT [[Kart]] |
− | == Ambient light 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
| + | |
− | | + | |
− | * Manufacturer: '''VISHAY'''
| + | |
− | * Farnell: '''1870777'''
| + | |
− | * Manufacturer Desc: '''VCNL4000-GS08'''
| + | |
− | | + | |
− | == I2C communication ==
| + | |
− | | + | |
− | The chip I2C address is <code>26</code><sub>h</sub>.
| + | |
− | 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 <code>SCL</code> clock rate is 3.4 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 40h 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 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 <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 20h is 0.
| + | |
− | [start] 26 87 [start] 27 FF FF 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.
| + | |
− | | + | |
− | == Kart PCB pins ==
| + | |
− | | + | |
− | === FPGA board connector ===
| + | |
− | | + | |
− | The free pins towards the ex remote control board are:
| + | |
− | | + | |
− | {| cellpadding="3" cellspacing="0" border="1"
| + | |
− | ! Conn. pin
| + | |
− | ! prev. fct
| + | |
− | ! new fct
| + | |
− | |-
| + | |
− | | A1
| + | |
− | | j. left
| + | |
− | | SCL
| + | |
− | |-
| + | |
− | | A2
| + | |
− | | j. right
| + | |
− | | SDA1
| + | |
− | |-
| + | |
− | | A4
| + | |
− | | j. toggle
| + | |
− | | SDA2
| + | |
− | |-
| + | |
− | | A6
| + | |
− | | j. back
| + | |
− | | hall1
| + | |
− | |-
| + | |
− | | A8
| + | |
− | | j. fwd
| + | |
− | | hall2
| + | |
− | |}
| + | |
− | | + | |
− | === FPGA pinout ===
| + | |
− | | + | |
− | The FPGA pinout is:
| + | |
− | | + | |
− | {| cellpadding="3" cellspacing="0" border="1"
| + | |
− | ! function
| + | |
− | ! conn.
| + | |
− | ! FPGA
| + | |
− | |-
| + | |
− | | SCL
| + | |
− | | A1
| + | |
− | | 57
| + | |
− | |-
| + | |
− | | SDA1
| + | |
− | | A2
| + | |
− | | 58
| + | |
− | |-
| + | |
− | | SDA2
| + | |
− | | A4
| + | |
− | | 60
| + | |
− | |-
| + | |
− | | hall1
| + | |
− | | A6
| + | |
− | | 62
| + | |
− | |-
| + | |
− | | hall2
| + | |
− | | A8
| + | |
− | | 64
| + | |
− | |-
| + | |
− | | VSS
| + | |
− | | A26
| + | |
− | |
| + | |
− | |-
| + | |
− | | VDD
| + | |
− | | A24
| + | |
− | |
| + | |
− | |}
| + | |
| | | |
| [[Category:Kart]] | | [[Category:Kart]] |