Rotation Sensor#

Introduction#

The Rotation Sensor measures the rotation of a shaft. It can be used anywhere on a robot where a shaft is rotating, even if that shaft is not connected directly to a motor.

A motor has a built-in encoder that can track its own rotation. The Rotation Sensor works like an external encoder that can track the rotation of a separate shaft.

The Rotation Sensor can report the shaft’s angle, position, and velocity. Angle is the shaft’s absolute position from 0 to 359.99 degrees. It does not reset when a project starts or when the robot is powered off. Position tracks how many degrees or turns the shaft has rotated forward or reverse during a project, and it can be reset as needed.

The Rotation Sensor is compatible with 1/8 inch and 1/4 inch standard VEX shafts.

The VEX Rotation Sensor.

Below is a list of available blocks:

set Rotation position#

The set Rotation position stack block sets the Rotation Sensor’s current position to a value in degrees.

Position is how far the shaft has rotated during a project. Setting the position changes the current position value without moving the shaft.

  set [Rotation1 v] position to [0] degrees

Parameters

Description

device

The Rotation Sensor to use. Choose from the Rotation Sensors configured in the Devices window.

position

The position value to assign to the Rotation Sensor, in degrees. This can be an integer or a decimal.

Rotation angle#

The Rotation angle reporter block reports the shaft’s current angle from 0 to 359.99 degrees.

Angle reports the shaft’s absolute position within one rotation. It does not reset when a project starts or when the robot is powered off.

  ([Rotation1 v] angle in degrees)

Parameters

Description

device

The Rotation Sensor to use. Choose from the Rotation Sensors configured in the Devices window.

Rotation position#

The Rotation position reporter block reports the shaft’s total rotational position.

Unlike angle, position can increase past 359.99 degrees or decrease below 0 degrees. Position tracks how far the shaft rotates forward or reverse during a project and can be reset as needed.

  ([Rotation1 v] position in [degrees v] :: custom-sensing)

Parameters

Description

device

The Rotation Sensor to use. Choose from the Rotation Sensors configured in the Devices window.

units

The position unit: degrees or turns.

Rotation velocity#

The Rotation velocity reporter block reports how fast the shaft is rotating.

  ([Rotation1 v] velocity in [rpm v] :: custom-sensing)

Parameters

Description

device

The Rotation Sensor to use. Choose from the Rotation Sensors configured in the Devices window.

units

The velocity unit: rpm (revolutions per minute) or dps (degrees per second).