2020-10-26 03:29 AM
Hello
I use VL53L1X in polling mode to detect hand presence in the range [30, 200] mm. It works well and VL53L1X_GetResult() returns values continuously.
Now I want to add window thresholds [40, 80] mm because I need GPIO interrupt to trigger some other especial functionality when my hand is inside range [40, 80] mm.
After setting window thresholds with "VL53L1X_SetDistanceThreshold()", function VL53L1X_GetResult() only returns distance values when my hand is inside [40,80].
However I need VL53L1X_GetResult() to return values continuously, regardless of the window configuration or distance from my hand to the sensor.
Is it possible to do that?
2020-10-30 12:00 AM
I reviewed other forum threads.
Thread title: Is it possible to disable hardware interrupt on VL53L1, but still receive measurements?
@John E KVAM --> The 'done' bit and the interrupt are tied together. I think I knew that but never considered the implication.
It seems that VL53L1X works continuously but only returns distance values when window thresholds are met. Am I right?
I need to analyze distance values regardless of whether they are inside or outside window thresholds. Is it possible to do that?
Thanks
2020-10-30 07:42 AM
Sure! You don't have to use thresholds. They are there only if you need them. If you don't set them up, you will get an interrupt after every range.
But you don't even need to use the interrupt if you don't want to.
You can poll by repeatly asking the sensor, "Are you done yet?"
Or there is a function that does the poll for you. You call that and it will return when the sensor is done.
(The interrupt triggers in this case, but you either don't connect, or don't pay any attention to it.)
Good luck,
2020-11-11 06:03 AM
Thanks for your answer @John E KVAM .
"If you don't set them up, you will get an interrupt after every range. "
I didn't know that. I tried it and now I get an interrupt after every range as you said.
Until now, when I wanted to measure continuously ingnoring thresholds, I wrote value 0x20 to register 0x0046 (SYSTEM__INTERRUPT_CONFIG_GPIO), as ULD manual says:
However my problem persists: I want to use window thresholds and interrupt GPIO pin. And I want to store the distance values measured by VL53L1X.
The problem is that the sensor ONLY returns distance values when the target is within window thresholds. When the target is outside that thresholds, the sensor DOESN'T RETURN any value.
Is it possible to get distance values when target is outside window thresholds?
2020-11-11 08:40 AM
You are using the ULD - UltraLite Driver.
So the threshold code looks like:
VL53L1X_ERROR VL53L1X_SetDistanceThreshold(uint16_t dev, uint16_t ThreshLow,
uint16_t ThreshHigh, uint8_t Window,
uint8_t IntOnNoTarget)
{
VL53L1X_ERROR status = 0;
uint8_t Temp = 0;
status = VL53L1_RdByte(dev, SYSTEM__INTERRUPT_CONFIG_GPIO, &Temp);
Temp = Temp & 0x47;
if (IntOnNoTarget == 0) {
status = VL53L1_WrByte(dev, SYSTEM__INTERRUPT_CONFIG_GPIO,
(Temp | (Window & 0x07)));
} else {
status = VL53L1_WrByte(dev, SYSTEM__INTERRUPT_CONFIG_GPIO,
((Temp | (Window & 0x07)) | 0x40));
}
status = VL53L1_WrWord(dev, SYSTEM__THRESH_HIGH, ThreshHigh);
status = VL53L1_WrWord(dev, SYSTEM__THRESH_LOW, ThreshLow);
return status;
}
And indeed
#define SYSTEM__INTERRUPT_CONFIG_GPIO 0x0046
So the manual and the function at least agree on the register to be messed with.
You state:
"The problem is that the sensor ONLY returns distance values when the target is within window thresholds. When the target is outside that thresholds, the sensor DOESN'T RETURN any value."
Looks to me like you need to mess with the parameter - IntOnNoTarget, That reverses when you get the interrupt. IN or OUT of the min/max you have set up.