Motores y grupos de motores#
Introducción#
Motors and motor groups control how parts of a robot move. A motor controls one configured Smart Motor, while a motor group controls two configured 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 is configured in the Devices window. Depending on the build, the names of the motors and directions can change. A custom robot may use different motor names or directions.
By default, forward spins a motor counterclockwise, and reverse spins a motor clockwise. If a motor is set to reverse in the Devices window, those directions will be switched.
There are many ways to code motors and motor groups. Below is a list of all Motors and Motor Groups blocks:
Actions — Stop and spin motors and motor groups.
spin motor — Spins a motor or motor group forward or reverse forever.
spin motor for — Spins a motor or motor group for a specific distance.
spin motor to position — Spins a motor or motor group to a specific position.
stop motor — Stops a motor or motor group from spinning.
Settings — Adjust motor and motor group settings.
set motor position — Changes the motor or motor group’s current position to a new value.
set motor velocity — Tells a motor or motor group how fast to spin.
set motor stopping — Sets how a motor or motor group will stop moving: by braking, coasting, or holding.
set motor max torque — Sets how hard a motor or motor group is allowed to push while spinning.
set motor timeout — Sets how many seconds a motor or motor group will try to finish a movement.
Values — Check motor and motor group status.
motor is done — Reports whether the motor or motor group is finished moving.
motor is spinning — Reports whether the motor or motor group is spinning.
motor position — Reports the motor or motor group’s current position.
motor velocity — Reports how fast the motor or motor group is spinning.
motor current — Reports how much electrical current the motor or motor group is using.
Comportamiento#
motor de giro#
The spin motor stack block 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.
girar [Motor 1 v] [adelante v]
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to spin. Choose from the motors configured in the Devices window. |
dirección |
The direction the motor or motor group spins. By default, the choices are forward and reverse. Direction choices can change depending on the motor’s configuration. |
Ejemplo
cuando empezó
[Spin the motor forward, then stop.]
girar [Motor 1 v] [adelante v]
esperar (1) segundos
parada [Motor 1 v]
motor de giro para#
The spin motor for stack block spins a motor or motor group for a specific distance. The spin is relative to the current position of the motor or motor group. The project will wait until the motor or motor group is done spinning before the next block in the stack runs.
girar [Motor 1 v] [adelante v] por (90) [grados v] ▶
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to spin. Choose from the motors configured in the Devices window. |
dirección |
The direction the motor or motor group spins. By default, the choices are forward and reverse. Direction choices can change depending on the motor’s configuration. |
distancia |
The distance the motor or motor group spins. Degrees use integers. Turns can use integers or decimals. |
unidad |
The distance unit: degrees or turns. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Ejemplo
cuando empezó
[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] ▶
motor de giro para posicionar#
The spin motor to position stack block 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 position is set to 0 degrees. The motor position can also be set using the set motor position block.
Position values are absolute. This means the direction of the spin depends on the motor or motor group’s current position.
girar [Motor 1 v] a la posición (90) [grados v] ▶
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to spin. Choose from the motors configured in the Devices window. |
posición |
The position value the motor or motor group will spin to. Degrees use integers. Turns can use integers or decimals. |
unidad |
The position unit: degrees or turns. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Ejemplo
cuando empezó
[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] ▶
detener el motor#
The stop motor stack block immediately stops the selected motor or motor group.
parada [Motor 1 v]
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to stop. Choose from the motors configured in the Devices window. |
Ejemplo
cuando empezó
[Stop the motor after 1 second.]
girar [Motor 1 v] [adelante v]
esperar (1) segundos
parada [Motor 1 v]
Ajustes#
establecer la posición del motor#
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. The set motor position stack block changes the motor or motor group’s current position to a new value.
For example, if a motor has spun to 180 degrees, setting the position to 0 degrees will reset that position from 180 to 0 degrees. Then the motor can spin to positions based on that new value.
Establezca la posición [Motor 1 v] en (0) [grados v]
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to set the position of. Choose from the motors configured in the Devices window. |
posición |
The position value to set for the motor or motor group. Degrees use integers. Turns can use integers or decimals. |
unidad |
The position unit: degrees or turns. |
Ejemplo
cuando empezó
[Spin the motor to the new 0 position.]
Establezca la posición [Motor 1 v] en [180] [grados v]
girar [Motor 1 v] a la posición [0] [grados v] ▶
establecer la velocidad del motor#
The set motor velocity stack block 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.
Every project begins with each motor spinning at 50% velocity by default.
Note: A higher velocity makes the motor spin faster, but it may be less precise. A lower velocity makes the motor spin slower, but it can be more precise.
Establezca la velocidad [Motor 1 v] en (50) [% v]
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to set the velocity of. Choose from the motors configured in the Devices window. |
velocidad |
The speed the motor or motor group will spin at. Percent uses integers from 0% to 100%. RPM uses integers from 0 to 127. |
unidad |
The velocity unit: % or rpm (revolutions per minute). |
Ejemplo
cuando empezó
[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] ▶
configurar la parada del motor#
The set motor stopping stack block sets how a motor or motor group will stop moving: by braking, coasting, or holding.
establecer [Motor 1 v] deteniéndose en [freno v]
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to set the stopping behavior of. Choose from the motors configured in the Devices window. |
comportamiento de detención |
How the motor or motor group will stop:
|
If this block is not used, the motor will use brake when stopping.
establecer el par máximo del motor#
Torque is a turning force. It shows how hard a motor can push or pull when it spins.
The set motor max torque stack block sets the most torque a motor or motor group is allowed to use.
A higher percentage lets the motor or motor group push harder, like when lifting a heavy object. A lower percentage limits how hard the motor or motor group can push. This can help protect the robot if the motor gets stuck or reaches the end of how far it can move.
Every project begins with each motor’s torque at 50% by default.
Establezca el par [Motor 1 v] en [50]%
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to set the max torque of. Choose from the motors configured in the Devices window. |
esfuerzo de torsión |
The max torque the motor or motor group can use from 0% to 100%. |
Ejemplo
cuando empezó
[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.]
set [Motor1 v] max torque to (20)%
girar [Motor 1 v] a la posición (0) [grados v] ▶
esperar (0.5) segundos
[Spin at the maximum torque.]
set [Motor1 v] max torque to (100)%
girar [Motor 1 v] a la posición (200) [grados v] ▶
establecer el tiempo de espera del motor#
The set motor timeout stack block sets how many seconds 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 block in the stack. This keeps the motor or motor group from getting stuck on a movement.
Establezca el tiempo de espera [Motor 1 v] en (1) segundo
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to set the timeout of. Choose from the motors configured in the Devices window. |
tiempo |
The number of seconds the motor or motor group can try to finish a movement. This can be a whole number or a decimal. |
Ejemplo
cuando empezó
[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] ▶
Valores#
motor is done#
The motor is done Boolean block reports whether the motor or motor group is finished moving. 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 block works together with the following Motion blocks that have the and don’t wait parameter: spin motor for and spin motor to position.
<[Motor 1 v] ¿está hecho?>
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to report whether it is finished moving. Choose from the motors configured in the Devices window. |
Ejemplo
cuando empezó
[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 Boolean block reports whether the motor or motor group is spinning. 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 block works together with the following Motion blocks that have the and don’t wait parameter: spin motor for and spin motor to position.
<[Motor 1 v] esta girando?>
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to report whether it is spinning. Choose from the motors configured in the Devices window. |
Ejemplo
cuando empezó
[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
posición del motor#
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. The motor position reporter block reports the motor or motor group’s current position.
At the beginning of a project, the motor position is set to 0 degrees. If the motor spins one full turn forward, the position will be 360 degrees or 1 turn. If the motor spins the other direction, the position will be negative.
([Motor 1 v] posición en [grados v])
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to report the position of. Choose from the motors configured in the Devices window. |
unidad |
The unit to report the motor position in: degrees or turns. |
Ejemplo
cuando empezó
[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]
velocidad del motor#
The motor velocity reporter block reports how fast the motor or motor group is spinning, as a percentage from -100% to 100% or as revolutions per minute (rpm) from -127 to 127.
([Motor 1 v] velocidad en [% v])
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to report the velocity of. Choose from the motors configured in the Devices window. |
unidad |
The unit to report the motor velocity in: % or rpm (revolutions per minute). |
Ejemplo
cuando empezó
[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]
corriente del motor#
The motor current reporter block reports how much electrical current the selected motor or motor group is using, measured in amps from 0.0 to 1.2 A. Current is the amount of electricity flowing through the motor or motor group.
A higher current value means the motor or motor group is using more electrical current. This can happen when the motor or motor group is lifting something heavy, pushing against an object, or trying to move when it is stuck.
This can be used to check if the motor or motor group is struggling during a movement. If current stays high, the motor may get warmer or use power less efficiently.
([Motor 1 v] corriente en [amps v])
Parámetros |
Descripción |
|---|---|
motor |
The motor or motor group to report the current of. Choose from the motors configured in the Devices window. |
unidad |
The unit to report current in: amps. |
Ejemplo
cuando empezó
[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]