Κινητήρας 393 (Ελεγκτής Κινητήρα 29)#

Εισαγωγή#

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.

Ο Ελεγκτής Κινητήρα VEX 29.

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

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

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

Destroys the motor29 object and releases associated resources.

~motor29();

Παράμετροι#

Παράμετρος

Τύπος

Περιγραφή

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 whether the motor’s spin direction is reversed:

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

Παράδειγμα#

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

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

The motor29 class includes the following member functions:

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

  • στάση — Σταματά τον κινητήρα.

  • setVelocity — Υποδεικνύει στον κινητήρα 393 πόσο γρήγορα πρέπει να περιστραφεί.

  • setReversed — Ορίζει εάν η κατεύθυνση περιστροφής του κινητήρα αντιστρέφεται.

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#

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

Διαθέσιμες Λειτουργίες

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

void spin(
 directionType dir );

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

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

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

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

Επιστρεφόμενες τιμές

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

Σημειώσεις

  • Αυτή η συνάρτηση δεν είναι σε αναμονή και το έργο θα συνεχίσει να εκτελείται αμέσως μετά την κλήση.

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

stop#

Σταματάει τον κινητήρα.

Διαθέσιμες Λειτουργίες

void stop();

Παράμετροι

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

Επιστρεφόμενες τιμές

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

setVelocity#

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

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

Διαθέσιμες Λειτουργίες

void setVelocity(
    double velocity,
    percentUnits units );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

velocity

double

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

units

percentUnits

The velocity unit:percent / pct — percent

Επιστρεφόμενες τιμές

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

setReversed#

Ορίζει εάν η κατεύθυνση περιστροφής του κινητήρα αντιστρέφεται.

Διαθέσιμες Λειτουργίες

void setReversed(
    bool value );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

value

bool

Whether the Motor 393’s direction is reversed:

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

Επιστρεφόμενες τιμές

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

Σημειώσεις

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