Motor Victor 883#
Introducción#
The motor_victor class is used to control a Victor 883 Motor Controller connected to a 3-Wire Port. The Victor 883 Motor Controller sends a PWM signal from the V5 Brain to control compatible VEXpro or VEX EDR DC motors that cannot be connected directly to Smart Ports.
El controlador de motor Victor 883 no se puede configurar en VEXcode y debe construirse manualmente mediante código para poder utilizarse.
Constructores de clases#
1 — Creates a
motor_victorobject for the Victor 883 Motor Controller connected to the specified 3-Wire Port.motor_victor( triport::port& port );
2 — Creates a
motor_victorobject on the specified 3-Wire Port and optionally reverses its direction.motor_victor( triport::port& port, bool reverse );
Instructor de clase#
Destroys the motor_victor object and releases associated resources.
~motor_victor();
Parámetros#
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The 3-Wire Port that the Victor 883 Motor is connected to, written as |
|
|
Sets the positive direction of motor rotation:
|
Ejemplo#
// Create the motor_victor instance on 3-Wire Port A
motor_victor victor = motor_victor(Brain.ThreeWirePort.A);
// Create the motor_victor instance with reversed direction
motor_victor victor2 = motor_victor(Brain.ThreeWirePort.B, true);
Funciones de los miembros#
The motor_victor class includes the following member functions:
spin— Spins the motor in a specified direction.stop— Stops the motor.setVelocity— Sets the default velocity for the motor.setReversed— Sets the motor direction to be reversed or not.
Before calling any motor_victor member functions, a motor_victor instance must be created, as shown below:
/* This constructor is required to use a
Victor 883 Motor. Replace the values
as needed. */
// Create the motor_victor instance on 3-Wire Port A
motor_victor victor = motor_victor(Brain.ThreeWirePort.A);
spin#
Hace girar el motor en la dirección especificada de forma indefinida.
Available Functions1 — Hace girar el motor utilizando la velocidad del motor configurada actualmente.
void spin( directionType dir );
Parameters2 — Hace girar el motor a la velocidad especificada.
void spin( directionType dir, double velocity, velocityUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The direction in which the motor spins:
|
|
|
El valor de velocidad aplicado al motor. |
|
|
The unit used to represent velocity:
|
Esta función no devuelve ningún valor.
NotesThe motor will continue spinning until
stopis called or another movement function is executed.
// Spin forward, then stop
victor.spin(forward);
wait(1, seconds);
victor.stop();
// Spin forward at 100 rpm
victor.spin(forward, 100, rpm);
wait(1, seconds);
victor.stop();
stop#
Impide que el motor gire.
Available Functionsvoid stop();
Esta función no acepta ningún parámetro.
Return ValuesEsta función no devuelve ningún valor.
NotesCalling
stopimmediately stops any current motor movement.
// Spin and then stop
victor.spin(forward);
wait(1, seconds);
victor.stop();
setVelocity#
Establece la velocidad predeterminada para el motor Victor 883. Esta configuración de velocidad se utilizará para las llamadas posteriores a cualquier función del motor si no se proporciona una velocidad específica.
Available Functionsvoid setVelocity(
double velocity,
percentUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
El valor de velocidad que se aplicará al motor. |
|
|
The unit used to represent
|
Esta función no devuelve ningún valor.
NotesAny subsequent Victor 883 Motor movement function (such as
spin) that does not explicitly specify a velocity will use this value.
// Set velocity to 50%, then spin
victor.setVelocity(50, percent);
victor.spin(forward);
setReversed#
Permite configurar si el sentido de giro del motor debe invertirse o no.
Available Functionsvoid setReversed( bool value );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
A boolean value to set the direction to reversed or not:
|
Esta función no devuelve ningún valor.
NotesThis is the same as changing the
reverseparameter in the constructor.
// Reverse the motor direction
victor.setReversed(true);
victor.spin(forward); // Will actually spin in reverse