2025-02-10 05:34 AM
Hi
I am using VL53L4CD for detecting presence of an object at a distance below 300mm. I have considered Examnple4 Ultra Low Power as the base. I am able to get the interrupts when an object comes below 300mm distance as expected.
But in this scenario if the object stays at a distance below 300mm I keep on getting the interrupts after a regular interval.
What I want to implement is that I should get interrupt once an object comes below 300mm and once when it goes away.
Is it possible to get this functionality?
2025-02-10 06:55 AM
With the VL53L sensors each range is independent of any other range. So, indeed, you will get an interrupt every time you range if you have your thresholds and you have an object lower than your threshold.
If you want to trigger exactly once when the object comes near and get another interrupt when the object goes away, you should get the interrupt, reconfigure your interrupts for above your threshold. Once the object has gone away, you can go back to your 'below' threshold configuration.
In order to make this work right you might have to do a bit of a re-write on the interrupt section.
We simplified that code a bit as 99% of our customers don't need this functionality:
The register definition below
SYSTEM__INTERRUPT_CONFIG_GPIO
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
RESERVED |
int_mode |
||||||
R |
R/W |
[2:0] |
int_mode: Interrupt mode source for Range readings (single bit to set usage to either range or phase) 0: Disabled |
Try playing with 'out of Window'. Make sure you get an interrupt when you object leaves the area.
But I honestly think you are going to do better, by detecting the interrupt, and assuming your object went away when you stop getting them.
Good luck.
john