DM00114403

DM00114403
AN4478
Application note
Using multiple VL6180Xs in a single design
By Darin Winterton
Introduction
The purpose of this document is to give an example of how multiple VL6180X devices can
be placed on a board design while only using a single I2C interface to interact with the
devices.
Figure 1. VL6180X device
4.8 mm
1 mm
2.8 mm
May 2014
DocID026250 Rev 1
1/9
www.st.com
Contents
AN4478
Contents
1
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2
Multiple VL6180X operation steps and schematic suggestions . . . . . . 3
3
Example source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2/9
DocID026250 Rev 1
AN4478
1
Purpose
Purpose
The purpose of this document is to give an example of how multiple VL6180X devices can
be placed on a board design while only using a single I2C interface to interact with the
device. The VL6180X is a proximity sensor that uses a time of flight technology to get
distance, and the control and output interface is an I2C interface. Each VL6180X device
has both a reset pin and an interrupt pin, which will be used in this design setup for using
multiple devices.
The uses for multiple VL6180Xs on a single design can include the following:
2
1.
Distance sensing in multiple directions
2.
Robotics with multiple sensors
3.
Gesture Detection
4.
….
Multiple VL6180X operation steps and schematic
suggestions
1.
Figure 2 is a typical example schematic using a VL6180X device. Since the VL6180X
can have the I2C device address changed by doing an I2C write once it is booted, a
separate reset pin would be needed to each VL6180X used in a design. Each device is
then taken out of reset one at a time, and then the I2C Device Address is changed to a
new unique address. This can be done by using multiple GPIO pins from the
microprocessor on the board.
Figure 2. VL6180X typical application
DocID026250 Rev 1
3/9
9
Multiple VL6180X operation steps and schematic suggestions
2.
3.
AN4478
For a board with multiple VL6180Xs used in the design, and there are a limited number
of GPIO pins available on the microprocessor, the following are the recommended
options for the use of these GPIO pins available.
a)
If only 1 GPIO pin is available from the micro-processor, then this pin would have
to be used as a Reset pin for an I2C GPIO expander, and the interrupts from the
VL6180Xs could not be used. The GPIO expander would control the resetting of
the VL6180X devices, and polling of each VL6180X would have to be done to get
any data needed. A second GPIO expander could be used for the interrupts, but
the microprocessor would have to poll the U2 device to see if an interrupt has
been triggered.
b)
If 2 GPIOs are available with multiple VL6180X devices, then two I2C GPIO
expanders would be used, where the first would be for resetting the devices and
the second would be used for the interrupts. An example schematic is shown in
section 3.
c)
If (x) VL6180X devices are being used, and (x+1) GPIOs are available, then it is
recommended to use a GPIO expander for the resetting of the VL6180X devices,
and connect each individual interrupt to the microprocessor. Since the interrupt of
each VL6180X is going directly to the microprocessor, time is saved when an
interrupt is triggered directly to the microprocessor instead of going through a
GPIO expander IC.
d)
If (x) VL6180X devices are being used, and (2x) GPIOs are available, then no
GPIO expander chips are needed, and all reset and interrupts pins would be
connected directly to the microprocessor.
If the options from section 2 recommends a I2C GPIO expander IC, Figure 3 is an
example schematic showing how to implement I2C GPIO expanders.
This reference design has 8 VL6180X devices connected to the same I2C interface,
where the I2C GPIO exander U1 is controlling the reset pins to each VL6180X and U2
is handling the Interrupts from the VL6180X devices. With this design below, only 2
GPIO pins are needed on the microprocessor, which are for the interrupt from U2 and
the reset pins for both U1 and U2.
4/9
DocID026250 Rev 1
AN4478
Multiple VL6180X operation steps and schematic suggestions
Figure 3. I2C GPIO extender application
4.
The process to initialize each VL6180X is shown below
a)
Take VL6180X number 1 out of reset by either direct a direct GPIO from the
microprocessor or by giving an I2C command to U1 to bring GPIO0_1 high.
b)
Write to the VL6180X just taken out of reset to the address 0x0212 with the value
of the new I2C device address. The default value is 0x52, so for this example, the
address of the first device will be changed to 0x80 (0x82 for device 2, 0x84 for
device 3, …)
c)
To ensure it is working correctly, it is suggested that you now do a read of the
device ID of the VL6180X with its new I2C device address written in step 3.b.
d)
If the device is now communicating on its new I2C device address, then repeat the
steps 4.a to 4.c for each additional VL6180X attached to the device. In this case
shown in step 3, GPIO0_x will each be brought high one at a time until all 8
devices are initialized.
DocID026250 Rev 1
5/9
9
Multiple VL6180X operation steps and schematic suggestions
5.
After all of the VL6180X devices are initialized, the microprocessor can talk to each
device individually and can configure them for operation. The configuration will include
setting the convergence time, interrupts, inter-measurement time, Threshholds for the
interrupts, etc.
6.
To configure the Interrupts, the VL6180X device can give interrupts is various ways,
including the following:
7.
6/9
AN4478
a)
Interrupts Disabled
b)
Interrupt when a measurement is completed
c)
Interrupt when a measurement is below a certain threshold of distance (ie.
Distance less than 5cm)
d)
Interrupt when a measurement is above a a certain threshold of distance (ie.
Distance greater than 10cm)
e)
Interrupt when a distance measured is out of a certain window (ie. Distance less
than a Low Threshold or the Distance is greater than a High Threshold)
With the example of using the I2C GPIO Expander for the Interrupts, each VL6180X
could be configured to give an interrupt when a distance is less than 5cm and to run in
continuous measurement mode. If any device is showing a distance of less than 5cm,
then an interrupt will go off for that device, which sets off the interrupt either directly to
the microprocessor or from the U2 GPIO Expander. If the GPIO Expander is being
used, the microprocessor would then poll U2 to see which VL6180X is triggering the
interrupt. Next, the microprocessor would communicate directly to the VL6180X with
the interrupt that is showing a distance less than 5cm. When the microprocessor has
the information needed, it would then clear the interrupts on the VL6180X and the I2C
GPIO expander U2 (if used).
DocID026250 Rev 1
AN4478
3
Example source code
Example source code
1.
Function to see if a VL6180X can be detected on a certain I2C Device Address.
/*******************************************************************************
* Function name
: DetectVL6180X
* Description
: DetectVL6180X
* Input
: I2CDevAddr
* Output
: None
* Return
: Failure
*******************************************************************************/
u8 DetectVL6180X (u8 I2CDevAddr)
{
u8 i, DeviceID;
for (i=0; i<10; i++)
{
DeviceID = I2C_VL6180XReadByte(I2CDevAddr, 0x00);
Delay(20);
if (DeviceID == 0xB4)
{
return 0;
}
}
return 1;
}
2.
Function to Change the I2C Device address
/*******************************************************************************
* Function name
: ChangeVL6180XI2CAddr
* Description
: ChangeVL6180XI2CAddr
* Input
: CurrentI2CDevAddr, NewI2CDevAddr
* Output
: None
* Return
: Failure
*******************************************************************************/
u8 ChangeVL6180XI2CAddr (u8 CurrentI2CDevAddr, u8 NewI2CDevAddr)
{
u8 Failure;
Failure = I2C_VL6180XByteWrite (CurrentI2CDevAddr, 0x0212, NewI2CDevAddr / 2);
if (Failure != 0x00)
{
return 1;
}
else
{
return 0;
}
}
DocID026250 Rev 1
7/9
9
Revision history
4
AN4478
Revision history
Table 1. Document revision history
8/9
Date
Revision
14-May-2014
1
Changes
Initial release.
DocID026250 Rev 1
AN4478
Please Read Carefully:
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
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.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
ST PRODUCTS ARE NOT DESIGNED OR AUTHORIZED FOR USE IN: (A) SAFETY CRITICAL APPLICATIONS SUCH AS LIFE
SUPPORTING, ACTIVE IMPLANTED DEVICES OR SYSTEMS WITH PRODUCT FUNCTIONAL SAFETY REQUIREMENTS; (B)
AERONAUTIC APPLICATIONS; (C) AUTOMOTIVE APPLICATIONS OR ENVIRONMENTS, AND/OR (D) AEROSPACE APPLICATIONS
OR ENVIRONMENTS. WHERE ST PRODUCTS ARE NOT DESIGNED FOR SUCH USE, THE PURCHASER SHALL USE PRODUCTS AT
PURCHASER’S SOLE RISK, EVEN IF ST HAS BEEN INFORMED IN WRITING OF SUCH USAGE, UNLESS A PRODUCT IS
EXPRESSLY DESIGNATED BY ST AS BEING INTENDED FOR “AUTOMOTIVE, AUTOMOTIVE SAFETY OR MEDICAL” INDUSTRY
DOMAINS ACCORDING TO ST PRODUCT DESIGN SPECIFICATIONS. PRODUCTS FORMALLY ESCC, QML OR JAN QUALIFIED ARE
DEEMED SUITABLE FOR USE IN AEROSPACE BY THE CORRESPONDING GOVERNMENTAL AGENCY.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.
© 2014 STMicroelectronics - All rights reserved
STMicroelectronics group of companies
Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America
www.st.com
DocID026250 Rev 1
9/9
9
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement