Encoder#

Introduction#

The Optical Shaft Encoder measures the rotational position and speed of a shaft. It uses internal optical sensors to detect how far and how fast the shaft turns, making it useful for tracking wheel rotation, arm position, or other mechanisms.

The VEX Optical Shaft Encoder.

Below is a list of available blocks:

set Encoder position#

The set Encoder position stack block sets the encoder’s current position to a specified value. This block can be used to manually set the tracked position without rotating a motor or other mechanism.

Position is how far the shaft has rotated during a project.

  set [EncoderA v] position to [0] degrees

Parameter

Description

device

Which encoder to use, configured in the Devices window.

position

The rotational position to set in degrees as a whole number.

Encoder position#

The Encoder position reporter block reports how far the shaft connected to the encoder has rotated.

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

Parameter

Description

device

Which encoder to use, configured in the Devices window.

unit

The unit that will represent the position: degrees or turns.

Encoder velocity#

The Encoder velocity reporter block reports the rotational velocity of the encoder.

  ([EncoderA v] velocity in [dps v] :: custom-sensing)

Parameter

Description

device

Which encoder to use, configured in the Devices window.

unit

The unit that will represent the velocity: dps (degrees per second) or rpm (rotations per minute).