Κινητήρας και Ομάδα Κινητήρων#
Εισαγωγή#
Motors and motor groups control how parts of a robot move. A motor object controls one configured IQ Smart Motor, while a motor_group object controls multiple configured IQ Smart Motors together so they move in tandem. Motors and motor groups can be used to raise an arm, turn a claw, spin a wheel, or move another part of a build. Two motors can work together as a drivetrain to move and turn the whole robot.
Each motor or motor group is configured in the Devices window. Depending on the build, motor and motor group names can change. This page uses Motor1 and MotorGroup1 as example names. Replace them with your own configured names as needed.
By default, forward spins a motor counterclockwise, and reverse spins a motor clockwise. If a motor is set to reverse, those directions will be switched.
Μοτέρ#
Class Constructors#
1 — Creates a
motorobject for the IQ Smart Motor connected to the specified Smart Port. The motor automatically uses the detected internalgearSetting.motor( int32_t index );
2 — Creates a
motorobject on the specified Smart Port and optionally reverses its direction. The motor automatically uses the detected internalgearSetting.motor( int32_t index, bool reverse );
3 — Creates a
motorobject on the specified Smart Port with the specifiedgearSetting.motor( int32_t index, gearSetting gears );
4 — Creates a
motorobject on the specified Smart Port with the specifiedgearSettingand optional reversed direction.motor( int32_t index, gearSetting gears, bool reverse );
Class Destructor#
Destroys the motor object and releases associated resources.
~motor();
Parameters#
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The Smart Port that the motor is connected to, written as |
|
|
Sets whether the motor’s spin direction is reversed:
|
|
|
Specifies the internal gear cartridge ratio.
|
Notes#
Η ρύθμιση του γραναζιού πρέπει να ταιριάζει με το φυσικό φυσίγγιο που είναι εγκατεστημένο στον κινητήρα.
Example#
// Create the motor instance in Smart Port 1
motor LeftMotor = motor(PORT1);
// Creates the motor instance with different settings
motor RightMotor = motor(
PORT2, // Smart Port 2
ratio2_1, // Gear ratio is 2:1
true);
Ομάδα Μηχανοκίνητων#
Class Constructors#
motor_group( motor &m1, Args&... m2 );
Class Destructor#
Destroys the motor_group object and releases associated resources.
~motor_group();
Parameters#
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Ο πρώτος κινητήρας προστέθηκε στην ομάδα. |
|
|
Προστέθηκαν επιπλέον κινητήρες στην ομάδα. Ο μέγιστος αριθμός είναι τέσσερις κινητήρες σε μία ομάδα κινητήρων. |
Example#
// Create individual motor instances
motor LeftMotor = motor(PORT1);
motor RightMotor = motor(PORT2);
// Create a motor group with both motors
motor_group DriveMotors = motor_group(LeftMotor, RightMotor);
Συναρτήσεις Μελών#
There are many ways to code motors and motor groups. Below is a list of all motor and motor_group member functions:
Ενέργειες — Διακοπή και περιστροφή κινητήρων και ομάδων κινητήρων.
spin— Spins a motor or motor group forward or reverse forever.spinFor— Spins a motor or motor group for a specific distance or amount of time.spinToPosition— Spins a motor or motor group to a specific position.stop— Stops a motor or motor group from spinning.
Μεταλλαγμένοι — Προσαρμόστε τις ρυθμίσεις του κινητήρα και της ομάδας κινητήρων.
setVelocity— Tells a motor or motor group how fast to spin.setMaxTorque— Sets how hard a motor or motor group is allowed to push while spinning.setPosition— Changes the motor or motor group’s current position to a new value.setStopping— Sets how a motor or motor group will stop moving: by braking, coasting, or holding.setTimeout— Sets how much time a motor or motor group will try to finish a movement.
Λήπτες — Έλεγχος κατάστασης κινητήρα και ομάδας κινητήρων.
isDone— Returns whether the motor or motor group is finished moving, as a Boolean value.isSpinning— Returns whether the motor or motor group is spinning, as a Boolean value.position— Returns the motor or motor group’s current position.velocity— Returns how fast the motor or motor group is spinning.current— Returns how much electrical current the motor or motor group is using.power— Returns how much power the motor or motor group is using.torque— Returns how much torque the motor or motor group is using.efficiency— Returns how efficiently the motor or motor group is using power.temperature— Returns the temperature of the motor or motor group.voltage— Returns the electrical voltage supplied to the motor or motor group.direction— Returns the direction the motor or motor group is spinning.installed— Returns whether the motor or motor group is connected to the Brain.count— Returns the number of motors in a motor group.
Before calling any motor or motor_group member functions, an instance must be created, as shown below:
/* This constructor is required when using VS Code.
Motor and Motor Group configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */
// Create the motor instance in Smart Port 1
motor Motor1 = motor(PORT1);
Ενέργειες#
spin#
spin spins a motor or motor group forward or reverse forever. The motor or motor group will continue to spin until it is given another action, like spinning in a different direction or stopping.
1 — Περιστρέφει τον κινητήρα ή την ομάδα κινητήρων χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.
void spin( directionType dir );
2 — Περιστρέφει τον κινητήρα ή την ομάδα κινητήρων με την καθορισμένη ταχύτητα.
void spin( directionType dir, double velocity, velocityUnits units );
Parameters3 — Περιστρέφει τον κινητήρα ή την ομάδα κινητήρων χρησιμοποιώντας την καθορισμένη τάση.
void spin( directionType dir, double voltage, voltageUnits units );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The direction the motor or motor group spins: |
|
|
The velocity to spin with from 0% to 100% when using |
|
|
The unit used to represent velocity:
|
|
|
The voltage to spin with. A negative value spins opposite the given |
|
|
The unit used to represent voltage:
|
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesΑυτή η συνάρτηση δεν είναι σε αναμονή και το έργο θα συνεχίσει να εκτελείται αμέσως μετά την κλήση.
The motor or motor group will continue spinning until
stopis called or another movement function is executed.Functions such as
isDoneandisSpinningare not applicable tospin, since it does not use target-based movement (doesn’t have arotationortimeparameter).
// Spin forward, then stop
Motor1.spin(forward);
wait(1, seconds);
Motor1.stop();
spinFor#
spinFor spins a motor or motor group for a specific distance or amount of time. A rotation-based spin is relative to the current position of the motor or motor group. By default, the project will wait until the motor or motor group is done spinning before the next line of code runs.
1 — Περιστρέφεται για μια συγκεκριμένη απόσταση με την ταχύτητα που παρέχεται στην κλήση της συνάρτησης.
bool spinFor( double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion = true );
2 — Δέχεται μια παράμετρο κατεύθυνσης και περιστρέφεται για μια συγκεκριμένη απόσταση με την ταχύτητα που παρέχεται στην κλήση της συνάρτησης.
bool spinFor( directionType dir, double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion = true );
3 — Περιστρέφεται για μια συγκεκριμένη απόσταση χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.
bool spinFor( double rotation, rotationUnits units, bool waitForCompletion = true );
4 — Δέχεται μια παράμετρο κατεύθυνσης και περιστρέφεται για μια συγκεκριμένη απόσταση χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.
bool spinFor( directionType dir, double rotation, rotationUnits units, bool waitForCompletion = true );
5 — Περιστρέφεται για ένα συγκεκριμένο χρονικό διάστημα με την ταχύτητα που παρέχεται στην κλήση της συνάρτησης.
bool spinFor( double time, timeUnits units, double velocity, velocityUnits units_v );
6 — Δέχεται μια παράμετρο κατεύθυνσης και περιστρέφεται για ένα συγκεκριμένο χρονικό διάστημα με την ταχύτητα που παρέχεται στην κλήση της συνάρτησης.
bool spinFor( directionType dir, double time, timeUnits units, double velocity, velocityUnits units_v );
7 — Περιστρέφεται για συγκεκριμένο χρονικό διάστημα χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.
bool spinFor( double time, timeUnits units );
Parameters8 — Δέχεται μια παράμετρο κατεύθυνσης και περιστρέφεται για ένα συγκεκριμένο χρονικό διάστημα χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.
bool spinFor( directionType dir, double time, timeUnits units );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The direction the motor or motor group spins: |
|
|
Η απόσταση που περιστρέφεται ο κινητήρας ή η ομάδα κινητήρων. |
|
|
The rotation unit:
|
|
|
Ο χρόνος που περιστρέφεται ο κινητήρας ή η ομάδα κινητήρων. |
|
|
The unit of time:
|
|
|
The velocity to spin with from 0% to 100% when using |
|
|
The unit used to represent
|
|
|
|
Επιστρέφει μια δυαδική τιμή που δείχνει εάν ο κινητήρας ή η ομάδα κινητήρων έφτασε την τιμή-στόχο.
true— The motor or motor group reached the target value.false— The motor or motor group was not able to reach the target value orwaitForCompletionis set tofalse.
Executing another motor movement function (such as
spinorstop) whilespinForis in progress will interrupt the current movement.Because
spinForis target-based (uses arotationortimeparameter), functions such asisDoneandisSpinningwork withspinFor.
// Spin 1 turn fast, then 1 turn slow
Motor1.spinFor(forward, 1, turns, true);
Motor1.spinFor(reverse, 1, turns, 20, velocityUnits::pct, true);
spinToPosition#
spinToPosition spins a motor or motor group to a specific position.
A motor or motor group’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. At the beginning of a project, the motor or motor group position is set to 0 degrees. The motor or motor group position can also be set using the setPosition function.
Οι τιμές θέσης είναι απόλυτες. Αυτό σημαίνει ότι η κατεύθυνση της περιστροφής εξαρτάται από την τρέχουσα θέση του κινητήρα ή της ομάδας κινητήρων.
Για παράδειγμα, εάν ο κινητήρας ή η ομάδα κινητήρων ξεκινήσει από τις 0 μοίρες και περιστραφεί σε μια θέση 720 μοιρών, θα περιστραφεί προς τα εμπρός κατά δύο στροφές. Εάν στη συνέχεια περιστραφεί σε μια θέση 360 μοιρών, θα περιστραφεί προς τα πίσω κατά μία στροφή, επειδή οι 360 μοίρες είναι μικρότερες από 720 μοίρες.
Available Functions1 — Περιστρέφεται σε μια συγκεκριμένη θέση με την ταχύτητα που παρέχεται στην κλήση της συνάρτησης.
bool spinToPosition( double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion = true );
Parameters2 — Περιστρέφεται σε μια συγκεκριμένη θέση χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.
bool spinToPosition( double rotation, rotationUnits units, bool waitForCompletion = true );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η τιμή θέσης στην οποία θα περιστραφεί ο κινητήρας ή η ομάδα κινητήρων. |
|
|
The rotation unit:
|
|
|
The velocity to spin with from 0% to 100% when using |
|
|
The unit used to represent
|
|
|
|
Επιστρέφει μια δυαδική τιμή που δείχνει εάν ο κινητήρας ή η ομάδα κινητήρων ξεκίνησε την αιτούμενη κίνηση βάσει στόχου.
true— The motor or motor group begins the requested target-based movement.false— The call fails orwaitForCompletionis set tofalse.
Executing another motor movement function (such as
spinorspinFor) whilespinToPositionis in progress will interrupt the current movement.Because
spinToPositionis target-based (uses arotationparameter), functions such asisDoneandisSpinningwork withspinToPosition.
// Spin forward, then go to 90°
Motor1.spin(forward);
wait(1, seconds);
Motor1.spinToPosition(90, degrees);
stop#
stop stops a motor or motor group from spinning.
1 — Διακόπτει τον κινητήρα ή την ομάδα κινητήρων χρησιμοποιώντας την τρέχουσα διαμορφωμένη λειτουργία πέδησης.
void stop();
Parameters2 — Διακόπτει τον κινητήρα ή την ομάδα κινητήρων χρησιμοποιώντας τη λειτουργία πέδησης που παρέχεται στην κλήση συνάρτησης.
void stop( brakeType mode );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Optional. How the motor or motor group will stop:
|
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesCalling
stopimmediately stops any current motor or motor group movement.Εάν δεν έχει καθοριστεί λειτουργία πέδησης, ο κινητήρας ή η ομάδα κινητήρων χρησιμοποιεί την τρέχουσα διαμορφωμένη λειτουργία πέδησης.
stopinterrupts any active target-based movement (such asspinFororspinToPosition).
// Spin and coast to a stop
Motor1.setVelocity(100, percent);
Motor1.spin(forward);
wait(1, seconds);
Motor1.stop(coast);
Μεταλλάκτες#
setVelocity#
setVelocity tells a motor or motor group how fast to spin. A higher percentage makes the motor or motor group spin faster and a lower percentage makes the motor or motor group spin slower.
Κάθε έργο ξεκινά με κάθε κινητήρα ή ομάδα κινητήρων να περιστρέφεται με ταχύτητα 50% από προεπιλογή.
Σημείωση: Μια υψηλότερη ταχύτητα κάνει τον κινητήρα ή την ομάδα κινητήρων να περιστρέφεται πιο γρήγορα, αλλά μπορεί να είναι λιγότερο ακριβής. Μια χαμηλότερη ταχύτητα κάνει τον κινητήρα ή την ομάδα κινητήρων να περιστρέφεται πιο αργά, αλλά μπορεί να είναι πιο ακριβής.
Available Functionsvoid setVelocity(
double velocity,
velocityUnits units );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The velocity to spin with from 0% to 100% when using |
|
|
The unit used to represent
|
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesAny subsequent motor movement function (such as
spin,spinFor, orspinToPosition) that does not explicitly specify a velocity will use this value.
// Try default, then slow, then fast
Motor1.spinFor(forward, 180, degrees);
wait(1, seconds);
Motor1.setVelocity(20, percent);
Motor1.spinFor(reverse, 180, degrees);
wait(1, seconds);
Motor1.setVelocity(100, percent);
Motor1.spinFor(forward, 180, degrees);
setMaxTorque#
Η ροπή δείχνει πόσο δυνατά μπορεί να ωθήσει ή να έλξει ένας κινητήρας ή μια ομάδα κινητήρων ενώ περιστρέφεται.
setMaxTorque sets the most torque a motor or motor group is allowed to use.
Ένα υψηλότερο ποσοστό επιτρέπει στον κινητήρα ή την ομάδα κινητήρων να πιέζει πιο δυνατά, όπως κατά την ανύψωση ενός βαρέος αντικειμένου. Ένα χαμηλότερο ποσοστό περιορίζει την ισχύ που μπορεί να πιέσει ο κινητήρας ή η ομάδα κινητήρων. Αυτό μπορεί να βοηθήσει στην προστασία του ρομπότ εάν ο κινητήρας ή η ομάδα κινητήρων κολλήσει ή φτάσει στο όριο της απόστασης που μπορεί να κινηθεί.
Κάθε έργο ξεκινά με τη ροπή κάθε κινητήρα ή ομάδας κινητήρων στο 50% από προεπιλογή.
Available Functions1 — Ορίζει τη μέγιστη ροπή ως ποσοστό της ονομαστικής ροπής του κινητήρα ή της ομάδας κινητήρων.
void setMaxTorque( double value, percentUnits units );
2 — Ορίζει τη μέγιστη ροπή χρησιμοποιώντας φυσικές μονάδες ροπής.
void setMaxTorque( double value, torqueUnits units );
Parameters3 — Ορίζει τη μέγιστη ροπή περιορίζοντας το ρεύμα του κινητήρα.
void setMaxTorque( double value, currentUnits units );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η μέγιστη ροπή που μπορεί να χρησιμοποιήσει ο κινητήρας ή η ομάδα κινητήρων. |
|
|
Specifies torque as a percentage: |
|
|
Specifies torque in physical units such as:
|
|
|
Specifies torque by limiting motor current:
|
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesWhen using
currentUnits, torque is limited by restricting how much electrical current the motor or motor group can use.
setPosition#
A motor or motor group’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. setPosition changes the motor or motor group’s current position to a new value.
Για παράδειγμα, εάν ένας κινητήρας ή μια ομάδα κινητήρων έχει περιστραφεί στις 180 μοίρες, η ρύθμιση της θέσης σε 0 μοίρες θα επαναφέρει αυτήν τη θέση από 180 σε 0 μοίρες. Στη συνέχεια, ο κινητήρας ή η ομάδα κινητήρων μπορεί να περιστραφεί σε θέσεις με βάση αυτήν τη νέα τιμή.
Available Functionsvoid setPosition(
double value,
rotationUnits units );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η τιμή θέσης που θα οριστεί για τον κινητήρα ή την ομάδα κινητήρων. |
|
|
The position unit:
|
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesAfter calling
setPosition, subsequent calls tospinToPositionwill use the updated position as the reference.
setStopping#
setStopping sets how a motor or motor group will stop moving: by braking, coasting, or holding.
void setStopping(
brakeType mode );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
How the motor or motor group will stop:
|
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesAny subsequent call to
stopwithout a specified brake mode will use this value.
setTimeout#
setTimeout sets how much time a motor or motor group will try to finish a movement. If the motor or motor group cannot finish in that time, it will stop trying and move on to the next line of code. This keeps the motor or motor group from getting stuck on a movement.
void setTimeout(
int32_t time,
timeUnits units );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Ο χρόνος που μπορεί να προσπαθήσει η μηχανή ή η ομάδα κινητών για να ολοκληρώσει μια κίνηση. Πρέπει να είναι θετικός ακέραιος αριθμός. |
|
|
The unit of time:
|
Επιστρεφόμενες τιμές
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
NotesΤο χρονικό όριο του κινητήρα ή της ομάδας κινητήρων χρησιμοποιείται για να εμποδίσει τις κινήσεις που δεν φτάνουν στη θέση-στόχο τους να σταματήσουν την εκτέλεση άλλων εντολών στη στοίβα.
Εάν ο κινητήρας ή η ομάδα κινητήρων δεν φτάσει στη θέση-στόχο του πριν από τη λήξη του χρονικού ορίου, θα σταματήσει την προσπάθεια και θα προχωρήσει στην επόμενη γραμμή κώδικα.
The timeout applies to functions that have a target value such as
spinForandspinToPosition.
// Stop a long move after 1 second
Motor1.setTimeout(1, seconds);
Motor1.spinFor(forward, 2, turns);
Motor1.spinToPosition(0, degrees);
Αποκτητές#
isDone#
isDone returns whether the motor or motor group is finished moving, as a Boolean value. This can be used to control the timing of other behaviors based on the motor or motor group’s movement.
true— The motor or motor group is finished moving.false— The motor or motor group is still moving.
This function works together with the following Motion functions that have the waitForCompletion parameter: spinFor and spinToPosition.
bool isDone();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Return ValuesΕπιστρέφει εάν ο κινητήρας ή η ομάδα κινητήρων έχει ολοκληρώσει την κίνηση, ως λογική τιμή.
true— The motor or motor group is finished moving.false— The motor or motor group is still moving.
isDoneworks together with the following Motion functions that have thewaitForCompletionparameter:spinForandspinToPosition.
// Spin forward until the motor is done spinning
Motor1.spinFor(forward, 200, degrees, false);
while (true) {
if (Motor1.isDone()) {
Drivetrain.stop();
} else {
Drivetrain.drive(forward);
}
}
isSpinning#
isSpinning returns whether the motor or motor group is spinning, as a Boolean value. This can be used to control the timing of other behaviors based on the motor or motor group’s movement.
true— The motor or motor group is spinning.false— The motor or motor group is not spinning.
This function works together with Motion movement functions such as spin, spinFor, and spinToPosition.
bool isSpinning();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Return ValuesΕπιστρέφει εάν ο κινητήρας ή η ομάδα κινητήρων περιστρέφεται, ως λογική τιμή.
true— The motor or motor group is spinning.false— The motor or motor group is not spinning.
isSpinningworks with Motion movement functions such asspin,spinFor, andspinToPosition.
// Spin forward until the motor is done spinning
Motor1.spinFor(forward, 200, degrees, false);
while (true) {
if (Motor1.isSpinning()) {
Drivetrain.drive(forward);
} else {
Drivetrain.stop();
}
}
position#
A motor or motor group’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. position returns the motor or motor group’s current position.
Στην αρχή ενός έργου, η θέση του κινητήρα ή της ομάδας κινητήρων ορίζεται σε 0 μοίρες. Εάν ο κινητήρας ή η ομάδα κινητήρων περιστραφεί μία στροφή προς τα εμπρός, η θέση θα είναι 360 μοίρες ή 1 στροφή. Εάν ο κινητήρας ή η ομάδα κινητήρων περιστραφεί προς την αντίθετη κατεύθυνση, η θέση θα είναι αρνητική.
Available Functionsdouble position(
rotationUnits units );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The unit to return the motor or motor group position in:
|
Returns a double representing the motor or motor group’s current position in the specified units.
Calling
setPositionchanges the reference point for this value.Η επιστρεφόμενη τιμή αντικατοπτρίζει την τρέχουσα ένδειξη του κωδικοποιητή και δεν υποδεικνύει εάν ο κινητήρας ή η ομάδα κινητήρων κινείται ενεργά.
When called on a
motor_group, this function returns the position of the first motor in the group.
// Spin, then show the final position
Motor1.spin(forward);
wait(1, seconds);
Motor1.stop();
Brain.Screen.print("Pos: %f", Motor1.position(degrees));
velocity#
velocity returns how fast the motor or motor group is spinning.
Μια θετική τιμή σημαίνει ότι ο κινητήρας ή η ομάδα κινητήρων περιστρέφεται προς τα εμπρός. Μια αρνητική τιμή σημαίνει ότι περιστρέφεται προς τα πίσω.
Available Functionsdouble velocity(
velocityUnits units );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The unit used to represent velocity:
|
Returns a double representing how fast the motor or motor group is spinning in the specified units.
Σημειώσεις
When called on a
motor_group, this function returns the velocity of the first motor in the group.
current#
current returns how much electrical current the motor or motor group is using. Current is the amount of electricity flowing through the motor or motor group. When returned in amps, current is reported from 0.0 to 1.2 A.
Μια υψηλότερη τιμή ρεύματος σημαίνει ότι ο κινητήρας ή η ομάδα κινητήρων χρησιμοποιεί περισσότερο ηλεκτρικό ρεύμα. Αυτό μπορεί να συμβεί όταν ο κινητήρας ή η ομάδα κινητήρων σηκώνει κάτι βαρύ, πιέζει ένα αντικείμενο ή προσπαθεί να κινηθεί όταν αυτό έχει κολλήσει.
Αυτό μπορεί να χρησιμοποιηθεί για να ελεγχθεί εάν ο κινητήρας ή η ομάδα κινητήρων παρουσιάζει δυσκολίες κατά τη διάρκεια μιας κίνησης. Εάν το ρεύμα παραμείνει υψηλό, ο κινητήρας μπορεί να θερμανθεί ή να χρησιμοποιήσει την ισχύ λιγότερο αποτελεσματικά.
Available Functions1 — Επιστρέφει το ηλεκτρικό ρεύμα του κινητήρα ή της ομάδας κινητήρων σε αμπέρ.
double current( currentUnits units = amp );
Parameters2 — Επιστρέφει το ηλεκτρικό ρεύμα του κινητήρα ή της ομάδας κινητήρων ως ποσοστό του μέγιστου ονομαστικού ρεύματος.
double current( percentUnits units );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The unit used to represent current: |
|
|
Represents the current as a percentage of the motor’s maximum rated current: |
Returns a double representing how much electrical current the motor or motor group is drawing in the specified units.
Σημειώσεις
When called on a
motor_group, this function returns the total electrical current for all motors in the group.
power#
power returns how much power the motor or motor group is using in watts. Power shows how quickly the motor or motor group is using energy.
Μια υψηλότερη τιμή ισχύος σημαίνει ότι ο κινητήρας ή η ομάδα κινητήρων χρησιμοποιεί ενέργεια πιο γρήγορα. Αυτό μπορεί να συμβεί όταν ο κινητήρας ή η ομάδα κινητήρων σηκώνει κάτι βαρύ, πιέζει ένα αντικείμενο ή προσπαθεί να κινηθεί όταν αυτό έχει κολλήσει.
Αυτό μπορεί να χρησιμοποιηθεί για τη σύγκριση κινήσεων ή για τον έλεγχο αν ο κινητήρας ή η ομάδα κινητήρων αντιμετωπίζει δυσκολίες. Εάν η ισχύς παραμείνει υψηλή, ο κινητήρας μπορεί να θερμανθεί ή να χρησιμοποιήσει την ενέργεια λιγότερο αποτελεσματικά.
Available Functionsdouble power(
powerUnits units = watt );
Παράμετροι
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The unit used to represent the motor power:
|
Επιστρεφόμενες τιμές
Returns a double representing how much power the motor or motor group is using in watts.
Σημειώσεις
When called on a
motor_group, this function returns the electrical power of the first motor in the group.
torque#
Η ροπή δείχνει πόσο δυνατά περιστρέφεται, σπρώχνει ή τραβάει ένας κινητήρας ή μια ομάδα κινητήρων ενώ περιστρέφεται.
torque returns how much torque the motor or motor group is using.
Μια υψηλότερη τιμή ροπής σημαίνει ότι ο κινητήρας ή η ομάδα κινητήρων πιέζει ή τραβάει πιο δυνατά. Αυτό μπορεί να συμβεί όταν ο κινητήρας ή η ομάδα κινητήρων σηκώνει κάτι βαρύ, πιέζει ένα αντικείμενο ή προσπαθεί να κινηθεί όταν αυτό έχει κολλήσει.
Αυτό μπορεί να χρησιμοποιηθεί για να ελέγξετε αν ο κινητήρας ή η ομάδα κινητήρων δυσκολεύεται ή για να συγκρίνετε πόση ώθηση χρειάζονται οι διαφορετικές κινήσεις.
To set the torque of a motor or motor group, use setMaxTorque.
double torque(
torqueUnits units = Nm );
Παράμετροι
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The unit used to represent the motor torque:
|
Επιστρεφόμενες τιμές
Returns a double representing how much torque the motor or motor group is using in the specified units.
Σημειώσεις
When called on a
motor_group, this function returns the mechanical output torque of the first motor in the group.
efficiency#
efficiency returns how efficiently the motor or motor group is using power, as a percentage from 0% to 100%.
Η απόδοση δείχνει πόση από την ισχύ του κινητήρα ή της ομάδας κινητήρων χρησιμοποιείται για κίνηση. Μια υψηλότερη τιμή απόδοσης σημαίνει ότι περισσότερη από την ισχύ του κινητήρα ή της ομάδας κινητήρων χρησιμοποιείται για κίνηση. Μια χαμηλότερη τιμή απόδοσης μπορεί να συμβεί όταν ο κινητήρας ή η ομάδα κινητήρων εργάζεται σκληρά αλλά δεν κινείται πολύ, όπως όταν έχει κολλήσει ή πιέζει ένα αντικείμενο.
Αυτό μπορεί να χρησιμοποιηθεί για τη σύγκριση κινήσεων ή για τον έλεγχο εάν ο κινητήρας ή η ομάδα κινητήρων σπαταλά ενέργεια αντί να τη χρησιμοποιεί για κίνηση.
Available Functionsdouble efficiency(
percentUnits units = percent );
Παράμετροι
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The unit used to represent motor efficiency:
|
Επιστρεφόμενες τιμές
Returns a double representing how efficiently the motor or motor group is using power as a percentage.
Σημειώσεις
When called on a
motor_group, this function returns the efficiency of the first motor in the group.
temperature#
temperature returns the temperature of the motor or motor group.
Motor temperature shows how warm the motor or motor group is. A higher temperature means the motor or motor group is getting warmer while it works. The motor should stay below 55°C to keep working at full performance.
If the motor or motor group gets too hot, it will lower its maximum current to protect itself. At 70°C, a motor will stop running until it cools down.
Αυτό μπορεί να χρησιμοποιηθεί για να ελέγξετε εάν ο κινητήρας ή η ομάδα κινητήρων υπερθερμαίνεται κατά τη διάρκεια επαναλαμβανόμενων κινήσεων, μεγάλων διαδρομών ή όταν πιέζει ένα αντικείμενο.
Available Functions1 — Επιστρέφει τη θερμοκρασία του κινητήρα ή της ομάδας κινητήρων ως ποσοστό της μέγιστης θερμοκρασίας λειτουργίας.
double temperature( percentUnits units = percent );
2 — Επιστρέφει τη θερμοκρασία του κινητήρα ή της ομάδας κινητήρων σε φυσικές μονάδες θερμοκρασίας.
double temperature( temperatureUnits units );
Παράμετροι
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The unit used to represent motor or motor group temperature as a percentage:
|
|
|
The unit used to represent motor or motor group temperature in degrees:
|
Επιστρεφόμενες τιμές
Returns a double representing the temperature of the motor or motor group in the specified units.
Σημειώσεις
The operating temperature range for the motor is approximately
20°C(68°F) to70°C(158°F).When called on a
motor_group, this function returns the temperature of the first motor in the group.
voltage#
voltage returns the electrical voltage supplied to the motor or motor group.
double voltage(
voltageUnits units = volt );
Παράμετροι
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The unit to represent the voltage:
|
Επιστρεφόμενες τιμές
Returns a double representing the electrical voltage supplied to the motor or motor group in the specified units.
Σημειώσεις
When called on a
motor_group, this function returns the electrical voltage of the first motor in the group.
direction#
direction returns the direction that the motor or motor group is spinning.
directionType direction();
Παράμετροι
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Επιστρεφόμενες τιμές
Returns a directionType indicating the motor’s or motor group’s current direction:
forward— The motor or motor group is spinning forward.reverse— The motor or motor group is spinning in reverse.
installed#
installed returns whether the motor or motor group is connected to the IQ (2nd gen) Brain.
bool installed();
Παράμετροι
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Επιστρεφόμενες τιμές
Returns a bool indicating whether the motor or motor group is connected.
true— The motor or motor group is connected.false— The motor or motor group is not connected.
count#
count returns the number of motors in a motor group.
int32_t count();
Παράμετροι
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Επιστρεφόμενες τιμές
Returns an int32_t representing the number of motors in the motor group.