Encoder Sensing#

To make Optical Shaft Encoder blocks appear in VEXcode V5, a 3-Wire Shaft Encoder must be configured in the Devices window.

For more information, refer to these articles:

Set Shaft Encoder Position#

The Set Shaft Encoder Position block is used to set the Shaft Encoder’s position to the given value.

  set [EncoderC v] position to (0) degrees

Choose which Shaft Encoder to use.

Shaft encoder device displaying position and velocity data on a V5 Brain screen for robotics applications.

In this example, the Shaft Encoder will print its starting position, set its position to 90 degrees, and then print the new position.

  when started :: hat events
  print ([EncoderC v] position in [degrees v]) on [Brain v] ◀ and set cursor to next row
  set [EncoderC v] position to (90) degrees
  print ([EncoderC v] position in [degrees v]) on [Brain v] ◀ and set cursor to next row

Shaft Encoder Position#

The Shaft Encoder Position block is used to report the distance the Shaft Encoder has rotated.

  ([EncoderC v] position in [degrees v])

Choose which Shaft Encoder to use.

Shaft encoder position device displaying settings for motor position and velocity in robotic applications.

Choose which unit to report in: degrees or turns.

Shaft encoder position units diagram illustrating the measurement of rotational position and velocity in robotics.

In this example, the Shaft Encoder will print its starting position, set its position to 90 degrees, and then print the new position.

  when started :: hat events
  print ([EncoderC v] position in [degrees v]) on [Brain v] ◀ and set cursor to next row
  set [EncoderC v] position to (90) degrees
  print ([EncoderC v] position in [degrees v]) on [Brain v] ◀ and set cursor to next row

Shaft Encoder Velocity#

The Shaft Encoder Velocity block is used to report the current velocity of a Shaft Encoder.

  ([EncoderC v] velocity in [dps v])

Choose which Shaft Encoder to use.

Shaft encoder velocity device showing real-time velocity data in degrees per second for precise motor control.

Choose which unit to report in: degrees per second (dps) or rotations per minute (rpm).

Shaft encoder velocity units diagram illustrating degrees per second (dps) and rotations per minute (rpm) measurements.