Giter Site home page Giter Site logo

lidarlite_arduino_library's Introduction

LIDAR-Lite Arduino Library

This library provides quick access to basic functions of LIDAR-Lite via the Arduino interface. Additionally, it can provide a user of any platform with a template for their own application code.

For detailed specifications, pinout, and connection diagrams, see the manuals linked at the above product pages.

A Note on Compatibility: Minor interface changes have occurred between LIDAR-Lite v3, v3HP, and previous versions. Backwards-compatibility of this library is largely preserved, though support is not directly provided for v1 and v2.

Installation instructions

To install, download this repository and place in your Arduino libraries folder or use the Arduino Library Manager. If you need help, follow the instructions here: http://arduino.cc/en/Guide/Libraries.

Example Sketches

v3/GetDistancePWM

This is the simplest demonstration of LIDAR-Lite. It shows how to read a distance using the PWM interface.

v3/GetDistanceI2c

This demonstration shows how to read distance using the I2C interface and choose preset configurations.

v3/ShortRangeHighSpeed

This example shows a method to run LIDAR-Lite at high speed for short range applications. It combines a variety of settings to trade off range and accuracy for very fast measurements.

v3HP/v3HP_I2C

This example shows various methods to run LIDAR-Lite v3HP.

v3HP/v3HP_MONITOR

Use the MODE pin to monitor STATUS of the LIDAR-Lite v3HP.

v3HP/v3HP_PWM

Use PWM output to read distances from LIDAR-Lite v3HP.

v4LED/v4LED

Various operation examples for LIDAR-Lite v4 LED.

v4LED/v4LED_fast

High rep rate example using the optional GPIO pins or I2C port to trigger measurements.

v4LED/v4LED_lowpower

Take single distance measurements using the I2C port in a lower power state.

Version History

  • 3.0.6 - Copy alt requestFrom() to LLv4LED library
  • 3.0.5 - v3HP library updated for alternate requestFrom()
  • 3.0.4 - v4 LED and v3HP library updates. New v3HP PWM example.
  • 3.0.3 - Add v3HP library function to read peak stack
  • 3.0.2 - Add v4 LED examples and link to ANT Library
  • 3.0.1 - v4 LED example clean up and library fixes
  • 3.0.0 - Support for LIDAR-Lite v4 LED
  • 2.0.6 - Add v3HP library function to reset the reference filter
  • 2.0.5 - Add v3 library function to set alternate I2C addr
  • 2.0.4 - Update short-range, high-error configuration
  • 2.0.3 - New example using MODE pin for STATUS output of v3HP
  • 2.0.2 - Updates to v3HP library
  • 2.0.0 - Support for LIDAR-Lite v3HP
  • 1.0.3 - Fix version convention
  • 1.0.2 - Library Manager Update
  • 1.0.1 - Release to Library Manager
  • 1.0.0 - Initial release

Raspberry Pi Library for LIDAR-Lite v3

ANT Library for LIDAR-Lite v4 LED

License

Copyright (c) 2018 Garmin Ltd. or its subsidiaries. Distributed under the Apache 2.0 License. See LICENSE for further details.

lidarlite_arduino_library's People

Contributors

jmseitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lidarlite_arduino_library's Issues

LIDAR-Lite v3HP second peak data?

I want to move Arduino code from the v3 to the v3HP. On the v3 I have been using the 0x4c register PEAK_BCK to get the second peak data but this register is not listed as available for the v3HP. Are the 0x26 and 0x27 peak stack registers the v3HP’s equivalent and how would one interpret the data?
My interest is in identifying reflection / penetration of glass surfaces. If you can suggest data registers available on the v3HP to aid in this please let me know.

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

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!

LIDARLite v4 LED Library - max measurement 255cm

I am new to Arduino programming and playing around with a Sparkfun Redboard Artemis nano connected to a LIDARLite v4 LED via the Qwiik connector. When running the GetDistance example I noticed I could not obtain a measurement over 255cm. It would jump back to low measurments like 1cm. I noticed the in the library that the getDistance function was only declared as uint8_t (8bit). Thus the reason for the max value of 255. I changed the getDistance funtion declaration to unit16_t in both the LIDARLite_v4LED.h and the .cpp library files and now I am able to get measurements over 255cm.
Attached are the updated files.
LIDARLite_v4LED.zip

Cant compile on Arduino Uno wifi rev 2

Hello,

