garmin / LIDARLite_Arduino_Library

High-performance optical distance sensing.
Apache License 2.0
181 stars 84 forks source link

Is there a way to change sample rate for PWM code? Also code restart? #29

Open ccz359 opened 1 year ago

ccz359 commented 1 year ago

Hello @jmseitz ,

I'm using the LidarLite v3HP with an Arduino Uno. The device is wired using the PWM wiring diagram in the manual. I have installed the PWM 'get distance' code on the Arduino, and it is working great. However, I only need a 10Hz sample rate, not 400Hz for my application.

Is there a way to reduce the sample rate in the code without re-wiring the system?

I also noticed the system crashing when gently moved or bumped. My application requires the system be mounted to moving parts, is there a way to restart the Lidar periodically in the code?

Thank you!

BradWiseman commented 1 year ago

If you are using the PWM functionality, I think you can most easily reduce the rep rate by adding a software timer to the sample code. That would reduce the rep rate without requiring any changes to the wiring.

It's unclear to me why bumping the system would cause a crash. Are you sure your connections are not intermittent in a way that would interrupt them when the system is bumped? There is no soft reset available on the LIDAR-Lite v3HP, but you could cycle the power enable pin if you need to externally apply a signal to reset the device.