Closed linzha0 closed 7 years ago
I put time record : Time = millis(); in the interrupt, it's same result.
Then i use ShortRangeHighSpeed example and put time record : Time = millis(); in the interrupt,it's works fine. Juts got problem to use myLidarLite.distance().
@CrazyPopLin the Lidar code is not using any interrupts. Your problem is due to the fact that the distance operations is blocking at these lines: https://github.com/garmin/LIDARLite_v3_Arduino_Library/blob/master/src/LIDARLite.cpp#L243-L266, as it simply waits until the data is ready.
Another option would be init the measurement manually: https://github.com/garmin/LIDARLite_v3_Arduino_Library/blob/master/src/LIDARLite.cpp#L171-L180 and then read the busy flag in your loop. And finally read the distance measurement when data is actually ready.
I did the same for my flight controller: https://github.com/Lauszus/LaunchPadFlightController/blob/Lidar/src/LidarLiteV3.c#L68-L98, as I did not want it to block my main loop.
@Lauszus ,thanks for your help.
You can also use my own library which is meant to be asynchronous. LidarEnhanced
Hi, I am use arduino nano board to do project which collects range data of Lidar Lite V3 and time period from micro optical sensor.
Here is the code:
Basically, the photo sensor will trig a interrupt as soon as something cover it or leave it. Then the Lidar rotate 360 degree I will get 30 time durations by optical sensor. 28 of them should be almost close, 29th is small and 30th is large to determine the zero position. Because most of covers are the normal size and one is small then normal size and one is larger than normal size. As you can see the code, without int d =myLidarLite.distance(), the durations lists below:
Obviously, this Lidar API cause interrupt function process inaccurate so that time duration calculations are wrong. Is that lidar API take too much time so that interrupts process wrong? Any suggestions will be appreciated. Thanks for your help.