SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By tapsoc
#197934
I am currently working on a project for a class that involves distance measurement between parked cars. Recently, I purchased a Lidar-Lite V3 sensor from Sparkfun to use for measuring this distance. I followed the hookup guide linked below for the sensor's setup. After setting up the sensor as depicted on the hookup guide (over I2C) and installing the Lidar-Lite V3 Arduino library, I ran tests to see if the distance measurements were accurate. The serial monitor, though, printed distance values about 10 cm off at lower ranges (0 cm - 50 cm) and varying differences in distance from the actual distance for 50+cm values. The product will likely never need to reach beyond 4m, so around the +/- 2.5 cm resolution at this range listed on Garmin's website is what I would like to achieve. I have attempted to work with HC-SR04 ultrasonic sensors and Sharp IR sensors, but both also had fairly similar problems with inaccurate measurement. Am I doing something wrong, or are all sensors in this price range this inaccurate? Are there modifications I could make to the code to create more accurate results? I am looking into calling Sparkfun support on the issue soon, too. I'm fairly new to sensors, Arduino, etc., so any help with getting accurate distance measurements would be appreciated :D

tl;dr: I'm having trouble getting the Lidar-Lite V3 to print accurate distance values below 5m. Am I doing something wrong, or are distance sensors at this price range always inaccurate by +/- 10cm?

https://learn.sparkfun.com/tutorials/li ... okup-guide

Here's the code I'm currently using with my sensor from the hookup guide
Code: Select all
/**
 * LIDARLite I2C Example
 * Author: Garmin
 * Modified by: Shawn Hymel (SparkFun Electronics)
 * Date: June 29, 2017
 * 
 * Read distance from LIDAR-Lite v3 over I2C
 * 
 * See the Operation Manual for wiring diagrams and more information:
 * http://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf
 */

#include <Wire.h>
#include <LIDARLite.h>

// Globals
LIDARLite lidarLite;
int cal_cnt = 0;

void setup()
{
  Serial.begin(9600); // Initialize serial connection to display distance readings

  lidarLite.begin(0, true); // Set configuration to default and I2C to 400 kHz
  lidarLite.configure(0); // Change this number to try out alternate configurations
}

void loop()
{
  int dist;

  // At the beginning of every 100 readings,
  // take a measurement with receiver bias correction
  if ( cal_cnt == 0 ) {
    dist = lidarLite.distance();      // With bias correction
  } else {
    dist = lidarLite.distance(false); // Without bias correction
  }

  // Increment reading counter
  cal_cnt++;
  cal_cnt = cal_cnt % 100;

  // Display distance
  Serial.print(dist);
  Serial.println(" cm");

  delay(10);
}
By paulvha
#197946
interesting device and project. It looks to me that the reader can be tuned to provide better accuracy and the driver has some options.
Have you tried the other settings for configure and did that provide better results ?:
0: Default mode, balanced performance.
1: Short range, high speed. Uses 0x1d maximum acquisition count.
2: Default range, higher speed short range. Turns on quick termination
detection for faster measurements at short range (with decreased
accuracy)
3: Maximum range. Uses 0xff maximum acquisition count.
4: High sensitivity detection. Overrides default valid measurement detection
algorithm, and uses a threshold value for high sensitivity and noise.
5: Low sensitivity detection. Overrides default valid measurement detection
algorithm, and uses a threshold value for low sensitivity and noise.
By tapsoc
#197948
paulvha wrote: Thu Jan 18, 2018 5:00 am Have you tried the other settings for configure and did that provide better results ?
Thanks for the recommendation, but I have experimented with those values as well. I can run more tests, but my previous attempts still resulted in +/- 10cm accuracy on all settings. If I want to change into a different mode, would I change both of the zeroes in these two lines of code?

lidarLite.begin(0, true);
lidarLite.configure(0);

For example, if I wanted a shorter range, would I change it to the code below? Just want to make sure I'm changing the settings correctly. Thanks.

lidarLite.begin(1, true);
lidarLite.configure(1);
By paulvha
#197949
if you set idarLite.begin(1, true); you can ommit lidarLite.configure(1); it is double up.

In loop() you could try to call lidarLite.configure(x); where x= a value 0 to 5 and see whether you find a difference in measurement out come.