I am following the example shown on this page https://learn.sparkfun.com/tutorials/lidar-lite-v3-hookup-guide/all and I placed the cloned repository under my user's arduino library directory which is /Users/jung/Documents/Arduino/libraries

jung@MacOS-[/Users/jung/Documents/Arduino/libraries]:~$ ls
LIDARLite_Arduino_Library-master readme.txt

I have a Arduino Uno wifi rev 2 and a LIDAR Lite v3 and when I tried to compile the code I get this error message below. Please help!

Here is the complete code:

/**
 * 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);
}

and here is the log

/Users/jung/Documents/Arduino/libraries/LIDARLite_Arduino_Library-master/src/LIDARLite_v4LED.cpp: In member function 'void LIDARLite_v4LED::read(uint8_t, uint8_t*, uint8_t, uint8_t)':
/Users/jung/Documents/Arduino/libraries/LIDARLite_Arduino_Library-master/src/LIDARLite_v4LED.cpp:426:5: error: no matching function for call to 'TwoWire::requestFrom(uint8_t&, uint8_t&, uint8_t&, int, bool)'
     );
     ^
In file included from /Users/jung/Documents/Arduino/libraries/LIDARLite_Arduino_Library-master/src/LIDARLite_v4LED.cpp:27:0:
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:61:12: note: candidate: virtual size_t TwoWire::requestFrom(uint8_t, size_t)
     size_t requestFrom(uint8_t, size_t);
            ^~~~~~~~~~~
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:61:12: note:   candidate expects 2 arguments, 5 provided
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:62:12: note: candidate: virtual size_t TwoWire::requestFrom(uint8_t, size_t, bool)
     size_t requestFrom(uint8_t, size_t, bool);
            ^~~~~~~~~~~
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:62:12: note:   candidate expects 3 arguments, 5 provided
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:63:12: note: candidate: size_t TwoWire::requestFrom(int, int)
     size_t requestFrom(int, int);
            ^~~~~~~~~~~
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:63:12: note:   candidate expects 2 arguments, 5 provided
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:64:12: note: candidate: size_t TwoWire::requestFrom(int, int, int)
     size_t requestFrom(int, int, int);
            ^~~~~~~~~~~
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:64:12: note:   candidate expects 3 arguments, 5 provided
/Users/jung/Documents/Arduino/libraries/LIDARLite_Arduino_Library-master/src/LIDARLite_v3HP.cpp: In member function 'void LIDARLite_v3HP::read(uint8_t, uint8_t*, uint8_t, uint8_t)':
/Users/jung/Documents/Arduino/libraries/LIDARLite_Arduino_Library-master/src/LIDARLite_v3HP.cpp:455:5: error: no matching function for call to 'TwoWire::requestFrom(uint8_t&, uint8_t&, uint8_t&, int, bool)'
     );
     ^
In file included from /Users/jung/Documents/Arduino/libraries/LIDARLite_Arduino_Library-master/src/LIDARLite_v3HP.cpp:27:0:
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:61:12: note: candidate: virtual size_t TwoWire::requestFrom(uint8_t, size_t)
     size_t requestFrom(uint8_t, size_t);
            ^~~~~~~~~~~
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:61:12: note:   candidate expects 2 arguments, 5 provided
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:62:12: note: candidate: virtual size_t TwoWire::requestFrom(uint8_t, size_t, bool)
     size_t requestFrom(uint8_t, size_t, bool);
            ^~~~~~~~~~~
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:62:12: note:   candidate expects 3 arguments, 5 provided
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:63:12: note: candidate: size_t TwoWire::requestFrom(int, int)
     size_t requestFrom(int, int);
            ^~~~~~~~~~~
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:63:12: note:   candidate expects 2 arguments, 5 provided
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:64:12: note: candidate: size_t TwoWire::requestFrom(int, int, int)
     size_t requestFrom(int, int, int);
            ^~~~~~~~~~~
/Users/jung/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7/libraries/Wire/src/Wire.h:64:12: note:   candidate expects 3 arguments, 5 provided
exit status 1
Error compiling for board Arduino Uno WiFi Rev2.

Status output mode?

Is it possible use status output mode and I2C at the same time?

I write 0b01 to the first two bits of ACQ_CONFIG_REG.

Then I write 0x03 to ACQ_COMMAND.

After that I create an interrupt for falling edge on the control mode pin.

However, the control mode pin never goes LOW. Even if I trigger it using I2C.

LIDAR-Lite v3HP - NACK attack on Arduino Due

I have tested LiDAR 3HP on both Arduino UNO and Due microcontroller board with I2C connection. It seems like the Due microcontroller is always encountered by NACK attack comparing to UNO board and I found the value of nackCatcher is 2 returning from endTransmission(). I suspect that the Due board clock speed affects the performance on LiDAR 3HP which I added delayMicroseconds() command after each write() and read() function in LIDARLite_v3HP.cpp to ensure that master and slave device have sufficient time to acknowledge. After several trying, it still remains unsolved.

How to detect intensity of a measurement from lidar lite

I have a project using the lidar lite as a scanner and i want to be able to detect a reflective target i set up. I was wondering if there were any commands or functions i could use to determine the intensity of a measurement.

The end goal is to be able to perform a scan with 3 stationary reflective targets, setup at a different position, scan again near those targets, and be able to stitch these scans together with a 3D transformation using a survey technique called a resection

any help would be greatly appreciated

Too many blocking code:(

Hello,

Very good spec sensor but the lib is useless for serious application.
There is too many blocking code inside it :

while(busyFlag != 0) // Loop until device is not busy
{
... update busyFlag ...
}

delay(1); // 1 ms delay for robustness with successive reads and writes

You can't do this on a microcontroller 1ms is a huge waste like many years lol.

My project need a serious non blocking code, I must rewrite this unusable lib :(

Pascal

LIDAR-LITE V3HP distance measurement results unclear....

Dear all,
We are interfacing the Garmin LIDAR-LITE V3HP with our hardware and using the datasheet to send the i2C commands to make a distance measurements. We use ATmega1284p AVR as Host MCU.

It seems that what we receive is garbage, and/or not correct measurement data. Below is the i2C session which we initiate with device. Any information regarding the i2C transaction and its commands being sent to achieve the correct data will be highly appreciated....
David

      uint8_t receiver_reply;
      i2cStart(); // start a i2C session
      i2cSend(0xC4); // LIDAR address with write bit
      receiver_reply = TWSR; // MCU register with session codes, to checkup on errors....
      receiver_reply = receiver_reply & 0b11111000;

      printBinaryByte(receiver_reply);
      printString("\r\n");

      if(receiver_reply == 0x18){  // if Ack receieved from LIDAR
            printString("\r\n issuing start condition ok, device accessible\r\n");
            i2cSend(0x00); // send the register address
            receiver_reply = TWSR; // again checkup on Ack and errors.....
            receiver_reply = receiver_reply & 0b11111000;
            printBinaryByte(receiver_reply);
            printString("\r\n");
            if(receiver_reply == 0x28){
                    printString("\r\n register 0x00 address sent >> ok\r\n");
                    i2cSend(0x04); // writing 0x04 to register 0x00 to start a distance measurement
                    receiver_reply = TWSR; // again checkup on Ack and errors.....
                    receiver_reply = receiver_reply & 0b11111000;
                    printBinaryByte(receiver_reply);
                    printString("\r\n");
   
                    i2cStop();
                    if(receiver_reply == 0x28){ // again checkup on Ack and errors.....
                            printString("\r\n wrote 0x04 to register 0x00\r\n");
                            i2cStart();
                            i2cSend(0xC5); // put LIDAR in Read mode
                            receiver_reply = TWSR; // again checkup on Ack and errors.....
                            receiver_reply = receiver_reply & 0b11111000;
                            printBinaryByte(receiver_reply);
                            printString("\r\n");
                
                            if(receiver_reply == 0x40){
                                i2cSend(0x01);
                                 for(int i = 0; i < 100; i ++){
                                     uint8_t lidar_busy_flag = i2cReadAck();
                                     printBinaryByte(lidar_busy_flag);
                                     printString("\r\n");
                                     if((lidar_busy_flag & 0b00000001) == 0x00){
                                          i2cSend(0x0f); // send address of highbyte 
                                          receiver_reply = TWSR;
                                          receiver_reply = receiver_reply & 0b11111000; 
                                          printBinaryByte(receiver_reply);
                                         uint8_t distance_high = i2cReadAck(); // read highbyte 
                                          i2cSend(0x01); // send address of lowbyte
                                         uint8_t distance_low = i2cReadNoAck(); // read lowbyte
                                        uint16_t range = distance_high << 8;
                                        range = range | distance_low;
                                        printWord(range);
                                        printString("\r\n");
                                     }
                                     else{
                                        printString("busy flag!");
                                        printBinaryByte(lidar_busy_flag);
                                        printString("\r\n");
                                   }
                                   }

Add the acquisition frequency depending on the mode.

Dear,

Here are the results of my benchmark (for one laser), so people can see what configuration fits the user needs.

The test is done with :

  • maximal frequency
  • nominal distance of 2 meters
  • 1000 measures.
  • Error are measures outside [150,250]
  • One laser (v2)

Results :

Configuration -1 distanceFast(true) : 559.69Hz, errors : 36 on 1000 measurements
Configuration -1 distanceFast(false) : 1048.50Hz, errors : 40 on 1000 measurements
Configuration 0 distance(true) : 258.22Hz, errors : 0 on 1000 measurements
Configuration 0 distance(false) : 321.70Hz, errors : 0 on 1000 measurements
Configuration 1 distance(true) : 371.17Hz, errors : 0 on 1000 measurements
Configuration 1 distance(false) : 506.87Hz, errors : 0 on 1000 measurements
Configuration 2 distance(true) : 473.07Hz, errors : 0 on 1000 measurements
Configuration 2 distance(false) : 669.00Hz, errors : 0 on 1000 measurements
Configuration 3 distance(true) : 257.01Hz, errors : 0 on 1000 measurements
Configuration 3 distance(false) : 322.77Hz, errors : 0 on 1000 measurements
Configuration 4 distance(true) : 256.93Hz, errors : 0 on 1000 measurements
Configuration 4 distance(false) : 323.17Hz, errors : 0 on 1000 measurements
Configuration 5 distance(true) : 256.37Hz, errors : 0 on 1000 measurements
Configuration 5 distance(false) : 323.01Hz, errors : 0 on 1000 measurements

Code :

/*------------------------------------------------------------------------------

  LIDARLite v2 library (from Garmin) benchmark

  This script test the performance of the lasers depending on the 
configurations 
------------------------------------------------------------------------------*/

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

