LogoLogo
  • REV Crossover Landing
  • Sensors
    • Through Bore Encoder
      • Specifications
      • Application Examples
    • Color Sensor V3
      • Specifications
      • Application Examples
      • Discontinued Color Sensors
        • V2 Specifications & Examples
        • V1 Specifications & Examples
    • 2m Distance Sensor
      • Specifications
      • Application Examples
    • Magnetic Limit Switch
      • Specifications
      • Application Examples
    • Touch Sensor
      • Specifications
      • Application Examples
    • Potentiometer
      • Specifications
      • Application Examples
  • Blinkin LED Driver
    • Blinkin LED Driver Overview
    • Blinkin Specifications
    • Blinkin Getting Started
      • LED Pattern Tables
    • Blinkin Troubleshooting
    • REV ION Application Examples
    • REV DUO Application Examples
  • UltraPlanetary System
    • UltraPlanetary System Overview
    • UltraPlanetary Features
    • Cartridge Details
    • Load Ratings
    • Assembly Instructions
    • Mounting Brackets
    • Ultra 90 Degree Gearbox
      • Assembly Instructions
      • Rotation Direction
  • Servos & Accessories
    • Servo Hub
      • Servo Hub Wiring
      • Configuring the Servo Hub with a Control Hub
      • Channel Power
      • Channel Pulse
      • Servo Hub Status LED Patterns
      • Troubleshooting
      • REVLib for Servo Hub
    • Smart Robot Servo
      • SRS Gear Replacement
    • SRS Programmer
      • Switching Operating Modes
    • Servo Power Module
  • Indicators
    • Digital LED Indicator
      • Specifications
      • Application Examples
Powered by GitBook
On this page
  • Application Examples
  • FTC Applications
  • FRC Applications
  • Additional Resources

Was this helpful?

Export as PDF
  1. Sensors
  2. 2m Distance Sensor

Application Examples

PreviousSpecificationsNextMagnetic Limit Switch

Last updated 7 months ago

Was this helpful?

Application Examples

While the REV 2m Distance Sensor produces a significantly more accurate and reliable measurement than other types of ranging sensors, the following tips will help minimize errors.

A major benefit to time-of-flight measurements is that the target’s surface reflectance does not significantly impact the calculated distance. However, the smallest errors and farthest measurements are achieved with more reflective targets. Similarly, larger targets are easier to detect because they fill more of the sensors 25° field of view.

Ambient infrared (IR) interference can also affect the measurement distance and quality. The sensor can produce accurate measurements in sunlit environments, but the maximum distance will be reduced. The following table outlines the typical ranging capabilities of the sensor:

Target Reflectance

Indoor

Outdoor (overcast)

White (88%)

200 cm †

80 cm

Grey (17%)

80 cm

50 cm

† Using long range API profile; default profile range is 120cm.

FTC Applications

Configuring in the Control System

Configure the 2m Distance Sensor as "REV 2M Distance Sensor," shown in the image below.

The Robot Controller Application currently only supports the default profile for the sensor.

In this example, the 2m Distance Sensor is configured on I2C bus 1. The 2m Distance Sensor can be configured on any of the I2C busses as long as a Color Sensor V3 is not configured to the same bus.

Recall that I2C sensors must have different addresses in order to operate on the same bus. The Color Sensor V3 and 2m Distance Sensor share the same address.

Programming Applications

This program moves a motor if there is an object less than 10 centimeters from the distance sensor, and stops it if there is no object within that range.

The Java version of this program is pasted below. It assumes that the Distance Sensor was configured with the name “test_distance” and that a motor was configured with the name “test_motor.”

package org.firstinspires.ftc.teamcode;
 
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
import com.qualcomm.robotcore.hardware.DistanceSensor;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
 
@TeleOp
public class DistanceTest extends LinearOpMode {
    DistanceSensor test_distance;
    DcMotor test_motor;
    
    @Override
    public void runOpMode() {
        // Get the distance sensor and motor from hardwareMap
        test_distance = hardwareMap.get(DistanceSensor.class, "test_distance");
        test_motor = hardwareMap.get(DcMotor.class, "test_motor");
        
        // Loop while the Op Mode is running
        waitForStart();
        while (opModeIsActive()) {
            // If the distance in centimeters is less than 10, set the power to 0.3
            if (test_distance.getDistance(DistanceUnit.CM) < 10) {
                test_motor.setPower(0.3);
            } else {  // Otherwise, stop the motor
                test_motor.setPower(0);
            }
        }
    }
}

FRC Applications

  • Example Code

Additional Resources

Additional information about the VL53L0X, its capabilities, and the ST Application Programming Interface (API) can be found through the ST website:

For use with WPILib and the roboRIO the . Utilize the roboRIO's I2C port and a 4-pin JST PH to 4-pin roboRIO I2C Cable () to easily connect the sensor to the roboRIO.

proper library will need installation
REV-11-1729
Java
C++
Labview
VL53L0X Datasheet
VL53L0X API and Documentation