Skip to main content
AGreen
Associate II
October 30, 2022
Solved

Help on issues found in VL53LX API v1.2.8?

  • October 30, 2022
  • 1 reply
  • 1141 views

I'm using the latest API version (1.2.8) available from the VL53L4CX product page.

In my project I have implemented an interface to set configurations or run calibrations.

I am also using this driver for both the VL53L4CD and VL53L4CX, since the driver seems to be universal for all VL53LX parts. Correct me if I'm wrong.

(Problem 1 )

I noticed the function VL53LX_PerformOffsetPerVcselCalibration(~) would hang seemingly at random calls.

Below is the block of code with the issue and a potential fix. After I changed it, I've had no issues running it.

while ((Status == VL53LX_ERROR_NONE) && (inloopcount < Max) && (inloopcount < OverMax)) {
 
Status = VL53LX_WaitMeasurementDataReady(Dev);
 
if (Status == VL53LX_ERROR_NONE)
 
Status = VL53LX_GetMultiRangingData(Dev, &RangingMeasurementData);
 
pRange = &(RangingMeasurementData.RangeData[0]);
 
goodmeas = (pRange->RangeStatus == VL53LX_RANGESTATUS_RANGE_VALID);
 
ics = pdev->ll_state.cfg_internal_stream_count;
 
if ((Status == VL53LX_ERROR_NONE) && goodmeas) {
 
if (ics & 0x01) {
 
sum_ranging_range_A += pRange->RangeMilliMeter;
 
offset_meas_range_A++;
 
} else {
 
sum_ranging_range_B += pRange->RangeMilliMeter;
 
offset_meas_range_B++;
 
}
 
// NOTE: COMMENT OUT / REMOVE
inloopcount = offset_meas_range_A + offset_meas_range_B;
 
}
 
Status = VL53LX_ClearInterruptAndStartMeasurement(Dev);
 
// NOTE: ADD THIS
inloopcount++;
 
}

(Problem 2)

In the function VL53LX_SetDistanceMode(~) it will return with an error if setting distance to SHORT if using a VL53L4CD (Close Distance). Is this correct behavior? It seems counterintuitive. I noted the line below where it checks the type.

VL53LX_Error VL53LX_SetDistanceMode(VL53LX_DEV Dev,
		VL53LX_DistanceModes DistanceMode)
{
	VL53LX_Error Status = VL53LX_ERROR_NONE;
	uint32_t inter_measurement_period_ms;
	uint32_t TimingBudget = 0;
	uint32_t MmTimeoutUs = 0;
	uint32_t PhaseCalTimeoutUs = 0;
 
	LOG_FUNCTION_START("%d", (int)DistanceMode);
 
	if ((DistanceMode != VL53LX_DISTANCEMODE_SHORT) &&
		(DistanceMode != VL53LX_DISTANCEMODE_MEDIUM) &&
		(DistanceMode != VL53LX_DISTANCEMODE_LONG))
		return VL53LX_ERROR_INVALID_PARAMS;
 
	if (IsL4(Dev) && (DistanceMode == VL53LX_DISTANCEMODE_SHORT)) // NOTE: This returns error for VL53L4CD (Close Distance)
		return VL53LX_ERROR_INVALID_PARAMS;
 
	inter_measurement_period_ms = VL53LXDevDataGet(Dev,
				LLData.inter_measurement_period_ms);
 
	if (Status == VL53LX_ERROR_NONE)
		Status = VL53LX_get_timeouts_us(Dev, &PhaseCalTimeoutUs,
			&MmTimeoutUs, &TimingBudget);
 
	if (Status == VL53LX_ERROR_NONE)
		Status = SetPresetModeL3CX(Dev,
				DistanceMode,
				inter_measurement_period_ms);
 
	if (Status == VL53LX_ERROR_NONE) {
		VL53LXDevDataSet(Dev, CurrentParameters.DistanceMode,
				DistanceMode);
	}
 
	if (Status == VL53LX_ERROR_NONE) {
		Status = VL53LX_set_timeouts_us(Dev, PhaseCalTimeoutUs,
			MmTimeoutUs, TimingBudget);
 
		if (Status == VL53LX_ERROR_NONE)
			VL53LXDevDataSet(Dev, LLData.range_config_timeout_us,
				TimingBudget);
	}
 
	LOG_FUNCTION_END(Status);
	return Status;
}

Let me know what you think.

Regards,

Andrew

This topic has been closed for replies.
Best answer by John E KVAM

On the first one - I think you found a bug - thank you. I'm told my software guys will respond in a couple of days with a fix.

Why is there is no 'short' on the VL53L4CD (Close distance)??

Laser power is measured in power over time. So one can have a very intense light - as long as it's a very short pulse - or one can have a more dim light - but on for a longer time.

On the VL53L4CD, we chose a rather bright light - but that means we need a slower pulse repetition rate.

Turns out we already had that - it's just the medium distance mode. (The only difference between short, medium and long - is the pulse repetition rate.)

So do not 'invent' a short distance mode. Cranking up the pulse repetion rate will make the device non eye-safe. And one does not need it. There is plenty of light.

  • john

1 reply

John E KVAM
John E KVAMBest answer
ST Employee
November 7, 2022

On the first one - I think you found a bug - thank you. I'm told my software guys will respond in a couple of days with a fix.

Why is there is no 'short' on the VL53L4CD (Close distance)??

Laser power is measured in power over time. So one can have a very intense light - as long as it's a very short pulse - or one can have a more dim light - but on for a longer time.

On the VL53L4CD, we chose a rather bright light - but that means we need a slower pulse repetition rate.

Turns out we already had that - it's just the medium distance mode. (The only difference between short, medium and long - is the pulse repetition rate.)

So do not 'invent' a short distance mode. Cranking up the pulse repetion rate will make the device non eye-safe. And one does not need it. There is plenty of light.

  • john
If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
AGreen
AGreenAuthor
Associate II
November 7, 2022

I'm glad I could help and thank you for clarifying how the distance mode works. I have the VL53L4CD working well in my project but I was just curious about that function.

Andrew