LIDARLite myLidarLite;

long now, last;
int errors = 0;

#define N_MEASURE_PROFILE 1000.0

void setup()
{
  Serial.begin(115200); 
  myLidarLite.begin(0, true); // Set configuration to default and I2C to 400 kHz
}

void loop()
{
  /* distanceFast Config */ 
  myLidarLite.write(0x02, 0x0d); // Maximum acquisition count of 0x0d. (default is 0x80)
  myLidarLite.write(0x04, 0b00000100); // Use non-default reference acquisition count
  myLidarLite.write(0x12, 0x03); // Reference acquisition count of 3 (default is 5)
  
  last = micros();
  for(int i = 0; i < N_MEASURE_PROFILE; i++)
  {
    isError(distanceFast(true));
  }
  now = micros();
  Serial.print("Configuration ");
  Serial.print("-1");
  Serial.print(" distanceFast(true) : ");
  Serial.print(N_MEASURE_PROFILE*1000000.0/double(now-last));
  Serial.print("Hz, errors : ");
  Serial.print(errors);
  Serial.println(" on 1000 measurements");
  errors = 0;
  
  
  last = micros();
  for(int i = 0; i < N_MEASURE_PROFILE; i++)
  {
    isError(distanceFast(false));
  }
  now = micros();
  Serial.print("Configuration ");
  Serial.print("-1");
  Serial.print(" distanceFast(false) : ");
  Serial.print(N_MEASURE_PROFILE*1000000.0/double(now-last));
  Serial.print("Hz, errors : ");
  Serial.print(errors);
  Serial.println(" on 1000 measurements");
  errors = 0;

  for(int conf = 0; conf < 6; conf++){
    myLidarLite.configure(conf); 
    last = micros();
    for(int i = 0; i < N_MEASURE_PROFILE; i++)
    {
      isError(myLidarLite.distance(true));
    }
    now = micros();
    Serial.print("Configuration ");
    Serial.print(conf);
    Serial.print(" distance(true) : ");
    Serial.print(N_MEASURE_PROFILE*1000000.0/double(now-last));
    Serial.print("Hz, errors : ");
    Serial.print(errors);
    Serial.println(" on 1000 measurements");
    errors = 0;
    
    
    last = micros();
    for(int i = 0; i < N_MEASURE_PROFILE; i++)
    {
      isError(myLidarLite.distance(false));
    }
    now = micros();
    Serial.print("Configuration ");
    Serial.print(conf);
    Serial.print(" distance(false) : ");
    Serial.print(N_MEASURE_PROFILE*1000000.0/double(now-last));
    Serial.print("Hz, errors : ");
    Serial.print(errors);
    Serial.println(" on 1000 measurements");
    errors = 0;
  }
}

