Codificador#

Introducción#

El Codificador Óptico de Eje mide la posición y la velocidad de rotación de un eje. Utiliza sensores ópticos internos para detectar la distancia y la velocidad de giro del eje, lo que lo hace útil para el seguimiento de la rotación de la rueda, la posición del brazo u otros mecanismos.

El codificador de eje óptico VEX.

This page uses encoder_a as the example Optical Shaft Encoder name. Replace it with your own configured name as needed.

A continuación se muestra una lista de los métodos disponibles:

  • set_position – Sets the encoder’s current position to a specific value.

  • reset_position – Sets the encoder’s current position to 0.

  • position – Returns how far the encoder has rotated.

  • velocity – Returns the current rotational speed of the encoder.

Constructor: inicializa y configura manualmente un codificador de eje óptico.

  • Encoder – Create an Optical Shaft Encoder.

establecer_posición#

set_position sets the encoder’s current position to a specified value.

Usage:
encoder_a.set_position(position, units)

Parámetro

Descripción

posición

La posición del codificador a establecer como un número.

unidades

Optional. The unit to set the position with:

  • DEGREES (default)
  • TURNS

# Set the encoder's position to 3 turns
encoder_a.set_position(3, TURNS)

restablecer_posición#

reset_position sets the encoder’s current position to 0.

Usage:
encoder_a.reset_position()

Parámetros

Descripción

Este método no tiene parámetros.

posición#

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

Usage:
encoder_a.position(units)

Parámetros

Descripción

unidades

Optional. The unit to return the position with:

  • DEGREES (default) – Returns an integer
  • TURNS – Returns a float.

velocidad#

velocity returns the rotational speed of the encoder as a float.

Usage:
encoder_a.velocity(units)

Parámetro

Descripción

unidades

Optional. The unit to return the velocity with:

  • RPM (default) – Rotations per minute
  • VelocityUnits.DPS – Degrees per second.

Constructor#

Constructors are used to manually create Encoder objects, which are necessary for configuring an Optical Shaft Encoder outside of VEXcode.

Encoder#

Encoder creates an Optical Shaft Encoder.

Usage:
Encoder(port)

Parámetro

Descripción

port

The first of the two 3-Wire Ports that the Optical Shaft Encoder is connected to:

  • On the V5 BrainPorts.PORTx where x is the number of the port.
  • On a 3-Wire Expanderexpander.a where expander is the name of the expander instance.

# Create an Optical Shaft Encoder in Port A and B
encoder_a = Encoder(brain.three_wire_port.a)