VL53L1X Roi / Optical Centers

Hi!

I bought some of your VL53L1X - works perfectly.

I now have the build the following contruction:

https://i.ibb.co/NTgCDft/1111.jpg

The screwdriver indicates the spot where I want to mount one of my VL53L1X.

The sensor will point to the middle, where the boards come together, along that one board next/left to the screwdriver.

Imagine the yelow part is the sensor and the metal-part of the screwdriver indicates the direction of the sensor :stuck_out_tongue:

(The goal is to measure an object that gets placed on the cut-out area.)

My problem:

My tests have shown that I get strange/incorrect readings because the sensor points parallel along the board.

I think sometimes the field of view hits the wood left to it (or the wooden plate) first and not the object that’s to be measured.

You state, that the FoV it approx. 15°-27°. Can I somehow tell the sensor that a straight beam is required, instead of FoV that is “cone-shaped”.

Maybe the library you provide gives me something to fiddle with?

I am thinking of some tweaking with the following methods: setXTalk, calibrateXTalk, setROI

Especially setROI seems interesting since it hase to do with the optical centers.

Sadly , I am not sure what exactly are “Optical Centers” and how that functions ist used.

Maybe you can help me out?

I would like/need to have some functionality that puts some software-side “blinkers” on, so the sensor only sees whats realy straight in front of it (and not whats left/right to it)

I found the following in ST’s User Guide (here), regarding the FoV:

Setting ROI
The receiving SPAD array of the sensor consists of 16x16 SPADs which cover the full FoV.
It is possible to program a smaller ROI, with a smaller number of SPADs, to reduce the FoV for applications which require a narrow FoV.
Use the function VL53L1X_SetROI (dev, X, Y).
• X is the ROI width from 4 to 16, if X < 4 the Firmware limits the width to 4
• Y is the ROI height from 4 to 16, if Y < 4 the Firmware limits the height to 4
VL53L1X_GetROI returns the current ROI.
Note:Lowering the number of SPADs limits the maximum ranging distance. Some experimentation is required

So, “reducing the FoV for applications which require a narrow FoV” is exactly what I want, I think!

I can find the following in your library (SparkFun_VL53L1X.h) about the ROI:

/**Table of Optical Centers**

*

* 128,136,144,152,160,168,176,184, 192,200,208,216,224,232,240,248

* 129,137,145,153,161,169,177,185, 193,201,209,217,225,233,241,249

* 130,138,146,154,162,170,178,186, 194,202,210,218,226,234,242,250

* 131,139,147,155,163,171,179,187, 195,203,211,219,227,235,243,251

* 132,140,148,156,164,172,180,188, 196,204,212,220,228,236,244,252

* 133,141,149,157,165,173,181,189, 197,205,213,221,229,237,245,253

* 134,142,150,158,166,174,182,190, 198,206,214,222,230,238,246,254

* 135,143,151,159,167,175,183,191, 199,207,215,223,231,239,247,255



* 127,119,111,103, 95, 87, 79, 71, 63, 55, 47, 39, 31, 23, 15, 7

* 126,118,110,102, 94, 86, 78, 70, 62, 54, 46, 38, 30, 22, 14, 6

* 125,117,109,101, 93, 85, 77, 69, 61, 53, 45, 37, 29, 21, 13, 5

* 124,116,108,100, 92, 84, 76, 68, 60, 52, 44, 36, 28, 20, 12, 4

* 123,115,107, 99, 91, 83, 75, 67, 59, 51, 43, 35, 27, 19, 11, 3

* 122,114,106, 98, 90, 82, 74, 66, 58, 50, 42, 34, 26, 18, 10, 2

* 121,113,105, 97, 89, 81, 73, 65, 57, 49, 41, 33, 25, 17, 9, 1

* 120,112,104, 96, 88, 80, 72, 64, 56, 48, 40, 32, 24, 16, 8, 0 Pin 1

*

* To set the center, set the pad that is to the right and above the exact center of the region you'd like to measure as your opticalCenter*/

void setROI(uint8_t x, uint8_t y, uint8_t opticalCenter); //Set the height and width of the ROI(region of interest) in SPADs, lowest possible option is 4. Set optical center based on above table

Since X and Y should be 4 for my application needs, I don’t know how to figure out the correct value for “opticalCenter”.

I do not understand the “Table of Optical Centers”… could you explain what that actually is and what value might be correct for my needs?

//EDIT

Sorry for that spamming…

No matter what i set via the “setROI” function, the next reading is “65535” and getRangeStatus() returns 13.

ST’s “User guide” says:

This function programs the new user ROI center. Please note that there is no check in this function. If the ROIcenter vs the ROI size is outside the border, the ranging function returns an error #13

So… can someone tell me twhat correct values are?

//EDIT2

Another thing is, that getSpadNb() always returns different values when restarting my programm.

(I dont set that value by myself)

I seems the sensor calculates that value on its own… why? (and how?)

Ok, i build a function to loop through all possible combinations.

ROI 16x16, opticalCenter 0 →

ROI 16x16, opticalCenter 1 →

(and so on…)

ROI 4x4, opticalCenter 255 →

Here is my (reproduceable) result:

(too many characters, so i uploaded my result to pastebin) : https://pastebin.com/9ByFaSCp

Column 1: OK if getRangeStatus() returned 0 (valid). If not 0, getRangeStatus’s Number

Column 2: ROI XxY

Column 3: opticalCenter (0-255 on each iteration)

Column 4: distance in mm

You can see, that from (16x16 with opticalCenter 0) to (10x10 opticalCenter 3) everyting is ok.

From than on, getRangeStatus() always returns 13, and the readings are thown up.

I can reproduce this - the point where getRangeStatus() returns 13 sometime changes a little bit, but not much.

(opticalCenter 3 to 7, but alwyas at 10x10 ROI)

Strange thing is, while runnuing my test-script a couple of times, there was ONE run, where the whole list of combinations was getRangeStatus() = 0 (valid) while all readings were successfull and valid.

I than ran the script some moe time, but that never happend again.

what is wrong?

Hi Trisse.

I’m afraid your questions are beyond the scope of what we can help with and you would probably need to contact ST for the information you’re looking for.

SparkFun don’t actually make the VL53L1X chips, we just solder them to our own board so our knowledge on the inner workings isn’t as great as the manufacturers would be.

Sure, and thats totaly fine, but some realy smart guy wrote the library you provide on github:

https://github.com/sparkfun/SparkFun_VL … no_Library

I think its “AndyEngland521” (andrew.england@sparkfun.com) because he replied to all issues there.

Maybe (for sure) he can help me here.

Sould i create an issue on Github or could you get him on board / forward this topic to him?

Thanks

Hi, funny you bring this up, as I fixed an issue with setting ROI in v1.2.4 which was published yesterday. Make sure you check out the [library overview section in the hookup guide](https://learn.sparkfun.com/tutorials/qw … y-overview) as well for setting ROI

I think your problem is that you are attempting to configure an ROI that is too big/ too close to the edges. All ROI’s with X or Y over 10 will automatically be centered at SPAD 199, if you want to make your ROI smaller than this, you’ll have to pick an Optical Center that doesn’t allow your region of interest to go beyond the edges of the array. call setROI then call startranging to start ranging with the proper roi. If your ROI goes off the edge, you’ll see bad ranging status as the VL53L1X won’t know where to look. Also in the future, please refrain from emailing SparkFun employees, instead, the best way is to file an issue on github. Thanks and I hope this is of some help!

p.s. make sure you update your library to v1.2.4