Using the V5 Distance Sensor

Description

The V5 Distance Sensor is one of the powerful V5 sensors which are designed for complete integration with the V5 robotics platform. This sensor uses a pulse of classroom-safe laser light to measure the distance from the front of the sensor to an object.

V5_Distance_Sensor.png

The V5 Distance Sensor can also be used to detect an object and determine the relative size of the object. The approximate size of an object is reported as small, medium or large.

The sensor can be used to calculate a robot’s approach speed. Approach speed measures the speed of the robot/sensor as it moves towards the object.

The housing of this sensor has two mounting tabs with slotted holes to provide flexibility when mounting the sensor to a robot.

V5_Distance_Sensor-Callouts1.png

On the face of the sensor there is a small window where the laser beam is sent out and then received in order to measure distance.

V5_Distance_Sensor-Callouts2.png

The width of the V5 Distance Sensor allows it to be nested into a piece of C Channel.

V5_Distance_Sensor_in_C-Channel.png

Note: a 1/4 inch Standoff (275 - 1013) or an 8mm Plastic Spacer (276-2019) needs to be used for this attachment in order to provide clearance for the V5 Smart Port.

In order for the Distance Sensor to be functional with the V5 Robot Brain, the sensor’s V5 Smart Port and a V5 Robot Brain’s Smart Port need to be connected with a V5 Smart Cable. The Distance Sensor will work with any of the 21 Smart Ports on the V5 Robot Brain. When connecting a V5 Smart Cable to the ports, be sure the cable’s connector is fully inserted into the port and the connector’s locking tab is fully engaged.

V5_Robot_Brain-V5_Distance_Sensor.png


How the Distance Sensor Works

The V5 Distance Sensor sends out a pulse of classroom-safe laser light and measures the amount of time it takes for the pulse to be reflected. This allows for a calculation of distance.

The sensor’s Class 1 Laser is similar to the lasers used on modern cell phones for head detection. The laser allows the sensor to have a very narrow field of view, so detection is always directly in front of the sensor.

The V5 Distance Sensor’s measurement range is 20mm to 2,000mm (0.79 inch to 78.74 inches). Below 200mm the accuracy is approximately +/‐15mm, above 200mm the accuracy is approximately 5%.

The Distance Sensor needs to be paired with a programming language such as the VEXcode V5 or VEXcode Pro V5 to create a user program for the V5 Robot Brain to utilize the sensor’s readings to control the robot’s behavior.

The V5 Brain in concert with a user program can be used to convert the Distance Sensor readings into:

  • Distance to an object measured in millimeters or inches.
  • Object velocity in meters per second.
  • Object size is small, medium, or large.
  • Found an object.

VEXcodeV5-icon.jpg


Setup of the Distance Sensor

  • Placement: The placement of the Distance Sensor is very important to its accurate readings. Be sure no structure on the robot is in front of the small laser window on the face of the sensor. There needs to be a clear path in front of the sensor between any object being measured and the sensor.

V5_Distance_Sensor-Detecting_Red.png

  • Reading Distance Sensor Values: It is helpful to use the Device Info screen on the V5 Robot Brain to see the values the Distance Sensor is returning. This can be done with the sensor connected to the Brain by:
    1. Remove the V5 Brain Magnetic Screen Protector, turn on the Brain, and touch the Devices icon.
      RemoveTheV5.png
    1. Touch the Distance Sensor icon on the Device Info screen.
      TouchTheDistance.png
    1. Place an object in front of the Distance Sensor or face the sensor towards a wall and observe its measurements. The displayed range and units, mm or inches, can be changed by a touch of the screen.
      PlaceAnObject.png

 

Note: Ensure the V5 Robot Brain has the latest version of firmware.


Adding the distance sensor as a device in VEXcode V5

Whenever a sensor is used with a programming language it needs to be configured within that language. With VEXcode V5 and VEXcode Pro V5, this is accomplished by using the ‘Add a device’ feature. To provide an example of this, the following steps will add the Distance Sensor as a device within VEXcode V5.

  1. Select the Devices icon.
    SelectDevicesIcon.png
  1. Select ‘Add a device.’
    SelectAddADevice.png
  1. Select ‘DISTANCE.’
    SelectDistance.png
  1. Select the Smart Port that the Distance Sensor is plugged into on the V5 Robot Brain.
    SelectSmartPort.png
  1. Once the port is chosen, select ‘DONE.’
    OnceThePort.png
    Note: There is an option to change the name of the Distance Sensor in the text window from Distance1 to a different name.

Once the distance sensor has been added to your user program a new set of sensor commands will become available.

OnceTheDistance.png


Common Uses of the Distance Sensor

The Distance Sensor can produce several measurements which can be used to change the behavior of the robot.

These features can be used with either:

  • The ‘Device info’ option on the V5 Robot Brain.
  • Using the example project ‘Distance Sensing’ found in the ‘Open Examples’ option in the File menu of VEXcode V5.
  • Writing a custom user program with one of the VEXcode programs.

OpenExamples.pngExampleLogo.png


These features include:

  • Distance to an object measured in millimeters or inches. This provides a measurement between the front of the distance sensor and an object or a barrier/wall. A fun classroom challenge would be to use the distance sensor to measure the distance between your robot and the wall. Then measure the distance with a different method such as a tape measure and compare the two measurements.
  • Object velocity in meters per second. This provides a measurement of the velocity in meters per second for an object approaching your robot or your robot approaching an object. A fun classroom challenge would be to write a custom user program to measure the maximum speed of your robot as you drive it towards a wall.
  • Object size is small, medium, or large. This feature allows your robot to identify an object as being small, medium, or large depending on the sensor’s reading. A fun classroom challenge would be to use the V5 Robot Brains Device Info screen and place different objects at a set distance, such as one meter, to see if the sensor detects the object as small, medium, or large.
    Note: Object size is an estimation and may be affected by object reflectivity.
  • Found an object. This feature allows your robot to detect an object when it becomes within the range of the distance sensor. A fun classroom challenge would be to place objects with different reflectivity in front of the sensor, such as a block of black foam rubber or a shiny ball of aluminum foil, to see if the object’s surface has any effect on its detection.
    V5_Clawbot_with_Foam.png

Uses of the Distance Sensor on a Competition Robot:

The Distance Sensor will provide a superior competitive advantage for competition robots. The ability to detect distance to the perimeter wall and be able to measure a robot's velocity will provide a great deal of information when designing autonomous routines.

Object detection and determining the object’s relative size will provide helpful information with the detection of game pieces and or goals.

For example in the 2020 - 2021 VEX Robotics Competition Game, Change Up, a distance sensor could be angled to scan the floor in front of your robot's intake. As soon as one of the balls used in the game is detected, this could automatically turn on the robot's intake and pick up the ball.

V5_Distance_Sensor-Detecting_Red.png

No matter what the application the VEX V5 Distance Sensor is used for, there is no doubt it will be a welcomed addition for teams. The function of the sensor’s values are open for the imagination of the user.

The V5 Distance Sensor is available on VEX’s Website.