Servomotor#
Introducción#
The servo class is used to control and configure a V5 3-Wire Servo Motor. The V5 3-Wire Servo Motor provides position-based control within a fixed range of motion.
Constructores de clases#
servo( triport::port& port );
Instructor de clase#
Destroys the servo object and releases associated resources.
~servo();
Parámetros#
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The 3-Wire Port that the Servo Motor is connected to, written as |
Notas#
A Brain or 3-Wire Expander must be created first before they can be used to create an object with the
servoclass constructor.
Ejemplo#
// Create the servo instance on 3-Wire Port A
servo myServo = servo(Brain.ThreeWirePort.A);
Funciones de los miembros#
The servo class includes the following member functions:
setPosition— Sets the position of the servo motor.
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#
Establece la posición del servomotor a un valor específico.
Available Functions1 — Establece la posición del servo utilizando un valor porcentual.
void setPosition( int32_t value, percentUnits units );
Parameters2 — Establece la posición del servo utilizando unidades de rotación.
void setPosition( double value, rotationUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
Un valor entero para la posición del servomotor cuando se utilizan unidades porcentuales. |
|
|
Se utiliza un valor doble para la posición del servomotor cuando se emplean unidades de rotación. |
|
|
The unit used to represent position as percentage:
|
|
|
The unit used to represent
|
Esta función no devuelve ningún valor.
NotesAl utilizar unidades porcentuales, el rango válido es de 0 a 100%.
Al utilizar unidades de rotación, el servomotor se moverá a la posición absoluta especificada.
// 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);