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 block sets the encoder’s current position to a specified value.

设定 [EncoderA v] 位置为 [0] 度

Parameter

Description

device

Which encoder to use, configured in the Devices window.

position

The rotational position to set in degrees.

Encoder position#

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

([EncoderA v] 转位 [度 v])

Parameter

Description

device

Which encoder to use, configured in the Devices window.

unit

The unit that will represent the position:

  • degrees
  • turns

Encoder velocity#

The Encoder velocity block returns the rotational speed of the encoder.

([EncoderA v] 速度 [dps v] 值)

Parameter

Description

device

Which encoder to use, configured in the Devices window.

unit

The unit that will represent the velocity:

  • dps – degrees per second
  • rpm – rotations per minute