Quantcast
Viewing all articles
Browse latest Browse all 81

VL53L0X code to minimize latency

Hello!

I am using several VL53L0X’s with Pololu’s library on an ESP32. I am attempting to retrieve ToF ranging measurements with as low latency as possible. I am then sending data wirelessly over UDP.

I’ve noticed that the while loop in readRangeContinuousMillimeters effectively creates a delay when included in my main loop code. This is because the function initiates a reading and then we must wait until the results are in, 20-30ms.

Instead I would like to turn on startContinuous in setup and then pool the VL53L0X to see when new data is ready in my main loop, sending it immediately if this is the case. I cannot find a library function to do this and thus have modified code from readRangeContinuousMillimeters to achieve this.

Could anyone confirm if this is 1) stable and 2) as low latency as possible? Do I need to worry about replicating the timeout portion of the code from VL53L0X::readRangeContinuousMillimeters?

My setup:
ToFSensor.setTimeout(100);
ToFSensor.setMeasurementTimingBudget(20000);
ToFSensor.startContinuous(100);

My loop:
// see if a reading is ready…
if ((ToFSensor.readReg(ToFSensor.RESULT_INTERRUPT_STATUS) & 0x07) != 0) {
uint16_t range = ToFSensor.readReg16Bit(ToFSensor.RESULT_RANGE_STATUS + 10);
ToFSensor.writeReg(ToFSensor.SYSTEM_INTERRUPT_CLEAR, 0x01);
// send range data…
}

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 81

Trending Articles