Victor 883 Motor#

Εισαγωγή#

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.

Ο ελεγκτής κινητήρα Victor 883 δεν μπορεί να διαμορφωθεί σε VEXcode και πρέπει να κατασκευαστεί χειροκίνητα σε κώδικα για να χρησιμοποιηθεί.

Κατασκευαστές κλάσεων#

1 Creates a motor_victor object for the Victor 883 Motor Controller connected to the specified 3-Wire Port.

motor_victor( triport::port& port );

2 Creates a motor_victor object on the specified 3-Wire Port and optionally reverses its direction.

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

Καταστροφέας κλάσης#

Destroys the motor_victor object and releases associated resources.

~motor_victor();

Παράμετροι#

Παράμετρος

Τύπος

Περιγραφή

port

triport::port&

The 3-Wire Port that the Victor 883 Motor 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 whether the motor’s spin direction is reversed:

  • false (default) — Does not reverse the motor’s direction.
  • true — Reverses the motor’s direction.

Παράδειγμα#

// 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);

Συναρτήσεις Μελών#

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#

Περιστρέφει τον κινητήρα προς την καθορισμένη κατεύθυνση για πάντα.

Available Functions

1 Περιστρέφει τον κινητήρα χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.

void spin(
 directionType dir );

2 Περιστρέφει τον κινητήρα με την καθορισμένη ταχύτητα.

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

Parameters

Παράμετρος

Τύπος

Περιγραφή

dir

directionType

The direction in which the motor spins: forward or reverse.

velocity

double

The velocity to spin with from 0% to 100% when using percent.

units

velocityUnits

The velocity unit:

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

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • The motor will continue spinning until stop is called or another movement function is executed.

Examples
// 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#

Σταματά την περιστροφή του κινητήρα.

Available Functions
void stop();

Parameters

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Calling stop immediately stops any current motor movement.

Examples
// Spin and then stop
victor.spin(forward);
wait(1, seconds);
victor.stop();

setVelocity#

Υποδεικνύει στον κινητήρα πόσο γρήγορα πρέπει να περιστραφεί. Ένα υψηλότερο ποσοστό κάνει τον κινητήρα να περιστρέφεται πιο γρήγορα και ένα χαμηλότερο ποσοστό κάνει τον κινητήρα να περιστρέφεται πιο αργά.

Κάθε έργο ξεκινά με κάθε συνδεδεμένο κινητήρα να περιστρέφεται με ταχύτητα 50% από προεπιλογή.

Available Functions
void setVelocity(
    double       velocity,
    percentUnits units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

velocity

double

The velocity to spin with from 0% to 100% when using percent.

units

percentUnits

The velocity unit:percent / pct — percent

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Any subsequent Victor 883 Motor movement function (such as spin) that does not explicitly specify a velocity will use this value.

Examples
// Set velocity to 50%, then spin
victor.setVelocity(50, percent);
victor.spin(forward);

setReversed#

Ορίζει την κατεύθυνση του κινητήρα για αντιστροφή ή όχι.

Available Functions
void setReversed( bool value );

Parameters

Παράμετρος

Τύπος

Περιγραφή

value

bool

Whether the motor’s direction is reversed:

  • true — Reverses the motor’s direction.
  • false — Returns the motor’s direction to its default.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • This is the same as changing the reverse parameter in the constructor.

Examples
// Reverse the motor direction
victor.setReversed(true);
victor.spin(forward); // Will actually spin in reverse