The steval-mki021v1 is a demonstration kit designed to provide the user with a complete, ready-to-use platform for the evaluation of the lis331al (9 pages)
Page 1
Application note VL6180X basic ranging application note Introduction The VL6180X is a proximity sensor based on ST’s patented FlightSense™ technology. The VL6180X interfaces to your micro-controller via the industry standard I²C bus. The module also includes an ambient light sensor (ALS).
Communication with the VL6180X is via the I²C bus. The default 7-bit address of the VL6180X is 0x29. It can be changed by the user to any 7-bit addresses by writing to the I2C_SLAVE__DEVICE_ADDRESS {0x212} register. The SCL and SDA lines should each have a pull-up resistor on the I²C bus.
VL6180X is ready to start a range measurement. Note: This procedure must be repeated if the VL6180X has been power cycled or if GPIO-0 has been toggled. SYSTEM__FRESH_OUT_OF_RESET {0x16} will reset to 0x01 if the VL6180X has been power cycled or if GPIO-0 was toggled.
In Single-shot mode, the VL6180X will perform a single range measurement and will enter software standby once the measurement has completed. In continuous mode the VL6180X will perform back to back range measurements at a user determined rate until the stop command is issued.
(New Sample Ready threshold event). Reading range result. Read RESULT__RANGE_VAL {0x62}. This is the range measurement between the VL6180X and target in mm Clear the Interrupt status. Write 0x07 to SYSTEM__INTERRUPT_CLEAR {0x15}. Repeat the previous steps 1 to 4 for more range measurements.
Other ranging outputs AN4545 Other ranging outputs As well as the range output, the following can also be read along with each range measurement. Range error codes Register RESULT__RANGE_STATUS {0x4d} returns an error code after each range measurement. Table 13 gives a summary of the range error codes: Table 1.
3.2.2 Return convergence time Register RESULT__RANGE_RETURN_CONV_TIME {0x7c} contains the time in µs it took for the return array on VL6180X to settle or converge on a target distance during the range measurement. Note: If Return convergence time is equal to the max convergence time, then VL6180X was not able to detect a target during the last measurement.
Other ranging outputs AN4545 3.3.2 Reference convergence time Register RESULT__RANGE_REFERENCE_CONV_TIME {0x80} contains the time in µs it took for the reference array to settle or converged on a target distance during the range measurement. Note: {0x7c} is a 32-bit register. 3.3.3 Reference signal count Register RESULT__RANGE_REFERENCE_SIGNAL_COUNT {0x70} contains the number...
Figure 5. Graph of range output vs. target distance. The test was performed in the dark and with no cover glass. The range output of VL6180X with each of the targets should be linear with range. There could however be an offset error .
Note: Cover glass can alter the return signal rate characteristics. We therefore recommend the signal rate be re-characterized once the VL6180X has been integrated into the final system before attempting to perform any system optimisation. d. The field or view of VL6180X is approximately ±12.5°.
Convergence time Figure 7 shows the typical convergence time output from VL6180X for different targets at different distances. The convergence time can provide useful information on how to optimise VL6180X settings to perform more efficiently and reliably.
Page 14
Typical ranging output AN4545 Figure 7. Graph of convergence time vs. target distance. The test was performed in the dark and with no cover glass. 14/27 DocID026571 Rev 1...
The VL6180X can be used with a cover glass. The cover glass can cause internal reflection and this can be detected by VL6180X as unwanted signals. This is known as the cross talk. The cross talk can affect the range output, hence we recommend the user perform the cross...
4.1.1. Note: If the offset is incorrectly calibrated, cross talk calibration will be inaccurate. Place a dark target at 100mm away from VL6180X. Low reflectance target recommended, e.g. 3% target. Ensure SYSRANGE__CROSSTALK_COMPENSATION_RATE {0x1e} is set to 0. Collect a number of range measurements with the target in place and calculate mean of the range results and Return signal rate.
Cover glass 5.1.2 Range ignore The range ignore function in VL6180X can be enabled by setting bit 1 of SYSRANGE__RANGE_CHECK_ENABLES {0x2d}. If enabled, the ignore threshold must be specified. We recommend setting the ignore threshold to at least 1.2x cross talk.
The sampling period is set to 4.4ms by default. If the return signal from a target is lower than the minimum signal rate then the VL6180X will return a range output of 255 and a max convergence will be flagged.
Additional error checks VL6180X has three additional system error checks which can be enabled to help filter out invalid range results. See the VL6180X data sheet on how to set these error checks as well as enabling and disabling them.
Example code AN4545 Example code Below is example code on how to perform ranging with VL6180X using single shot mode. The code is based on the STM32 F401 Nucleo board and can be compiled using the mbed Compiler. /////////////////////////////////////////////////////////////////// // Beginning of code /////////////////////////////////////////////////////////////////// #include "mbed.h"...
Page 21
AN4545 Example code /////////////////////////////////////////////////////////////////// int VL6180X_Init() { char reset; reset = ReadByte(0x016); if (reset==1){ // check to see has it be Initialised already /////////////////////////////////////////////////////////////////// // Added latest settings here - see Section 8 /////////////////////////////////////////////////////////////////// WriteByte(0x016, 0x00); //change fresh out of set status to 0 return 0;...
Page 22
To change the example above to continuous mode: In the VL6180X_Start_Range() function change the data written to VL6180X from 0x01 to 0x03. In the while loop, move the function call for VL6180X_Start_Range() to outside the while loop, immediately after the VL6180X_Init() call.
Acronyms and abbreviations Acronyms and abbreviations Table 2. Acronyms and abbreviations Acronym/ abbreviation Definition Ambient When the VL6180X have detected a target and “converged” or Convergence acquired the target distance GPIO General Purpose Input/Output Non Volatile Memory Unit for measuring the signal rate from the return/reference array.
SR03 settings AN4545 SR03 settings Below are the recommended settings required to be loaded onto the VL6180X during the initialisation of the device (see Section 1.3). // Mandatory : private registers WriteByte(0x0207, 0x01); WriteByte(0x0208, 0x01); WriteByte(0x0096, 0x00); WriteByte(0x0097, 0xfd); WriteByte(0x00e3, 0x00);...
Page 25
AN4545 SR03 settings WriteByte(0x002e, 0x01); // perform a single temperature calibration // of the ranging sensor Optional: Public registers - See data sheet for more detail WriteByte(0x001b, 0x09); // Set default ranging inter-measurement // period to 100ms WriteByte(0x003e, 0x31); // Set default ALS inter-measurement period // to 500ms WriteByte(0x0014, 0x24);...
Revision history AN4545 Revision history Table 3. Document revision history Date Revision Changes 19-Jun-2014 Initial release. 26/27 DocID026571 Rev 1...
Page 27
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein.
Need help?
Do you have a question about the VL6180X and is the answer not in the manual?
Questions and answers