LIDAR V.3 Introduction and Interfacing With Arduino

ABOUT THIS PROJECT

STORY: 

Finding the range of an object in front of your robot is a rather simple task and has been done reliably using sonar and IR range sensors for a long time. In most cases, those two types of sensors fulfill the basic needs of the robot when it comes to distance measurement. Sonar can provide good ranging on most surfaces but they have wide detection beams that can easily be interfered with. On the other hand, IR range sensors provide a confined beam that is very small but suffers from reflective differences on varying surfaces, thus changing the distance readings. Until recently, there was no good option for projects on a hobbyist budget which needed a long range, high precision, small detection beam for distance measurement.

Lidar what?

For those of you who have not heard of the LIDAR-Lite before today, we figure a quick introduction would be best. The LIDAR-Lite v3 is the third generation of a low-cost, long-range laser-based distance measurement device (also sometimes referred to as “laser range finder”). The LIDAR-Lite v3 can provide measurements at distances up to 40 meters (accuracy of +-2.5 cm) and reliably function at night, in daytime (outdoors!) and even during rain / fog (provided that you protect it appropriately from the elements, of course!). The device also comes with an extensive Arduino library that exposes most of its settings and functions with a simple to use API. Over the last year and a half, LIDAR-Lites have been used in many projects, including UAVs, autonomous rovers, and even a laser harp!

Mounting / case

With a weight of just 22 g (0.77 oz) and its compact size of only 40 x 48 x 20 mm (1.6″ x 1.9″ x 0.8″), the LIDAR-Lite v3 has kept the same form factor as its predecessors, so no need to worry there all previous projects will still be able to use this new version as a drop-in replacement for the v1/v2 when it comes to size and mounting.

Interfaces

The LIDAR-Lite v3 still offers both of its traditional interfaces, I2C and PWM output. Therefore, you should have no issues using your previous wiring schemes with your projects, either. The connector and cable did change, though, but a cable is included with the product and the other end of each individual wire is bare, which is the same as the previous model. One notable change is the addition of colors to the wiring, which makes identifying which wire is associated with the SCL, SDA, MODE, etc. much easier than before. No more of that “use the other black wire” type of thing.

lidar-lite-v3-wiring-harness-2

Electrical

In the past, we have noticed many users running their LIDAR-Lite V1 straight off a USB-powered microcontroller board, such as an Arduino Uno. When the LIDAR-Lite v2 came out, some did the same but ran into intermittent issues which were due to the inrush current requirements of the V2 during power-up which was too high for what the average USB-powered voltage regulator could provide. Whenever such a situation happened, it would cause errors during the initialization sequence of the LIDAR-Lite V2, forcing the users to restart the board/LIDAR-Lite until it finally worked. This is still the case for the V3, but there is a simple solution to this “issue” and it comes in two parts:

Part 1: Capacitor

Adding a capacitor as shown in the diagram above will ensure a smooth power supply to your LIDAR-Lite v3 and it is required for consistent / proper operation. 680 µF is the minimum appropriate value for this capacitor, though if all you have available is a slightly larger capacitor such as 1000 µF, that will be fine, too.

Part 2: External power source

While the reported running current consumption of the LIDAR-Lite V3 is ~130 mA, the inrush current during initialization is much higher (possibly ~500 mA). While this current peak is only for a short duration, if your setup is not providing enough power, it will most likely prevent the proper initialization of your LIDAR-Lite V3. For our tests, we connected a wall adapter of 7 V DC, 2 A power supply to our microcontroller board, which worked quite well. For most cases, a power source that can provide at least 6 V DC with 1 A of current should be fine.

Another good option if you need your project to be mobile or just don’t want more cables would be to use a battery pack with your microcontroller setup. The typical recommendation would usually be either a 6 V DC NiMH (ex: RB-Sta-13) or a 7.4 V DC LiPo (2S) (ex: RB-Dfr-160) battery packs.

NOTE: The LIDAR-Lite V3 requires a stable, nominal voltage of 5 V DC (4.75 – 5.5 V DC is acceptable), so make sure your external power source is passed through a quality 5V DC regulator (such as is used on the Arduino boards) before reaching the LIDAR-Lite V3 (and its capacitor ).

THINGS REQUIRED TO MAKE THIS PROJECT

Components Quantity
LIDAR V.3 1
Arduino uno 1
Connector Cable 1
Power Supply 5v 1
Capacitor 680 uf 1

SOFTWARE REQUIRED

  1. Arduino IDE

Let’s Make It!

Let’s Code!

#include

#define LIDARLite_ADDRESS 0x62 // Default I2C Address of LIDAR-Lite.
#define RegisterMeasure 0x00 // Register to write to initiate ranging.
#define MeasureValue 0x04 // Value to initiate ranging.
#define RegisterHighLowB 0x8f // Register to get both High and Low bytes in 1 call.

/******Access this part if you want to make your LIDAR V3 a self rotating autonomous device******/
/*
#include

Servo myservo;

int pos = 0; // Position of the servo (degress, [0, 180])
int distance = 0; // Distance measured
*/
void setup()
{
// Serial output
Serial.begin(9600);
Serial.println(“< START >”);

// Servo control
// myservo.attach(5);

// LIDAR control
Wire.begin(); // join i2c bus
}

// Get a measurement from the LIDAR Lite
int lidarGetRange(void)
{
int val = -1;

Wire.beginTransmission((int)LIDARLite_ADDRESS); // transmit to LIDAR-Lite
Wire.write((int)RegisterMeasure); // sets register pointer to (0x00)
Wire.write((int)MeasureValue); // sets register pointer to (0x00)
Wire.endTransmission(); // stop transmitting

delay(20); // Wait 20ms for transmit

Wire.beginTransmission((int)LIDARLite_ADDRESS); // transmit to LIDAR-Lite
Wire.write((int)RegisterHighLowB); // sets register pointer to (0x8f)
Wire.endTransmission(); // stop transmitting

delay(20); // Wait 20ms for transmit

Wire.requestFrom((int)LIDARLite_ADDRESS, 2); // request 2 bytes from LIDAR-Lite

if(2 <= Wire.available()) // if two bytes were received
{
val = Wire.read(); // receive high byte (overwrites previous reading)
val = val << 8; // shift high byte to be high 8 bits
val |= Wire.read(); // receive low byte as lower 8 bits
}

return val;
}

void serialPrintRange(int pos, int distance)
{
Serial.print(“Position (deg): “);
Serial.print(pos);
Serial.print(“\t\tDistance (cm): “);
Serial.println(distance);
}
void loo()
{

}
/*
void loop()
{
for(pos = 0; pos <= 180; pos += 1) { myservo.write(pos); distance = lidarGetRange(); serialPrintRange(pos, distance); delay(20); } for(pos = 180; pos>=0; pos-=1)
{
myservo.write(pos);
distance = lidarGetRange();
serialPrintRange(pos, distance);
delay(20);
}
}
*/

   lidar-v3

ALL FILES

Hope you liked this project!

Happy Interfacing🙂

Shubham Gupta

TECEX

Advertisements

One thought on “LIDAR V.3 Introduction and Interfacing With Arduino

  1. You’re so cool! I don’t think I’ve read through something like that before. So wonderful to find another person with original thoughts on this topic. Seriously.. thank you for starting this up. This web site is one thing that is needed on the internet, someone with a little originality!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s