2024-08-26 02:20 PM
Hello,
I have been using the this ToF sensor along an ESP32-WROOM MCU for a while without major issues. My impementation of the i2c interface seems to be working well since in most simple ranging cases everything works well.
However, recently, i have been playing around with detection thresholds. I discovered that when I enable detection thresholds while in autonomous mode, I am unable to start ranging. In fact, the sensor gets properly configured (resolution, ranging mode, integration time, frequency and detection thresholds) but when it starts ranging (function vl53l8_start_ranging), error VL53L8_STATUS_ERROR occurs. The error gets raised in this part of the function
/* Read ui range data content and compare if data size is the correct one */
status |= l8_dci_read_data(p_dev,
(uint8_t*)p_dev->temp_buffer, 0x5440, 12);
(void)memcpy(&tmp, &(p_dev->temp_buffer[0x8]), sizeof(tmp));
if(tmp != p_dev->data_read_size)
{
status |= L8_STATUS_ERROR;
}
because the data that is read has a size of zero (tmp is zero).
However, I have no clue why this is happening since the Smart Person Detection code implements such a configuration (Autonomous 4x4 with low power consumption and detection thresholds). And when i disable detection thresholds while in autonomous it works well. Also, when i enable detection thresholds while in continuous mode, it also works well.
Do you have an idea why this is happening?
Note that at first, I was using ULD driver version v1.0.4 but i also did some testing with version v2.0.0 and also with the universal driver VL53LMZ_ULD_API_v2.0.10. In all my tests, I was unable to properly configure the sensor.
2024-08-26 02:47 PM
When playing around with threshold detection, do you only get the interrupt when something gets below the threshold point?
If I read your complaint correctly (not completely likely) you are reading zero bytes.
That's what might happen if you read the buffer before the interrupt triggers. Would that be possible?
Because you can set up to 64 interrupts on so many different items, one would be left wondering if they were configured correctly.
Put a breakpoint on the interrupt-service routine and convince yourself that the interrupt was indeed firing correctly. Then we can worry about why you are not reading the data that you should be.
I always hate answering questions with questions, but I don't have any other great ideas.
- john