// Read distance. The approach is to poll the status register until the device goes
// idle after finishing a measurement, send a new measurement command, then read the
// previous distance data while it is performing the new command.
int distanceFast(bool biasCorrection)
{
  byte isBusy = 1;
  int distance;
  int loopCount;

  // Poll busy bit in status register until device is idle
  while(isBusy)
  {
    // Read status register
    Wire.beginTransmission(LIDARLITE_ADDR_DEFAULT);
    Wire.write(0x01);
    Wire.endTransmission();
    Wire.requestFrom(LIDARLITE_ADDR_DEFAULT, 1);
    isBusy = Wire.read();
    isBusy = bitRead(isBusy,0); // Take LSB of status register, busy bit

    loopCount++; // Increment loop counter
    // Stop status register polling if stuck in loop
    if(loopCount > 9999)
    {
      break;
    }
  }

  // Send measurement command
  Wire.beginTransmission(LIDARLITE_ADDR_DEFAULT);
  Wire.write(0X00); // Prepare write to register 0x00
  if(biasCorrection == true)
  {
    Wire.write(0X04); // Perform measurement with receiver bias correction
  }
  else
  {
    Wire.write(0X03); // Perform measurement without receiver bias correction
  }
  Wire.endTransmission();

  // Immediately read previous distance measurement data. This is valid until the next measurement finishes.
  // The I2C transaction finishes before new distance measurement data is acquired.
  // Prepare 2 byte read from registers 0x0f and 0x10
  Wire.beginTransmission(LIDARLITE_ADDR_DEFAULT);
  Wire.write(0x8f);
  Wire.endTransmission();

  // Perform the read and repack the 2 bytes into 16-bit word
  Wire.requestFrom(LIDARLITE_ADDR_DEFAULT, 2);
  distance = Wire.read();
  distance <<= 8;
  distance |= Wire.read();

  // Return the measured distance
  return distance;
}

