Skip to content

LIDAR Lite v3

amhsrobotics4681 edited this page Feb 19, 2019 · 9 revisions

The specification manual for this hardware is:
http://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf
See p. 4 "Mode Control Pin" section for background on explaining the code and modified wiring. Pay close attention to the 10 µs per cm and termination resistance paragraph in the pdf. This will help you understand getPeriod() and the wiring shown below, respectively.
Ignore the wiring diagrams on p.3 unless you know what you're doing.
The wire colors and functions on p.2 are relevant, but unnecessary for understanding the sensor.

The electrical pinout specification for the NI roboRIO is:
http://www.ni.com/pdf/manuals/374474a.pdf

The WPILibJ programming documentation of the Counter class:
http://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/wpilibj/Counter.html

The FIRST WPILib documentation of using counters:
http://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/wpilibj/Counter.html

The specific wiki that helped us with our issues was: 👍 👍 👍 👍 👍 😄 🌵
https://github.com/GirlsOfSteelRobotics/Docs/wiki/LIDAR-Lite-Distance-Sensor

The LIDAR Lite is supposed to be used with I2C or PWM, but it is recommended the sensor be used with DIO, because the sensor is more like a digital sensor and not an analog sensor. Plus, PWM is a type of digital.
This is just a summary of our journey with the laser sensor.

Wiring (DIO)

There's only three wires on the LIDAR you need to worry about:

  • Black (Ground)
  • Red (5+ V Power)
  • Yellow (Mode/Signal) (White on 3-pin cables)

The DIO input on the RoboRio has three pins that match these.

|_____Lidar Lite_____|
  |+    |S        |G
  |     |         |
  |     |--(:::)--|
  |     |         |
| = = DIO Port = = = |

Notice that there is a 1k Ohm resistor --(:::)-- plugged in between the signal and ground wires.
Keep in mind that the wire order has been changed to allow for easier imaging. The actual order of the wires on the DIO port, from edge to center, is: Ground (black), Power (red), and Signal (white).

It's basically a simplified version of the right side of this wiring diagram: LIDAR Wiring Diagram

Code

package frc.robot;
import edu.wpi.first.wpilibj.DigitalSource;
import edu.wpi.first.wpilibj.Counter;

public class LIDARSensor {
    private Counter counter;
    private static final double offset = 0.0;
    private static final double factor = 1;
    /* Based on your sensor, you will have different data.
     * Use multiple data points and a linear regression program
     * to obtain personal factor and offset values.
     * for cm: 100000, for in: 39400 (from our testing)
    */

    public void LIDARSensorInit() {
        counter = new Counter(0);
        counter.setMaxPeriod(1.0);
        counter.setSemiPeriodMode(true);
        counter.reset();
    }

    public double getDistance() {
        if (counter.get() < 1) {
            return 0.0;
        }
        return (counter.getPeriod() * factor + offset) // Use lin reg to obtain values
    }
}

Come visit our Twitter! 🐦 @ https://twitter.com/MurphysLaw4681

Email us! ✉️ @ amhsrobotics4681@google.com

Clone this wiki locally