LooUQ / st_vl53l4cd

ESP-IDF Component for STMicroelectronics Ultra-Light Driver for VL53L4CD TOF sensor
0 stars 0 forks source link

Runs only in autonomous mode, but is expected to run continuously and some corious with setRangeTiming and read back #1

Open Hainer1 opened 1 month ago

Hainer1 commented 1 month ago

I am using ESP-IDF5.3.1 with an ESP32S3WROOM1N8R2 and TOF VL53L4CD.@ 400000Hz

During TOF initialisation I set the timings to: VL53L4CD_SetRangeTiming(i2c_address, 10, 0);

After a delay of about 50ms, I read back the values with: VL53L4CD_GetRangeTiming(i2c_address, &timing_budget_ms, &inter_measurement_ms); ESP_LOGI(TAG, "Ausgelesen: Range Timing Budget: %lu ms, Inter-Measurement Period: %lu ms", timing_budget_ms, inter_measurement_ms); ESP_LOGI(TAG, "Ausgelesen: Range Timing Budget: %" PRIu32 " ms, Inter-Measurement Period: %" PRIu32 " ms", timing_budget_ms, inter_measurement_ms);

The result is: I (2309) VL53L4CD_API: Sensor runs in autonomous mode I (2319) DISTANCE SENSOR: Ausgelesen: Range Timing Budget: 19 ms, Inter-Measurement Period: 101 ms I (2329) DISTANCE SENSOR: Ausgelesen: Range Timing Budget: 19 ms, Inter-Measurement Period: 101 ms

I have also added a print output to the API that indicates whether the mode is autonomous or continuous. I expect continuous, so I configure inter_measurement to 0, but I only get I (2309) VL53L4CD_API: Sensor is running in autonomous mode. Here is my customisation in the API: `VL53L4CD_Error VL53L4CD_StartRanging( Dev_t dev) { VL53L4CD_Error status = VL53L4CD_ERROR_NONE; uint32_t tmp;

status |= VL53L4CD_RdDWord(dev, VL53L4CD_INTERMEASUREMENT_MS, &tmp);

/* Sensor runs in continuous mode */
if(tmp == (uint32_t)0)
{
    status |= VL53L4CD_WrByte(dev, VL53L4CD_SYSTEM_START, 0x21);
    ESP_LOGI("VL53L4CD_API", "Sensor runs in continuous mode");
}
/* Sensor runs in autonomous mode */
else
{
    status |= VL53L4CD_WrByte(dev, VL53L4CD_SYSTEM_START, 0x40);
    ESP_LOGI("VL53L4CD_API", "Sensor runs in autonomous mode");
}

return status;

}`

GregTerrell commented 1 month ago

Thanks for reporting, I had performed basic testing on the code port when it was created earlier this year but must not have covered that case. I was working on 2 other ST TOF sensors for a client project and decided to do a conversion of the 4CD for my own use in the same time frame. I have not got around to my project for the VL53L4CD yet... maybe late this year.

My project for the VL53L4CD however will be on a system with a Nordic nRF9151, so this library will not likely be maintained for the ESP32.