When using a vl53l8cx configured for motion detection, which of the fields in the motion_indicator struct can I check to see if there was motion?
I understand that the motion[32] array has measurements but I'd like to be able to poll this infrequently and check if there was an event between these polls. Something like a motion_detected flag that latches?
From the current example code, the motion detection plugin does **not** appear to provide a separate latched `motion_detected` flag in the result structure.
The intended usage is to:
1. configure the **motion indicator**, 2. set **detection thresholds** on `VL53LMZ_MOTION_INDICATOR`, 3. read the ranging results, 4. check whether `Results.motion_indicator.motion[...]` exceeds the configured threshold.
In the example, motion is considered detected when the motion indicator value of a zone is greater than or equal to the configured threshold:
So, based on the provided ULD example, motion detection is done through **threshold comparison on `motion[]` values**, not through a sticky event flag.
If your application cannot use interrupts and needs infrequent polling, then a latched “motion happened since last poll” behavior would need to be implemented on the host side.
The interrupt autostop feature is used to abort the ranging session during a measurement. By default, the sensor cannot be stopped during a measurement, because the frame measurements need to be completed. However, by using autostop, the frame measurements are aborted when an interrupt is triggered. The autostop feature is useful when it is combined with a detection threshold. When a target is detected, the current measurement is automatically aborted. Autostop can be used in a customer state machine to switch quickly to another sensor configuration. An interrupt autostop feature can be enabled by using the function vl53l8cx_set_detection_threshold_auto_stop(). After a measurement is aborted, it is recommended to stop the sensor by using the function vl53l8cx_stop_ranging()
For more questions, please refer to the Q&A documents
Please refer to the user manual for detaiel information. How about the reason to reduce the polling frequency? To reduce the power consumption or just limited by the MCU performance ?
If I2C is too busy while MCU is comparatively free, you can increase the I2C freq to maximum like 1000kHz.The polling freq is decided by microcontroller side, motion detected status is ready by the sensor. Maybe you can modify the polling freq to low and increase the I2C freq to maximum. This will give you more freedom I2C bus
From the current example code, the motion detection plugin does **not** appear to provide a separate latched `motion_detected` flag in the result structure.
The intended usage is to:
1. configure the **motion indicator**, 2. set **detection thresholds** on `VL53LMZ_MOTION_INDICATOR`, 3. read the ranging results, 4. check whether `Results.motion_indicator.motion[...]` exceeds the configured threshold.
In the example, motion is considered detected when the motion indicator value of a zone is greater than or equal to the configured threshold:
So, based on the provided ULD example, motion detection is done through **threshold comparison on `motion[]` values**, not through a sticky event flag.
If your application cannot use interrupts and needs infrequent polling, then a latched “motion happened since last poll” behavior would need to be implemented on the host side.
Best regards,
Bin FAN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.