Motor 393 (Controlador de motor 29)#

Introducción#

The motor29 class is used to control a Motor Controller 29 connected to a 3-Wire Port. The Motor Controller 29 sends a PWM signal from the V5 Brain to operate a VEX Motor 393.

Constructores de clases#

1 Creates a motor29 object on the specified 3-Wire Port.

motor29(
    triport::port &port );

2 Creates a motor29 object on the specified 3-Wire Port and changes the positive turning direction.

motor29(
    triport::port &port,
    bool           reverse );

Instructor de clase#

Destroys the motor29 object and releases associated resources.

~motor29();

Parámetros#

Parámetro

Tipo

Descripción

port

triport::port&

The 3-Wire Port that the Motor Controller 29 is connected to, written as Brain.ThreeWirePort.X or ExpanderName.X, where X is the port letter (for example, Brain.ThreeWirePort.A or Expander1.A).

reverse

bool

Sets the positive direction of motor rotation:

  • false (default) — Clockwise rotation is treated as forward (positive direction).
  • true — Counterclockwise rotation is treated as forward (positive direction).

Ejemplo#

// Create a Motor Controller 29 instance in 3-Wire Port A
motor29 Motor393_A = motor29(
    Brain.ThreeWirePort.A );

Funciones de los miembros#

The motor29 class includes the following member functions:

  • giro — Hace girar el motor en una dirección específica.

  • parada — Detiene el motor.

  • setVelocity — Establece la velocidad del motor predeterminada que se utilizará para los comandos de movimiento subsiguientes.

  • setReversed — Establece si se invierte el sentido de giro del motor.

Before calling any motor29 member functions, an instance must be created, as shown below:

/* This constructor is required when using VS Code.
Motor 393 configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */

// Create a Motor Controller 29 instance in 3-Wire Port A
motor29 Motor393_A = motor29(
    Brain.ThreeWirePort.A );

spin#

Hace girar el motor 393 en la dirección especificada de forma indefinida.

Funciones disponibles

1 Gira usando la velocidad configurada actualmente.

void spin(
 directionType dir );

2 Gira a la velocidad especificada.

void spin(
 directionType dir,
 double        velocity,
 velocityUnits units );

Parámetros

Parámetro

Tipo

Descripción

dir

directionType

The direction in which the motor spins:

  • forward
  • reverse

velocity

double

El valor de velocidad aplicado al motor.

units

velocityUnits

The unit used to represent velocity:

  • percent / pct — percent
  • rpm — rotations per minute
  • dps — degrees per second

Valores de retorno

Esta función no devuelve ningún valor.

Notas

  • Esta función no requiere espera y el proyecto continuará ejecutándose inmediatamente después de la llamada.

  • The Motor 393 will continue spinning until stop is called or another spin is used.

stop#

Detiene el motor.

Funciones disponibles

void stop();

Parámetros

Esta función no requiere ningún parámetro.

Valores de retorno

Esta función no devuelve ningún valor.

setVelocity#

Sets the default velocity for a Motor 393. This velocity setting will be used for subsequent calls to spin if a specific velocity is not provided.

Funciones disponibles

void setVelocity(
    double velocity,
    percentUnits units );

Parámetros

Parámetro

Tipo

Descripción

velocity

double

El valor de velocidad que se aplicará al motor 393.

units

percentUnits

The unit used to represent velocity:

  • percent / pct — percent

Valores de retorno

Esta función no devuelve ningún valor.

setReversed#

Establece si se invierte el sentido de giro del motor.

Funciones disponibles

void setReversed(
    bool value );

Parámetros

Parámetro

Tipo

Descripción

value

bool

Sets the motor’s direction behavior:

  • true — The Motor 393’s positive direction is reversed.
  • false — The Motor 393’s positive direction remains normal.

Valores de retorno

Esta función no devuelve ningún valor.

Notas

  • Calling setReversed is the same as changing the reverse parameter in the constructor.