cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L3CX detects no targets

CSchr.14
Associate II

Dear STM-Team,

our first custom boards with VL53L3CX just arrived and I’ve ported the API to Zephyr (already did that for VL51).

I can see that the comms work, because I can read the chip id and start the mandatory calibrations as well as the measurement itself.

But I can‘t get a successful target detection.

The first measurement seems okay (it has the status which according to the d/s says that it is the first measurement and can be discarded) but after that, all measurements have 0 detected targets and status 255

any advise?

thanks,

Chris

8 REPLIES 8
CSchr.14
Associate II

can be closed, I've ignored the STDINT typecheck warning and after fixing it, it works - sorry!

CSchr.14
Associate II

ugh, it's not working anymore. I don't know what's going on. I had it working:

[00:00:09.044,769] <inf> vl53l3cx: VL53LX_GetCalibrationData suceeded

[00:00:09.063,598] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:10.791,778] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:10.791,809] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 6 max: 346 min: 343 mm: 346

[00:00:10.791,809] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:10.791,839] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:10.791,839] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:10.791,839] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:12.520,019] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:12.520,019] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 0 max: 389 min: 389 mm: 389

[00:00:12.520,050] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:12.520,050] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:12.520,050] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:12.520,050] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:14.248,229] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:14.248,260] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 0 max: 344 min: 334 mm: 334

[00:00:14.248,260] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:14.248,260] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:14.248,291] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:14.248,291] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:15.976,470] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:15.976,470] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 0 max: 390 min: 389 mm: 389

[00:00:15.976,470] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:15.976,501] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:15.976,501] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:15.976,501] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:17.704,711] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:17.704,742] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 0 max: 384 min: 368 mm: 369

[00:00:17.704,742] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:17.704,742] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:17.704,772] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:17.704,772] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:19.432,983] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:19.433,013] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 0 max: 374 min: 373 mm: 373

[00:00:19.433,013] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:19.433,013] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:19.433,013] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:19.433,044] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:21.161,224] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:21.161,254] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 0 max: 377 min: 370 mm: 370

[00:00:21.161,254] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:21.161,254] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:21.161,285] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:21.161,285] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:22.889,495] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:22.889,526] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 0 max: 378 min: 355 mm: 355

[00:00:22.889,526] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:22.889,556] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:22.889,556] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:22.889,556] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:24.617,767] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:24.617,767] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 0 max: 379 min: 369 mm: 369

[00:00:24.617,797] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:24.617,797] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:24.617,797] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:24.617,797] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:26.346,069] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:26.346,099] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 0 max: 379 min: 360 mm: 360

[00:00:26.346,099] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:26.346,130] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:26.346,130] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:26.346,130] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:28.074,371] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:28.074,371] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 0 max: 380 min: 369 mm: 369

[00:00:28.074,401] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:28.074,401] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:28.074,401] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:28.074,401] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:29.802,673] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:29.802,673] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 0 max: 374 min: 354 mm: 354

[00:00:29.802,673] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:29.802,703] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:29.802,703] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:29.802,703] <dbg> vl53l3cx.vl53l3cx_thread: Measurement loop

[00:00:31.530,914] <dbg> vl53l3cx.vl53l3cx_thread: targets detected: 1

[00:00:31.530,944] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 0 max: 379 min: 368 mm: 368

[00:00:31.530,944] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:31.530,975] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

[00:00:31.530,975] <dbg> vl53l3cx.vl53l3cx_thread: Rangedata status: 255 max: -1 min: -1 mm: -1

and then cleaned up the code a bit, and now I'm back to status 255 for all readings

Julien NGUYEN
ST Employee

​Hi Chris, I'm glad you already got the X-NUCLEO-53L3A2 board. Have your downloaded the VL53L3CX API from st.com (STSW-IMG015)?

Could you share the part of code where you control the VL53L3CX to have a look?


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi Julien,

thanks for the quick reply.

actually it‘s already a custom board (designed before and ordered as soon as distributors stocked the VL53x).

/* sensor API init */

VL53LX_Error err = VL53LX_DataInit(dev_data);

if (err < 0) {

LOG_ERR("VL53LX_DataInit return error (%d)", err);

return -ENOTSUP;

}

LOG_DBG("VL53LX_DataInit succeeded");

