Main Content

Rotation Sensor

Read shaft position and velocity

Since R2021b

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

  • Rotation Sensor block

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

Description

The Rotation Sensor block reads shaft's position and velocity from the Rotation sensor that is connected to the VEX® V5 Brain. The VEX V5 Rotation sensor is an absolute encoder and it retains the shaft orientation across power cycle.

Ports

Output

expand all

This port represents the rotational position of the shaft in degrees. The rotational position value ranges from -inf to inf.

Data Types: double

The Velocity port outputs shaft velocity in degrees per second.

Data Types: double

Parameters

expand all

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

Specify the option to reset the rotation sensor reading.

  • No reset – The block does not reset the Rotation sensor reading and outputs the total angle of rotation.

    For example, at T = 1 in the table the Rotation sensor rotates 20 degrees in a counterclockwise direction,so, the output is 20.

  • Reset at each sample time – For each sample period, the block outputs the rotation sensor reading, and then resets it to 0.

    For example, in the table, at T = 1, the rotation sensor rotates 20 degrees in a counterclockwise direction, and therefore, the output is 20.

    Between T = 1 and T = 2, the rotation sensor rotates 10 degrees in a counterclockwise direction, and therefore, the output is 10.

    If you reset the rotation sensor in this way, it retains the offset for the current program execution. It might require a reset after restarting the program. If you want to preserve the zero offset, select Set Zero on VEX V5 Brain’s User Interface. For more information, see Using VEX V5 Rotation Sensor.

  • Reset by external signal – The Rotation sensor reading is reset to 0 based on the input value to Rst port. When you send a value other than 0 to the block input, the Rotation sensor reading is reset to 0. For each sample period, the block outputs the Rotation sensor reading since the last reset.

    Reset mode

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.

Extended Capabilities

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

Version History

Introduced in R2021b