void isError(int data){
  if(data > 250) {
    errors++;
  } else if(data < 150){
    errors++;
  }
}

Configure function at the time of the writing :

void LIDARLite::configure(int configuration, char lidarliteAddress)
{
  switch (configuration)
  {
    case 0: // Default mode, balanced performance
      write(0x02,0x80,lidarliteAddress); // Default
      write(0x04,0x08,lidarliteAddress); // Default
      write(0x1c,0x00,lidarliteAddress); // Default
    break;

    case 1: // Short range, high speed
      write(0x02,0x1d,lidarliteAddress);
      write(0x04,0x08,lidarliteAddress); // Default
      write(0x1c,0x00,lidarliteAddress); // Default
    break;

    case 2: // Default range, higher speed short range
      write(0x02,0x80,lidarliteAddress); // Default
      write(0x04,0x00,lidarliteAddress);
      write(0x1c,0x00,lidarliteAddress); // Default
    break;

    case 3: // Maximum range
      write(0x02,0xff,lidarliteAddress);
      write(0x04,0x08,lidarliteAddress); // Default
      write(0x1c,0x00,lidarliteAddress); // Default
    break;

    case 4: // High sensitivity detection, high erroneous measurements
      write(0x02,0x80,lidarliteAddress); // Default
      write(0x04,0x08,lidarliteAddress); // Default
      write(0x1c,0x80,lidarliteAddress);
    break;

    case 5: // Low sensitivity detection, low erroneous measurements
      write(0x02,0x80,lidarliteAddress); // Default
      write(0x04,0x08,lidarliteAddress); // Default
      write(0x1c,0xb0,lidarliteAddress);
    break;
  }
} /* LIDARLite::configure */

LIDARLite_v3HP_read uses Repeated Start but datasheet says its not supported

Hi.
I just realized that the Library for the v3HP uses the Repeated Start Condition in LIDARLite_v3HP_read Function in /src/LIDARLite_v3HP.cpp on Line 398:
nackCatcher = Wire.endTransmission(false); // false means perform repeated start

Compleete function:

