cancel
Showing results for 
Search instead for 
Did you mean: 

VL53L1_SetThresholdConfig() API not working when setting up threshold in Vl53L1x sensor

Akansha
Associate II

Hi,

I am working on Vl53L1x sensor for designing Obstacle Detection sensor.

I want to set the distance threshold for obstacle detection in particular range only.

I have set threshold after following APIs:

 status = VL53L1_DataInit(Dev);

 status = VL53L1_StaticInit(Dev);

I have set following parameters:

Detectionconfig->DetectionMode = 1;
Detectionconfig->Distance.CrossMode = 3;
Detectionconfig->IntrNoTarget = 0;
Detectionconfig->Distance.High = 2000;
Detectionconfig->Distance.Low = 100;
status = VL53L1_SetThresholdConfig(Dev, Detectionconfig );

As per above parameters sensor should report distance measurement to host only when there is any obstacle in range (10cm - 200cm) but this sensor is still reporting data of ceiling which is 3500cm away.

Could you help me in resolving this issue?

Along with this can you explain me  IntrNoTarget parameter because as i got from manual that if this is set to 0 then sensor will not give ranging data is there is no target but after setting this to 0 sensor is still reporting ranging data with status 2 i.e, either there is no target or it is too far.

Please explain me the role of this parameter.

Regards

Akansha

3 REPLIES 3
John E KVAM
ST Employee

According to the user manual, you got it right. Looks like you pretty much copied the code. A very reasonable idea. (And it should have worked.)

VL53L1_SetThresholdConfig() is the function to be used.
Example of use:
detectionConfig.DetectionMode = 1;
detectionConfig.Distance.CrossMode = 2;
detectionConfig.Rate.CrossMode = 0;
detectionConfig.IntrNoTarget = 0;
detectionConfig.Distance.High = 1000;
detectionConfig.Distance.Low = 100;
detectionConfig.Rate.High = 0;
detectionConfig.Rate.Low = 0;
status = VL53L1_SetThresholdConfig(&VL53L1Dev, &detectionConfig );
to program the device to report ranging only when an object is detected within 10 cm and
1m.
The function VL53L1_GetThresholdConfig() allows to get the programmed report
filtering/threshold configuration.

The only think I can think of is that you are not in LONG ranging mode. In either short or medium, you will get something called RADAR ALIASING (which you should google).

And it is the radar aliasing that is giving you a false reading, and triggering your interrupt.

Check the RangeStatus. Is it 4? That is a 'Wrap-around' error. Another name for radar aliasing. And it will cause a long range target to look like a short range target.

As to IntrNoTarget...

What do you want to do if there is no target either within the window or outside of the window?

You might want to know of this situation.

In your case - only wanting to know if something is within a window, this parameter should not be set.


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.

I am using this same driver but having trouble with the exact C++ code syntax for the threshold parameters. Can you provide an example of the exact code listing syntax? The code shown in original post does not compile, the error is:

'detectionConfig' does not name a type

Thank you

CJani.1
Associate II

I received a response from Pololu with the code syntax, as follows:

VL53L1_DetectionConfig_t detectionConfig;
 
detectionConfig.DetectionMode = 1;
detectionConfig.Distance.CrossMode = 0;
detectionConfig.Distance.Low = 80;
 
VL53L1_SetThresholdConfig(Dev, &detectionConfig);

However this threshold setup isn't working. The ranging is triggering when there is no target in the configured threshold. I verified this by looking at GPIO1with a scope and its triggering continuously. Any ideas as to why this is not working.

I am using the sensor just for proximity sensing, i.e., when an object is within 80mm of the sensor. I do not read the distance data, just log a time stamp and clear the interrupt with:

status = VL53L1_ClearInterruptAndStartMeasurement(Dev);

I am using the Fast Ranging mode setup as described in ST app note AN5263 (100Hz ranging). As described in the app note I am discarding the first interrupt. But the threshold filter never takes affect.