Motors#
Introduction#
The Motion category includes blocks that control motors and motor groups in a VEX IQ (2nd generation) robot. These blocks let you spin motors forward or in reverse, move to specific positions, set and read encoder values, adjust speed, torque, or timeout settings.
Below is a list of available blocks:
Actions – Spin motors continuously, to a position, or stop them.
spin – Spins the selected motor or motor group indefinitely.
spin for – Spins a motor or group for a specific distance in degrees or turns.
spin to position – Spins a motor or group to a set position.
stop motor – Stops a specific motor or group from spinning.
Settings – Configure motor speed, position, stopping mode, torque, and timeouts.
set motor velocity – Sets the speed of a motor or motor group as a percentage.
set motor position – Sets the encoder value of a motor or motor group.
set motor stopping – Sets the stop behavior (brake, coast, or hold).
set motor max torque – Limits the maximum torque the motor can apply.
set motor timeout – Limits how long a motor block waits before giving up if movement is blocked.
Values – Read motor motion status, position, velocity, and current draw.
motor is done? – Returns a Boolean indicating whether the motor is no longer spinning.
motor is spinning? – Returns a Boolean indicating whether the motor is currently spinning.
motor position – Returns the motor’s current rotational position in degrees or turns.
motor velocity – Returns the motor’s current velocity in % or rpm.
motor current – Returns the current (in amps) drawn by the motor.
Actions#
spin#
The spin block spins a selected motor or motor group in a specified direction using the current motor velocity.
girar [Motor 1 v] [adelante v]
Parameters |
Description |
---|---|
motor |
The motor or motor group to spin, configured in the Devices window. |
direction |
The direction to spin, configured in the Devices window. By default this is:
|
Example
cuando empezó :: hat events
[Spin the motor forward, then stop.]
girar [Motor 1 v] [adelante v]
esperar (1) segundos
parada [Motor 1 v]
spin for#
The spin for block spins a selected motor or motor group for a specific amount of rotation using the current motor velocity, measured in degrees or turns.
girar [Motor 1 v] [adelante v] por (90) [grados v] ▶
Parameters |
Description |
---|---|
motor |
The motor or motor group to spin, configured in the Devices window. |
direction |
The direction to spin, configured in the Devices window. By default this is:
|
distance |
The rotation amount, as an integer or decimal. |
unit |
The measurement unit, which can be one of the following:
|
expanding arrow |
By default, this is a waiting block, so the drivetrain will finish moving before running the next block. To make the drivetrain start moving and immediately run the next block right away, expand the block to say and don’t wait. |
Example
cuando empezó :: hat events
[Spin the motor forward once, then reset.]
girar [Motor 1 v] [adelante v] por (90) [grados v] ▶
girar [Motor 1 v] [atrás v] por (90) [grados v] ▶
spin to position#
The spin to position block spins a motor or motor group to a specific absolute position using the current motor velocity and motor position.
girar [Motor 1 v] a la posición (90) [grados v] ▶
Parameters |
Description |
---|---|
motor |
The motor or motor group to spin, configured in the Devices window. |
position |
The target position to spin the motor or motor group to. |
unit |
The measurement unit, which can be one of the following:
|
expanding arrow |
By default, this is a waiting block, so the drivetrain will finish moving before running the next block. To make the drivetrain start moving and immediately run the next block right away, expand the block to say and don’t wait. |
Example
cuando empezó :: hat events
[Spin the motor, then put the motor at half of a rotation.]
girar [Motor 1 v] [adelante v]
esperar (2) segundos
girar [Motor 1 v] a la posición (180) [grados v] ▶
stop motor#
The stop motor block immediately stops the selected motor or motor group.
parada [Motor 1 v]
Parameters |
Description |
---|---|
motor |
The motor or motor group to stop, configured in the Devices window. |
Example
cuando empezó :: hat events
[Stop the motor after 1 second.]
girar [Motor 1 v] [adelante v]
esperar (1) segundos
parada [Motor 1 v]
Settings#
set motor position#
The set motor position block sets a specific position value to a motor or motor group, which updates the encoder reading.
Establezca la posición [Motor 1 v] en (0) [grados v]
Parameters |
Description |
---|---|
motor |
The motor or motor group to set the position of, configured in the Devices window. |
position |
The encoder position value to set. |
unit |
The measurement unit, which can be one of the following:
|
Example
cuando empezó :: hat events
[Spin the motor in reverse.]
Establezca la posición [Motor 1 v] en (180) [grados v]
girar [Motor 1 v] a la posición (0) [grados v] ▶
set motor velocity#
The set motor velocity block sets the default spinning speed of a motor or motor group as a percentage for all subsequent Motor blocks in the project.
Establezca la velocidad [Motor 1 v] en (50) [% v]
Parameters |
Description |
---|---|
motor |
The motor or motor group to set the velocity of, configured in the Devices window. |
velocity |
Sets the default movement velocity from 0 to 100 as a percent. |
unit |
The measurement unit, which can be one of the following:
|
Example
cuando empezó :: hat events
[Spin forward at the default velocity.]
girar [Motor 1 v] [adelante v] por (90) [giros v] ▶
[Spin slower.]
Establezca la velocidad [Motor 1 v] en (20) [% v]
girar [Motor 1 v] [atrás v] por (90) [giros v] ▶
[Spin faster.]
Establezca la velocidad [Motor 1 v] en (100) [% v]
girar [Motor 1 v] [adelante v] por (90) [giros v] ▶
set motor stopping#
The set motor stopping block sets how a motor or motor group behaves when it stops.
establecer [Motor 1 v] deteniéndose en [freno v]
Parameters |
Description |
---|---|
motor |
The motor or motor group to set the stopping behavior of, configured in the Devices window. |
stopping behavior |
Sets how the drivetrain stops, which can be one of the following:
|
Example
cuando empezó :: hat events
[Spin the motor, then coast to a stop.]
Establezca la velocidad [Motor 1 v] en (100) [% v]
establecer [Motor 1 v] deteniéndose en [libre v]
girar [Motor 1 v] [adelante v]
esperar (2) segundos
parada [Motor 1 v]
set motor max torque#
The set motor max torque block sets how much force a motor or motor group can exert.
Establezca el par [Motor 1 v] en (50)%
Parameters |
Description |
---|---|
motor |
The motor or motor group to set the max torque of, configured in the Devices window. |
torque |
The maximum torque allowed, from 0 to 100 as a percent. |
Example
cuando empezó :: hat events
[Spin the motor at the default torque.]
girar [Motor 1 v] a la posición (200) [grados v] ▶
esperar (0.5) segundos
[Spin at a lower torque.]
Establezca el par [Motor 1 v] en (20)%
girar [Motor 1 v] a la posición (0) [grados v] ▶
esperar (0.5) segundos
[Spin at the maximum torque.]
Establezca el par [Motor 1 v] en (100)%
girar [Motor 1 v] a la posición (200) [grados v] ▶
set motor timeout#
The set motor timeout block sets a time limit for how long a Motor block will wait to reach its target. If the robot cannot complete the movement within the set time, it will stop automatically and continue with the next block.
Note: The Motor’s time limit is used to prevent Motor blocks that do not reach their target position from stopping the execution of other blocks in the stack.
Establezca el tiempo de espera [Motor 1 v] en (1) segundo
Parameters |
Description |
---|---|
motor |
The motor or motor group to set the timeout of, configured in the Devices window. |
time |
The maximum number of seconds a Motor block will run before stopping and moving to the next block. |
Example
cuando empezó :: hat events
[Spin the motor forward for 1 second, then reset it.]
Establezca el tiempo de espera [Motor 1 v] en (1) segundo
girar [Motor 1 v] [adelante v] por (5) [giros v] ▶
girar [Motor 1 v] a la posición (0) [grados v] ▶
Values#
motor is done?#
The motor is done? block returns a Boolean indicating whether the motor is not spinning.
True - The motor is not spinning.
False - The motor is spinning.
<[Motor 1 v] ¿está hecho?>
Parameters |
Description |
---|---|
motor |
The motor or motor group to check, configured in the Devices window. |
Example
cuando empezó :: hat events
[Drive forward until the motor is done spinning.]
girar [Motor 1 v] [adelante v] por (200) [grados v] ◀ y no esperes
para siempre
si <[Motor 1 v] ¿está hecho?> entonces
deja de conducir
demás
unidad [adelante v]
motor is spinning?#
The motor is spinning? block returns a Boolean indicating whether the motor is spinning.
True - The motor is spinning.
False - The motor is not spinning.
<[Motor 1 v] esta girando?>
Parameters |
Description |
---|---|
motor |
The motor or motor group to check, configured in the Devices window. |
Example
cuando empezó :: hat events
[Move forward while the motor is spinning.]
girar [Motor 1 v] [adelante v] por (200) [grados v] ◀ y no esperes
mientras <[Motor 1 v] esta girando?>
unidad [adelante v]
fin
deja de conducir
motor position#
The motor position block returns the total distance the selected motor or motor group has rotated.
([Motor 1 v] posición en [grados v])
Parameters |
Description |
---|---|
motor |
The motor or motor group to check, configured in the Devices window. |
unit |
The unit of measurement, which can be one of the following:
|
Example
cuando empezó :: hat events
[Display the motor's position after spinning.]
imprimir ([Motor 1 v] posición en [grados v]) en [Brain v] ◀ y coloque el cursor en la siguiente fila
girar [Motor 1 v] [adelante v]
esperar (1) segundos
imprimir ([Motor 1 v] posición en [grados v]) en [Brain v] ▶
parada [Motor 1 v]
motor velocity#
The motor velocity block returns the current rotational speed of the motor or motor group in a range from -100% to 100% or -127 rpm to 127 rpm.
([Motor 1 v] velocidad en [% v])
Parameters |
Description |
---|---|
motor |
The motor or motor group to check, configured in the Devices window. |
unit |
The unit of measurement, which can be one of the following:
|
Example
cuando empezó :: hat events
[Display the motor's velocity from spinning.]
imprimir ([Motor 1 v] velocidad en [rpm v]) en [Brain v] ◀ y coloque el cursor en la siguiente fila
girar [Motor 1 v] [adelante v]
esperar (1) segundos
imprimir ([Motor 1 v] velocidad en [rpm v]) en [Brain v] ▶
parada [Motor 1 v]
motor current#
The motor current block returns the amount of electrical current the motor or motor group in a range from 0.0 to 1.2 amps (amperes).
([Motor 1 v] corriente en [amps v])
Parameters |
Description |
---|---|
motor |
The motor or motor group to check, configured in the Devices window. |
Example
cuando empezó :: hat events
[Display the motor's current from spinning.]
Establezca la precisión de impresión en [0.01 v] sobre [Brain v]
imprimir ([Motor 1 v] corriente en [amps v]) en [Brain v] ◀ y coloque el cursor en la siguiente fila
girar [Motor 1 v] [adelante v]
esperar (1) segundos
imprimir ([Motor 1 v] corriente en [amps v]) en [Brain v] ▶
parada [Motor 1 v]