Victor 883 Motor#
Introduction#
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 EXP Brain to control compatible VEXpro or VEX EDR DC motors that cannot be connected directly to Smart Ports.
The Victor 883 Motor Controller cannot be configured in VEXcode and must be manually constructed in code in order to be used.
Class Constructors#
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 );
Class Destructor#
Destroys the motor_victor object and releases associated resources.
~motor_victor();
Parameters#
Parameter |
Type |
Description |
|---|---|---|
|
|
The 3-Wire Port that the Victor 883 Motor is connected to, written as |
|
|
Sets whether the motor’s spin direction is reversed:
|
Example#
// 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);
Member Functions#
The motor_victor class includes the following member functions:
spin— Spins the motor in a specified direction.stop— Stops the motor.setVelocity— Tells the motor how fast to spin.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#
Spins the motor in the specified direction forever.
Available Functions1 — Spins the motor using the currently configured motor velocity.
void spin( directionType dir );
Parameters2 — Spins the motor at the specified velocity.
void spin( directionType dir, double velocity, velocityUnits units );
Parameter |
Type |
Description |
|---|---|---|
|
|
The direction in which the motor spins: |
|
|
The velocity to spin with from 0% to 100% when using |
|
|
The velocity unit:
|
This function does not return a value.
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#
Stops the motor from spinning.
Available Functionsvoid stop();
This function does not accept any parameters.
Return ValuesThis function does not return a value.
NotesCalling
stopimmediately stops any current motor movement.
// Spin and then stop
victor.spin(forward);
wait(1, seconds);
victor.stop();
setVelocity#
Tells the motor how fast to spin. A higher percentage makes the motor spin faster and a lower percentage makes the motor spin slower.
Every project begins with each connected motor spinning at 50% velocity by default.
Available Functionsvoid setVelocity(
double velocity,
percentUnits units );
Parameter |
Type |
Description |
|---|---|---|
|
|
The velocity to spin with from 0% to 100% when using |
|
|
The velocity unit: |
This function does not return a value.
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#
Sets the motor direction to be reversed or not.
Available Functionsvoid setReversed( bool value );
Parameter |
Type |
Description |
|---|---|---|
|
|
Whether the motor’s direction is reversed:
|
This function does not return a value.
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