cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L1X - Problems with Ultra Lite Driver (ULD) crosstalk functions "VL53L1X_SetXtalk()" and "VL53L1X_GetXtalk()". Wrong values.

Hardwariano
Associate III

Hello

I have problems with Ultra Lite Driver (ULD) crosstalk functions "VL53L1X_SetXtalk()" and "VL53L1X_GetXtalk()". I'm not sure if I have made a mistake or if there is an error in the ULD. I will give an example to explain my problem.

#######################################################

################## VL53L1X_CalibrateXtalk ##################

#######################################################

First of all I have to say that the self-calibration of the crosstalk VL53L1X_CalibrateXtalk()) works well (or I think so).

0693W0000058xl2QAA.pngAfter that correction (16bit register = 0x0fbe --> xtalk = 63 cps), my sensor returns RIGHT measurements.

##################################################

################## VL53L1X_GetXtalk #################

##################################################

The first issue comes when I try to read crosstalk value stored in internal VL53L1X memory using "VL53L1X_GetXtalk()". I receive 32 bits of data (0x0FBE0000) and this function says xtalk = 0 cps, which is not true because I previously used "VL53L1X_CalibrateXtalk()":

0693W0000058y3pQAA.pngI found 2 solutions to get xtalk = 63 cps. Please, tell me if they are correct:

1) Use "Read Word" (VL53L1_RdWord) instead of "Read Double Word" (VL53L1_RdDWord).

status = VL53L1_RdWord(dev,ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS, &tmp);
	*xtalk = (uint16_t)(tmp*1000)>>9; /* * 1000 to convert kcps to cps and >> 9 (7.9 format) */

2) Use the original "Read Double Word" (VL53L1_RdDWord) but change right shift from 9 to 25 (16+9). Note the new parentheses to give priority to shifting over casting:

status = VL53L1_RdDWord(dev,ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS, &tmp);
	*xtalk = (uint16_t)((tmp*1000)>>25);

#################################################

################## VL53L1X_SetXtalk ################

#################################################

The second issue comes when I try to write manually xtalk = 63 cps using "VL53L1X_SetXtalk()":

0693W0000058yQFQAY.pngAfter that operation (xtalk<<9/1000), xtalk = 63 cps is converted into 16bit register = 0x0020. Sending 0x0020 causes my sensor to return INCORRECT measurements.

I know 16bit register = 0x0020 is incorrect because if I send 16bit register = 0x0fbe (previosly calculated by "VL53L1X_CalibrateXtalk()", as I explained at the beginning of this thread), my sensor works well again.

  

Summing up:

  • VL53L1X_CalibrateXtalk --> OK. VL53L1X returns good measurements.
  • VL53L1X_GetXtalk --> VL53L1X internal register has right values, but crosstalk value returned is not right.
  • VL53L1X_SetXtalk --> Values sent to VL53L1X internal register are not correctly calculated. As a result, VL53L1X returns bad measurements.

My questions are:

1) Why "VL53L1X_GetXtalk()" returns incorrect values? Are my modifications correct?

2) Why "VL53L1X_SetXtalk()" doesn't work?

Regards

2 REPLIES 2
Hardwariano
Associate III

Any idea what the problem might be? I'm stuck with this and I can't continue with my project.

I tried to make the example as clear as possible, but if it is not well understood I can try to explain it in another way.

Thanks

Hardwariano
Associate III

In the end I think I was able to solve the problem. It has taken me a long time and a lot of testing, but I think it works well now. I am sharing this because I think there is some kind of bug in the ST API and I did not receive any response months ago confirming or denying my calculations.

##################################################

################## VL53L1X_GetXtalk #################

##################################################

This is the original code:

    status = VL53L1_RdDWord(dev,ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS, &tmp);
    	*xtalk = (uint16_t)(tmp*1000)>>9;

This is my code:

    status = VL53L1_RdDWord(dev,ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS, &tmp);
    	*xtalk = (uint16_t)((tmp*1000)>>25);

Changes:

1) I replace a 9 with a 25 because, otherwise, the result of the reading is always 0, as I explained in my previous post.

2) I add parentheses for bit shifting to be done before casting to uint16. This may not be a problem for ST microcontrollers, but it is a problem for the microcontrolers I am using. This gave me a lot of headaches until I figured it out.

#################################################

################## VL53L1X_SetXtalk ################

#################################################

This is the original code:

status = VL53L1_WrWord(dev, ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS, (XtalkValue<<9)/1000); 
/* * << 9 (7.9 format) and /1000 to convert cps to kpcs */

This is my code:

status = VL53L1_WrWord(dev, ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS,(uint16_t)((XtalkValue<<9)/1000)); 
/* * << 9 (7.9 format) and /1000 to convert cps to kpcs */

Changes:

1) Casting to uint16

2) I add parentheses for the same reason I explained for VL53L1X_GetXtalk.

With the changes I have discussed I have managed to read (getXtalk) and write (setXtalk) manually the same crosstalk value that the sensor calculates automatically with "VL53L1X_CalibrateXtalk()". Before these changes the values that I read and wrote manually were not consistent at all.

As I said, I don't know if these problems I have had are due to the fact that I use a different platform than ST or if there is some kind of bug in the ST API.