VL53L0X Time-of-Flight Ranging Sensor


#63

That’s odd, since with #define VL53L0X_LOG_ENABLE 0 commented out, the lib should behave as with v0.0.1.

Does your sensors work with the Pololu lib?
For my boards I need to add external pull-ups to the I2C lines.


#64

@ScruffR
Both boards worked w/ pololu code.
Just not getting SOS now
Maybe I’m in over my head on this and causing us all confusion. I just noticed that when I do a local build I get a binary of size 3876, but the CLI build is 30964??? I must be doing something wrong. I use:

make clean all PLATFORM=photon APPDIR=../../appmain/vl53l0x TARGET_DIR=../../appmain/vl53l0x/target/ PARTICLE_DEVELOP=1 LTO=n program-dfu v=1

from modules, git checkout latest.

While for CLI I do:

C:\particle\appmain\vl53l0x>particle compile photon
C:\particle\appmain\vl53l0x>dfu-util -d 2b04:d006 -a 0 -i 0 -s 0x080A0000:leave -D photon_firmware_1481839806786.bin

I didn’t need to use pull-ups for the pololu code, but I’ve tried 4k7s to the 2.8v line with the adafruit code without achieving anything different than solid cyan
Update: Just tried with a different photon and now back to SOS. :scream:


#65

@ScruffR @RWB

Not clear at all that I know what I’m doing, but it appears that in vl53l0x_api_core.cpp the function:

/* To convert ms into register value */
uint32_t VL53L0X_calc_timeout_mclks(VL53L0X_DEV Dev,
uint32_t timeout_period_us,
 uint8_t vcsel_period_pclks)

crashes because? the variable macro_period_ps gets set to zero therein.

I can’t get any farther on this tonight, maybe it’s a clue??


#66

The biggest help I’m going to be for solving this problem is getting one of these sensors in master @peekay123 's hands so he can work his magic.

I can test and verify code anytime you guys have something to try.

@scruffr what all is in this Adafruit Library that is missing from the working Poulou library?

What more could you want over and above the continuous & single shot measurement modes other than setting the interrupt thresholds and the different sleep modes maybe? Just curious what other features you may be interested in.


#67

The Adafruit library has the full STM feature set like recalibration, custom profile up-/down-load, dedicated functions for interrupt setup, …
That sensor is a powerful machine and hence has a ton of possible (but complicated) features and AFAIK there is no real API documentation but the actual code.
And that’s my problem here you don’t know the device but have to understand what the code is doing and back track to the how and why - and that code does a lot.

Getting it to build for Particle devices was a no-brainer, but have it run as expected - especially with boards that obviously behave differently - is driving me nuts.
For my own applications I’d not need anything else than the interrupt feature incorporated in the Pololu lib, but to find out how to get that there, I’d need to understand the STM/Adafruit lib first.


#68

I give up! What the heck are spads anyway?


#69

@ScruffR @bpr Is this Library for the 32bit Teensy 3.2 of any help possibly?


#70

@RWB interesting! but he didn’t get the interrupt going, which is what we all want.


#71

Yea but aren’t these part of the interrupt puzzle?


#72

SPADs are Single Photon Avalange Diodes which are the used LASER emitters in the sensor.


#73

@ScruffR @RWB @peekay123
I stumbled around hopelessly, couldn’t let it go, and it paid off. With some caveats. As soon as I got it the adafruit library more or less working, Windows 10 decided the photon was a mouse. After an hour of agitated fiddling I managed to solve that. However, my photon won’t use Serial anymore, just Serial1, but through USB not the TX-RX pins. I’m so confused now. Anyway, here’s a link to the code and see what you can make of it. It’s messy beyond belief, embarassingly so, but I have no engineering background so don’t laugh. What got this running was mostly the code provided by jerryn on the adafruit forum a week ago - he rewrote the vl53l0x_i2c_comms.cpp and Adafruit_VL53l0x.cpp files. Give it a whirl. The scaling seems off. Someone else please fix that and get the interrupt going.


#74

I bet this thread is partially responsible for 55 of these bad boys disappearing from time I ordered this morning, to tonight.


#75

I have not tried to run your code yet but I did download it and looked at most of the code in the files.

In the VL53L0X_device.h file I find these lines referring to the interrupt.

Can’t we write to these registers to change the interrupt GPIO pin functionality?

Can’t we also read and reset the Interrupt register after it has been tripped?

I guess we can try to write to the 0x00 register and see if it disables the GPIO Interrupt pin, and then write to register 0x01 and see if the GPIO pin goes high after something passes by the sensor?


#76

Great job Brian (@bpr)! :+1:
That was a precious find. I do get good readings now too.
I’ve just pushed that as version 0.0.3 to Particle Build.


Brian, could you point me to the place where you found this?
I want to know what has been changed an why?

Thanks :+1:


#77

@ScruffR
https://forums.adafruit.com/viewtopic.php?f=19&t=107418&start=15


#78

I see, the thread started off the same way as ours: Pololu lib worked but Adafruits own not.


#79

@bpr So which of the libraries do you prefer now that it sounds like both are working?

Any luck on figuring out how to properly configured the Interrupts? I’ve looked all the .H and .cpp files but there are so many of them it’s confusing :confused:


#80

That’s the point :sunglasses:
Finding the word interrupt in the lib is not even 10% of the way to get them working :wink:
But since there are no official sample codes that show how to do it, it’s some detective work with trial and error and does take time.


@shiv, about endianness

Because there are operations that are agnostic to endianness (e.g. math operations on the numeric date type) and there are operations where differences in endianness can cause trouble (e.g. void* operations).


#81

@ScruffR @bpr Here is another library that may or maynot be helpful :smiley:

He tried to get the interrupts working:


#82

@RWB, @ScruffR, sorry for the radio silence and thank you @RWB for shipping me one of these bad boys. I’ll be looking a code as soon as I get the unit. Good work so far though!