Ελεγκτής κινητήρα 55#

Εισαγωγή#

The motor55 class is used to control a VEX Motor Controller 55 connected to the EXP Brain. The Motor Controller 55 is a legacy motor controller designed to operate 2-wire DC motors.

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

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

1 Creates a motor55 object on the specified Smart Port.

motor55(
  int32_t index );

2 Creates a motor55 object on the specified Smart Port and changes the positive turning direction.

motor55(
  int32_t index,
  bool    reverse );

3 Creates a motor55 object on the specified Smart Port, sets the maximum drive voltage, and changes the positive turning direction.

motor55(
  int32_t index,
  double  maxv,
  bool    reverse );

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

Destroys the motor55 object and releases associated resources.

~motor55();

Παράμετροι#

Παράμετρος

Τύπος

Περιγραφή

index

int32_t

The Smart Port that the Motor Controller 55 is connected to, written as PORTx, where x is the port number (for example, PORT1).

reverse

bool

Determines whether the motor’s direction is reversed:

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

maxv

double

Η μέγιστη τάση που μπορεί να εφαρμόσει ο Ελεγκτής Κινητήρα 55 στον κινητήρα.

Παράδειγμα#

// Create the motor55 instance in Smart Port 1
motor55 Motor1 = motor55(PORT1);

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

The motor55 class includes the following member functions:

  • spin — Spins the motor in a specified direction.

  • stop — Stops the motor.

  • setVelocity — Tells the DC motor how fast to spin.

  • setStopping — Sets the stopping behavior (coast or brake).

  • setReversed — Sets whether the motor’s direction is reversed.

  • current — Returns the motor’s electrical current.

  • voltage — Returns the motor’s electrical voltage.

  • temperature — Returns the motor temperature.

  • getMotorType — Returns the detected motor/controller type.

  • installed — Returns whether the Motor Controller 55 is detected on the specified Smart Port.

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

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

// Create the motor55 instance in Smart Port 1
motor55 MC55_1 = motor55(PORT1);

spin#

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

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

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

void spin(
  directionType dir );

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

void spin(
  directionType dir,
  double        voltage,
  voltageUnits  units );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

dir

directionType

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

voltage

double

The voltage value applied to the motor. A negative value spins opposite the given dir.

units

voltageUnits

The unit used to represent voltage:

  • volt — volts
  • voltageUnits::mV — millivolts

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

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

Σημειώσεις

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

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

stop#

Σταματά την περιστροφή του κινητήρα χρησιμοποιώντας την τρέχουσα διαμορφωμένη λειτουργία πέδησης.

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

void stop();

Παράμετροι

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

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

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

Σημειώσεις

  • Stops the motor using the currently configured stopping mode set by setStopping.

setVelocity#

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

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

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

void setVelocity(
    double       velocity,
    percentUnits units = percent );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

velocity

double

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

units

percentUnits

The velocity unit: percent / pct — percent.

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

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

Σημειώσεις

  • Any subsequent call to spin without a specified voltage will use this value.

setStopping#

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

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

void setStopping(
    brakeType mode );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

mode

brakeType

The stopping mode applied when stop is called:

  • coast — Motor coasts to a stop
  • brake — Motor stops quickly using braking

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

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

Σημειώσεις

  • Any subsequent call to stop will use this stopping mode.

  • The Motor Controller 55 supports coast and brake only. hold is not supported.

setReversed#

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

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

void setReversed(
    bool value );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

value

bool

Whether the motor’s direction is reversed:

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

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

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

Σημειώσεις

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

current#

current returns how much electrical current the DC motor is using. Current is the amount of electricity flowing through the DC motor. When returned in amps, current is reported from 0.0 to 1.2 A.

Μια υψηλότερη τιμή ρεύματος σημαίνει ότι ο κινητήρας συνεχούς ρεύματος χρησιμοποιεί περισσότερο ηλεκτρικό ρεύμα. Αυτό μπορεί να συμβεί όταν ο κινητήρας συνεχούς ρεύματος σηκώνει κάτι βαρύ, πιέζει ένα αντικείμενο ή προσπαθεί να κινηθεί όταν αυτό έχει κολλήσει.

