VL53L1X - Problems with Ultra Lite Driver (ULD) crosstalk functions "VL53L1X_SetXtalk()" and "VL53L1X_GetXtalk()". Wrong values.
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).
After 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()":
I 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()":
After 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