void LIDARLite_v3HP::read(uint8_t regAddr, uint8_t * dataBytes,
                          uint16_t numBytes, uint8_t lidarliteAddress)
{
    uint16_t i = 0;
    int nackCatcher = 0;

    // Set the internal register address pointer in the Lidar Lite
    Wire.beginTransmission((int) lidarliteAddress);
    Wire.write((int) regAddr); // Set the register to be read

    // A nack means the device is not responding, report the error over serial
    nackCatcher = Wire.endTransmission(false); // false means perform repeated start
    if (nackCatcher != 0)
    {
        Serial.println("> nack");
    }

    // Perform read, save in dataBytes array
    Wire.requestFrom((int)lidarliteAddress, (int) numBytes);
    if ((int) numBytes <= Wire.available())
    {
        while (i < numBytes)
        {
            dataBytes[i] = (uint8_t) Wire.read();
            i++;
        }
    }

} /* LIDARLite_v3HP::read */

In the Datasheet on Page 6 it says:

Notes:
• This device does not work with repeated START conditions. It must first receive a STOP condition before a new START condition.
• The ACK and NACK items are responses from the master device to the slave device.
• The last NACK in the read is technically optional, but the formal I2C protocol states that the master shall not acknowledge the last byte.

It seems to work. But i implemented it into an other microcontroller and we ran into some I2C stucks when having higher EMI Problems. By digging into the code we found this issue...

Updating LIDAR-Lite v4 LED firmware.

It is described in the product manual that there is a way to update the firmware of the LIDAR-Lite v4 via Bluetooth, and if I am reading it correctly, that the zipped files (DFU.zip) for this update are supposed to be located in this github-rep. I am however unable to find any such files here, so I was just wondering where to look for a more up to date firmware, if there are any such files? Or in case I already possess the latest firmware update, where to find such in the future? I have been searching via Google, but to no avail. Thanks.

No matching function LIDARLite_v4LED

I tired to use all of the examples LIDARLite -> v4LED folders, and all of them have some form of the error message: "no macthing function for cal to 'LIDARLite_v4LED::write(Int, uint8_t*, int, int)'. Someone in the Arduino forum pointed out that the int parameters don't match.

Repeated read distance write repeated acquire

In the v3, by setting register 0x11 (OUTER_LOOP_COUNT) to 0xFF, registers 0x0F and 0x10 could be read on demand to get the latest distance. This is not supported in the v3HP as far as I can see. While this might not matter in a firmware device (i.e. Arduino), this is a significant problem for an O/S like a Raspberry Pi Linux. Is there a way to get the latest on-demand distance value without the write acquire, read status, read distance?

I2C address change?

Is it possible to hange the i2c address of the lidar? I dont see any functions to do this in the library?

Lidar Lite v3 not working

Hi,

I received a brand new Lidar-Lite v3 (2019/05) yesterday.
Hooked up to Arduino Leonardo by specification shown in thos document
http://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf
Green to Arduino SCL pin, blue to SDA pin. The whole setup gets power from external 5V BEC with 680 uF capacitor in parallel.

I tried with example code in this library, but all that I get is nack in the serial terminal.

Is there anything special that I have to do besides that, or any guidelines on how to debug this issue further?

--
BR,
Kpihus

LidarLite V4 LED - Signal Quality I2C

On the V3 and V3 HP versions you can read 0x0c, 0x0d and 0x0e over i2c to compute signal strength and detect invalid measurements.

However, when the V4 LED is near its maximum range it just returns garbage without any indication that the signal is terrible. Is there a way to capture signal quality or detect failure on the V4?

LIDAR LITE V4 - Connecting Wirelessly Using ANT

Hello,

I would like to test-develop on the Lidar Lite V4 ANT interface.

According to Manual:
....For more details about the ANT ranging profile and the
capabilities and workings of the ANT wireless protocol, see ANT
Ranging Profile and ANT Message Protocol and Usage at
https://github.com/garmin/.

