Main Content

Distance Sensor

Read distance, velocity, and relative size of obstacle

Since R2021b

Add-On Required: This feature requires the Simulink Coder Support Package for VEX EDR V5 Robot Brain add-on.

  • Distance Sensor block

Libraries:
Simulink Coder Support Package for VEX EDR V5 Robot Brain / Sensors

Description

The Distance Sensor block reads data from the Distance sensor that is connected to the VEX® V5 Brain. You can use this block in your Simulink model to obtain distance, velocity, relative size of obstacle, and confidence. Also, the sensor outputs confidence in measuring distance.

Ports

Output

expand all

The Distance port outputs distance in meters. Nominal range is around 2 meters.

Data Types: double

The Velocity port outputs relative velocity of obstacle in meters per second.

Dependencies

To enable this port select Velocity (m/s) parameter.

Data Types: double

The Size output indicates the obstacle size. It ranges from 0 to 400, with larger values corresponding to larger obstacle.

Dependencies

To enable this port select the Size parameter.

Data Types: double

The Confidence indicates if an object is detected within sensor's range and its value ranges from 0 to 63. Confidence value drops to 0 when an object is beyond the sensor's range and the value is 10 for distances below 0.2 meters.

Dependencies

To enable this port select the Confidence parameter.

Data Types: double

Parameters

expand all

Select the smart port on the V5 robot to which the VEX V5 Distance sensor is connected. There are 21 smart ports on the V5 robot.

Specify the sample time in seconds to determine how often the block reads values from the sensor. When you specify this parameter as -1, Simulink® determines the best sample time for the block based on the block context within the model.

Additional Outputs

Select this parameter to enable Velocity port. For more information on the Velocity port, see Velocity,

Select this parameter to enable Size port. For more information on the Size port, see Size,

Select this parameter to enable Confidence port. For more information on the Confidence port, see Confidence.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2021b