err = VL53LX_PerformRefSpadManagement(drv_data);

while(err)

{

LOG_ERR("VL53LX_PerformRefSpadManagement returned: %d", err);

k_sleep(K_SECONDS(3));

err = VL53LX_PerformRefSpadManagement(drv_data);

}

err = VL53LX_PerformOffsetPerVcselCalibration(drv_data, 100);

while(err)

{

LOG_ERR("VL53LX_PerformOffsetPerVcselCalibration returned: %d", err);

k_sleep(K_SECONDS(3));

err = VL53LX_PerformOffsetPerVcselCalibration(drv_data, 100);

}

VL53LX_CalibrationData_t calibration_data;

err = VL53LX_GetCalibrationData(drv_data, &calibration_data);

while(err)

{

LOG_ERR("VL53LX_GetCalibrationData returned: %d", err);

k_sleep(K_SECONDS(3));

err = VL53LX_GetCalibrationData(drv_data, &calibration_data);

}

LOG_INF("VL53LX_GetCalibrationData suceeded");

VL53LX_SetMeasurementTimingBudgetMicroSeconds(drv_data, 66000);

err = VL53LX_StartMeasurement(drv_data);

while(true)

{

LOG_DBG("Measurement loop");

VL53LX_MultiRangingData_t ranging_data;

k_sleep(K_MSEC(800));

err = VL53LX_ClearInterruptAndStartMeasurement(drv_data);

if(err)

{

LOG_ERR("VL53LX_StartMeasurement returned: %d", err);

}

k_sleep(K_MSEC(800));

err = VL53LX_WaitMeasurementDataReady(drv_data);

if(err)

{

LOG_ERR("VL53LX_WaitMeasurementDataReady returned: %d", err);

}

k_sleep(K_MSEC(111));

err = VL53LX_GetMultiRangingData(drv_data, &ranging_data);

if(err)

{

LOG_ERR("VL53LX_GetMultiRangingData returned: %d", err);

}

LOG_DBG("targets detected: %d", ranging_data.NumberOfObjectsFound);

for(u8_t i = 0; i < VL53LX_MAX_RANGE_RESULTS; i++)

{

VL53LX_TargetRangeData_t range_data = ranging_data.RangeData[i];

LOG_DBG("Rangedata status: %u max: %d min: %d mm: %d", range_data.RangeStatus, range_data.RangeMaxMilliMeter, range_data.RangeMinMilliMeter, range_data.RangeMilliMeter);

}

}

after some further trying I found that running measurements continuously works while giving status 255 for first measurement and (in my test case) valid results for the next 4 measurements.

Sorry, can‘t answer directly in the forum (gives invalid error) and formating via mail is a mess
Julien NGUYEN
ST Employee

​Effectively, it is a mess. please send me yr piece of code by email to Phuong.nguyen@st.com. Thanks, Julien


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Julien, have you received my mail? Just asking because maybe the attachment has been blocked
ABesp.1
Associate II

Hello,

I've got a similar issue. I'm using six VL53L3CX sensors (3x VL53L3CX-SATEL) and two independent I2C busses (Nucleo-G01BRE). To each bus three sensors are attached and share a common interrupt wire. I use FreeRTOS to create two tasks, which synchronize both busses independently. The Sensors are measuring sequentially, to prevent interference. Within the ISRs the binary semaphores are released. These are acquired within the tasks in order to read the last measurement result. The first two interrupts are ignored and only after the third interrupt the range result is reported, which is "Target not detected" (range_status = 255). According to the user manual the first interrupt is after init and second after range 1. Afterwards the measurement of current sensor is stopped and the next one on the same bus is started. I have tried to put osDelay(timing_budget) after first and second interrupt clearing and it works. I assume there is a timing issue but don't know why. Any idea what I am doing wrong?

Cheers

Alex

Update 20.09.2021:

Instead of using semaphores I've implemented non-blocking polling as follows:

while (1)
{
	status_result = VL53LX_GetMeasurementDataReady(pdevice, &data_ready);
	if (status_result != VL53LX_ERROR_NONE)
	{
		Error_Handler();
	}
	if (data_ready)
		break;
	else
		osDelay(POLLING_PERIOD_MS);
}

This works in contrast to ISR solution.