Connecting Wirelessly Using ANT
1 Connect the USB ANT stick to your computer.
2 Download and install the Garmin ANT demo PC application
on your computer (https://github.com/garmin/) .
3 Configure and connect the PC application to the LIDAR-Lite
v4 LED device as specified in the readme file that is included
with the Garmin ANT demo PC application.

Questions:
Where is located the ANT repository in github ?

Can I work with this ?
https://www.thisisant.com/developer/ant/starting-your-project

Or this ?
https://github.com/corbamico/ANT-Library

Regards

Arduino IDE ver. 18 and LidarLite V3 Library (version 1.02)

I downloaded the Garmin Arduino Library LIDARLite_v3_Arduino_Library-1.0.2.zip.

I added it via Add ZIP Library command.

Then I get the errors listed below:

Invalid version found: v1.0.2

Also
Library Manager states that installed library is verion 1.0.0

Also the library manager "More Info" link does not allow any Version Install xxxxxx option.
The "More Info " link just takes you to the garmin store and offers to sell the Lidar Lite V 3 hardware.
I plan on purchasing the Lidar Lite V3 but want to make sure the library updates are correct.

Thanks for your help in advance.
K Smith

image

Cannot compile for Pi Pico

Attempting to use the Lidar V3HP with the RP2040. It does not compile for multiple boards, with the following errors:

c:\Users\vavourak\Documents\Arduino\libraries\LIDAR-Lite\src\LIDARLite_v3HP.cpp: In member function 'void LIDARLite_v3HP::read(uint8_t, uint8_t*, uint8_t, uint8_t)':
c:\Users\vavourak\Documents\Arduino\libraries\LIDAR-Lite\src\LIDARLite_v3HP.cpp:455:5: error: no matching function for call to 'TwoWire::requestFrom(uint8_t&, uint8_t&, uint8_t&, int, bool)'
  455 |     );
      |     ^
In file included from c:\Users\vavourak\Documents\Arduino\libraries\LIDAR-Lite\src\LIDARLite_v3HP.cpp:27:
C:\Users\vavourak\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\2.7.1\libraries\Wire\src/Wire.h:58:12: note: candidate: 'virtual size_t TwoWire::requestFrom(uint8_t, size_t, bool)'
   58 |     size_t requestFrom(uint8_t address, size_t quantity, bool stopBit) override;
      |            ^~~~~~~~~~~
C:\Users\vavourak\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\2.7.1\libraries\Wire\src/Wire.h:58:12: note:   candidate expects 3 arguments, 5 provided
C:\Users\vavourak\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\2.7.1\libraries\Wire\src/Wire.h:59:12: note: candidate: 'virtual size_t TwoWire::requestFrom(uint8_t, size_t)'
   59 |     size_t requestFrom(uint8_t address, size_t quantity) override;
      |            ^~~~~~~~~~~
C:\Users\vavourak\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\2.7.1\libraries\Wire\src/Wire.h:59:12: note:   candidate expects 2 arguments, 5 provided
c:\Users\vavourak\Documents\Arduino\libraries\LIDAR-Lite\src\LIDARLite_v4LED.cpp: In member function 'void LIDARLite_v4LED::read(uint8_t, uint8_t*, uint8_t, uint8_t)':
c:\Users\vavourak\Documents\Arduino\libraries\LIDAR-Lite\src\LIDARLite_v4LED.cpp:426:5: error: no matching function for call to 'TwoWire::requestFrom(uint8_t&, uint8_t&, uint8_t&, int, bool)'
  426 |     );
      |     ^
In file included from c:\Users\vavourak\Documents\Arduino\libraries\LIDAR-Lite\src\LIDARLite_v4LED.cpp:27:
C:\Users\vavourak\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\2.7.1\libraries\Wire\src/Wire.h:58:12: note: candidate: 'virtual size_t TwoWire::requestFrom(uint8_t, size_t, bool)'
   58 |     size_t requestFrom(uint8_t address, size_t quantity, bool stopBit) override;
      |            ^~~~~~~~~~~
C:\Users\vavourak\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\2.7.1\libraries\Wire\src/Wire.h:58:12: note:   candidate expects 3 arguments, 5 provided
C:\Users\vavourak\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\2.7.1\libraries\Wire\src/Wire.h:59:12: note: candidate: 'virtual size_t TwoWire::requestFrom(uint8_t, size_t)'
   59 |     size_t requestFrom(uint8_t address, size_t quantity) override;
      |            ^~~~~~~~~~~
C:\Users\vavourak\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\2.7.1\libraries\Wire\src/Wire.h:59:12: note:   candidate expects 2 arguments, 5 provided

exit status 1

Compilation error: exit status 1

Is there anyway to fix this? Thanks!

lidar lite v3 API cause interrupt function wrong

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:

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

LIDARLite myLidarLite;

