2020-03-11 05:03 AM
Hello,
I have following issue.
For distance 0 mm - 60 mm the result of range measurement is always the same (0x20)
step by step code:
GPIO0 set High.
Range measurement start: write 1 to reg 0x0018
Wait 100ms
Read range status: read register 0x004D
Read range value: read resiter 0x0062
Range status is: 0x03
Range value is: 0x20
I tried to use as target white paper, black plastic and hand. The result is still the same.
I tried to change range offset (register 0x0024). Range value changes after offset change but again is constant for distance 0mm - 60mm.
Light conditions are regular office light.
Could you please help me solve this issue?
Thanks,
Mila
2020-03-11 08:31 AM
It is impossible that the sensor will return the same number several times in a row. It's not that accurate.
So my guess is it's not running. Do you see the sensor light on?
850nm light is visable - but just barely. Use a cell phone camera.
There is a API available, and even if you don't use it, it's a handy reference.
VL6180X API (Application Programming Interface and Documentation)
Reading register 4D tells you the condition of the last range, but that will not get updated until the next range is complete.
Check register 4F - basically the 'done' bit.
I have a guess though.
You brought the device out of reset and immediately set the start bit.
But your MCU is a lot faster than the sensor is.
Give the sensor one or two ms to boot, then tell the device to range. (I think it only takes 400usec, but a couple of ms is double safe.)
Or, to tell if the device is booted and you are communicating correctly, read the device ID at register 0.
Then tell it to start.
2020-03-15 02:54 AM
Hi John,
thank you for promt response.
The issue was I did not apply tuning setting after each boot.
I found this information in application note: VL6180X range and ambient light sensor quick setup guide.
Now everything works perfectly.
Thanks,
Mila