Αυτό μπορεί να χρησιμοποιηθεί για να ελέγξετε εάν ο κινητήρας συνεχούς ρεύματος παρουσιάζει δυσκολίες κατά τη διάρκεια μιας κίνησης. Εάν το ρεύμα παραμείνει υψηλό, ο κινητήρας μπορεί να θερμανθεί ή να χρησιμοποιήσει την ισχύ λιγότερο αποτελεσματικά.

Available Functions

1 Επιστρέφει το ηλεκτρικό ρεύμα του κινητήρα συνεχούς ρεύματος σε αμπέρ.

double current(
  currentUnits units = amp );

2 Επιστρέφει το ηλεκτρικό ρεύμα του κινητήρα συνεχούς ρεύματος ως ποσοστό του μέγιστου ονομαστικού ρεύματος.

double current(
  percentUnits units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

units

currentUnits

The unit used to represent current:amp (default) — amperes

units

percentUnits

Represents current as a percentage of the motor’s maximum rated current:percent / pct — percent

Return Values

Returns a double representing how much electrical current the DC motor is using in the specified units.

voltage#

Επιστρέφει την ηλεκτρική τάση που παρέχεται στον κινητήρα.

Available Functions
double voltage(
  voltageUnits units = volt );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

units

voltageUnits

The unit to represent the voltage:

  • volt (default)
  • voltageUnits::mV — millivolts

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

Returns a double representing the motor’s electrical voltage in the specified units.

temperature#

temperature returns the temperature of the DC motor.

Η θερμοκρασία του κινητήρα δείχνει πόσο ζεστός είναι ο κινητήρας συνεχούς ρεύματος. Μια υψηλότερη θερμοκρασία σημαίνει ότι ο κινητήρας συνεχούς ρεύματος θερμαίνεται κατά τη λειτουργία του. Ο κινητήρας θα πρέπει να παραμένει κάτω από τους 55°C για να συνεχίσει να λειτουργεί σε πλήρη απόδοση.

Εάν ο κινητήρας συνεχούς ρεύματος υπερθερμανθεί, θα μειώσει το μέγιστο ρεύμα του για να προστατευτεί. Στους 70°C, ο κινητήρας θα σταματήσει να λειτουργεί μέχρι να κρυώσει.

Αυτό μπορεί να χρησιμοποιηθεί για να ελέγξετε εάν ο κινητήρας συνεχούς ρεύματος υπερθερμαίνεται κατά τη διάρκεια επαναλαμβανόμενων κινήσεων, μεγάλων λειτουργιών ή όταν πιέζει ένα αντικείμενο.

Available Functions

1 Επιστρέφει τη θερμοκρασία του κινητήρα DC ως ποσοστό της μέγιστης θερμοκρασίας λειτουργίας.

double temperature(
  percentUnits units = percent );

2 Επιστρέφει τη θερμοκρασία του κινητήρα DC σε μονάδες φυσικής θερμοκρασίας.

double temperature(
  temperatureUnits units );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

units

percentUnits

The unit used to represent DC motor temperature as a percentage:

  • percent / pct (default) — percent

units

temperatureUnits

The unit used to represent DC motor temperature in degrees:

  • celsius — degrees Celsius
  • fahrenheit — degrees Fahrenheit

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

Returns a double representing the DC motor’s temperature in the specified units.

Σημειώσεις

  • The operating temperature range for the motor is approximately 20°C (68°F) to 70°C (158°F).

getMotorType#

Επιστρέφει τον ανιχνευμένο τύπο κινητήρα/ελεγκτή.

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

int32_t getMotorType();

Παράμετροι

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

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

Returns an int32_t indicating the detected motor/controller type:

  • 0 — 11W Motor
  • 1 — 5.5W Motor
  • 2 — Motor Controller 55

installed#

Επιστρέφει εάν ο Ελεγκτής Κινητήρα 55 είναι συνδεδεμένος στον Εγκέφαλο EXP.

Available Functions
bool installed();

Παράμετροι

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

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

Returns a bool indicating if the Motor Controller 55 is connected.

  • true — The Motor Controller 55 is connected.
  • false — The Motor Controller 55 is not connected.