volatile bool encoder_flag = false;
volatile unsigned long Time = 0;
volatile int Duration = 0;
volatile unsigned long LastTime = 0; 

void encoderTick(){
  encoder_flag = true;
}

void setup() {
  pinMode(3, INPUT);//monitor optical sensor read

  attachInterrupt(digitalPinToInterrupt(3), encoderTick, CHANGE);

  Serial.begin(115200);
  myLidarLite.begin(0,true);  
  myLidarLite.configure(0);
}

void loop() {

  if(encoder_flag){
    encoder_flag =false;
    
    /****record this encoder time****/
    Time = millis();
    Duration = Time-LastTime;
    LastTime = Time;
     
    Serial.println(Duration);  
  }

  //int d =myLidarLite.distance();
  
}

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:

7
8
7
7
6
8
6
9
6
8
6
8
6
9
6
8
6
8
8
7
7
7
7
7
8
7
7
7
3
11
Then I add int d =myLidarLite.distance(), the durations become ruleless and even not periodic. like this:

8
4
13
9
4
6
8
8
7
9
7
7
10
3
7
12
7
8
9
3
7
10
5
3
7
8
5
9
4
12

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.

Possible to read Control Registers in PWM mode?

We're using the Lidar Lite v3 HP configured in PWM to an Arduino Uno and would like to be able to read the control registers, for example, Health Status in the serial monitor. Is this possible? Looking through the Operations Manual and Tech specs isn't clear if the registers can only be used in I2C mode. Thank you in advance for your help with this!

library not compatible with SAMD21 M0 boards

Looks like this library won't compile for SAMD21 M0 boards. Attempted to compile for:

IDE 1.8.11

  • nano 33 IoT
  • MKR Wifi 1010
  • Adafruit Feather M0 Express

Changed to previous board versions back to 1.8.6.

Also failed to compile on 1.8.13 (portable)

The library successfully compiled for nano 33 BLE.

I see that this is coded for a Due which is a more powerful processor. So issue closed.

LIDAR Lite V3 HP with ESP32

Currently it seems that the ESP32 wire library doesn support the 5 params requestFrom() command. So as it is now, your library isn't compatible with ESP32. I have modified your read() function to be compatible on the ESP32, i am unshure it is the best way to do it, but it is working on my setup.!

`void LIDARLite_v3HP::read(uint8_t regAddr, uint8_t * dataBytes,
uint8_t numBytes, uint8_t lidarliteAddress)
{
// This single function performs the following actions -
// 1) I2C START
// 2) I2C write to set the address
// 3) I2C REPEATED START
// 4) I2C read to fetch the required data
// 5) I2C STOP
Wire.beginTransmission(lidarliteAddress);
Wire.write(regAddr);
if(!Wire.endTransmission()){
Wire.requestFrom
(
lidarliteAddress, // Slave address
numBytes, // number of consecutive bytes to read
//regAddr, // address of first register to read
//1, // number of bytes in regAddr
true // true = set STOP condition following I2C read
);

	uint8_t  numHere = Wire.available();
	uint8_t  i       = 0;
	while (i < numHere)
	{
		dataBytes[i] = Wire.read();
		i++;
	}
	delayMicroseconds(100); // 100 us delay for robustness with successive reads and writes
}else{
	Serial.println("> nack");
}

} /* LIDARLite_v3HP::read */`

Multi LIDARLite_v3 possible?

Hi, my project requires 3 distance sensors, I find LIDARLite_v2 has the changeAddressMultiPwrEn function for multi Lidar sensors in the library, I wonder if the LIDARLite_v3 can use that function or there is other way to read multi Lidar's value.

Overview of differences between LIDAR Lite v3 and LIDAR Lite v3HP?

I wanted to adapt a (Python) library for LIDAR Lite V3 to LIDAR Lite V3HP.
My new v3HP does not work with the (Python) lib for the v3, that I have available, so I want to change it.
The Problem is, that I have not seen any differences at my first look at the operation manual, but because the v3 lib does not work, obviously there have to be some.

Is there a list of the differences, so that I can go through my sources and include the changes?

How to increase speed of Lidar v3HP

wiht mode 3 it's speed is 250 HZ, but also with mode 2 the speed is 500Hz
But since i have the HP model i'm supposed also to get higher speed like 1000Hz
I tryed to understand the library and also looked the manual but wasn't succesfull.
Could you please help me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.