Σερβοκινητήρας#

Εισαγωγή#

The servo class is used to control and configure an EXP 3-Wire Servo Motor. The EXP 3-Wire Servo Motor provides position-based control within a fixed range of motion.

Ο σερβοκινητήρας EDR VEX

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

servo( triport::port& port );

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

Destroys the servo object and releases associated resources.

~servo();

Παράμετροι#

Παράμετρος

Τύπος

Περιγραφή

port

triport::port&

The 3-Wire Port that the Servo 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).

Παράδειγμα#

// Create the servo instance on 3-Wire Port A
servo myServo = servo(Brain.ThreeWirePort.A);

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

The servo class includes the following member functions:

  • setPosition — Moves the servo motor to a specified position.

Before calling any servo member functions, a servo instance must be created, as shown below:

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

// Create the servo instance on 3-Wire Port A
servo myServo = servo(Brain.ThreeWirePort.A);

setPosition#

Μετακινεί τον σερβοκινητήρα σε μια καθορισμένη θέση.

Ένα διάγραμμα ενός σερβοκινητήρα που δείχνει τις μοίρες που μπορεί να περιστραφεί, από 100 έως 0 μοίρες.

Available Functions

1 Ορίζει τη θέση του σερβοκινητήρα χρησιμοποιώντας μια ποσοστιαία τιμή.

void setPosition(
 int32_t value,
 percentUnits units );

2 Ορίζει τη θέση του σερβοκινητήρα χρησιμοποιώντας μονάδες περιστροφής.

void setPosition(
 double value,
 rotationUnits units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

value

int32_t

Η τιμή θέσης του σερβοκινητήρα κατά τη χρήση ποσοστιαίων μονάδων.

value

double

Η τιμή θέσης του σερβοκινητήρα κατά τη χρήση μονάδων περιστροφής.

units

percentUnits

The position unit: percent / pct — percent

units

rotationUnits

The position unit:

  • deg / degrees — degrees
  • turns / rev — revolutions

Return Values

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

Notes
  • Όταν χρησιμοποιούνται ποσοστιαίες μονάδες, το έγκυρο εύρος είναι 0 – 100%.

  • Ένας σερβοκινητήρας ξεκινά κάθε έργο κεντραριζόμενος αυτόματα στις 50 μοίρες πριν ολοκληρώσει οποιεσδήποτε κινήσεις.

  • Όταν χρησιμοποιείτε μονάδες περιστροφής, ο σερβοκινητήρας θα μετακινηθεί στην καθορισμένη απόλυτη θέση.

Examples
// Set the servo position to 10 percent
myServo.setPosition(10, percent);

// Set the servo position to 45.5 degrees
myServo.setPosition(45.5, degrees);

// Set the servo position to 90 degrees
myServo.setPosition(90, degrees);