Motors and Motor Groups#

Introduction#

Motor and Motor Group blocks can spin a motor forward or in reverse, move it to a specific position, and adjust its speed, torque, and timeout settings. They can also report encoder values to track movement and position.

Below is a list of all 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.

  • 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.

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.

  • motor velocity — Returns the motor’s current velocity.

  • motor current — Returns the current 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.

[Motor 1 v] [向前 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:

  • forward — counterclockwise
  • reverse — clockwise

Example

当开始
[Spin the motor forward, then stop.]
[Motor 1 v] [向前 v] 转
等待 (1) 秒
[Motor 1 v] 停止

spin for#

The spin for block spins a motor or motor group for a specific amount of rotation using the current motor velocity, measured in degrees or turns.

[Motor 1 v] [向前 v] 转 (90) [度 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:

  • forward — counterclockwise
  • reverse — clockwise

distance

The rotation amount, as an integer or decimal.

unit

The unit of measurement:

  • degrees
  • turns

expanding arrow

By default, this is a waiting block, so the motor will finish moving before running the next block. To make the motor start moving and immediately run the next block right away, expand the block to say and don’t wait.

Example

当开始
[Spin the motor forward once, then reset.]
[Motor 1 v] [向前 v] 转 (90) [度 v] ▶
[Motor 1 v] [反 v] 转 (90) [度 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.

[Motor 1 v] 转至 (90) [度 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 unit of measurement:

  • degrees
  • turns

expanding arrow

By default, this is a waiting block, so the motor will finish moving before running the next block. To make the motor start moving and immediately run the next block right away, expand the block to say and don’t wait.

Example

当开始
[Spin the motor, then put the motor at half of a rotation.]
[Motor 1 v] [向前 v] 转
等待 (2) 秒
[Motor 1 v] 转至 (180) [度 v] ▶

stop motor#

The stop motor block immediately stops the selected motor or motor group.

[Motor 1 v] 停止

Parameters

Description

motor

The motor or motor group to stop, configured in the Devices window.

Example

当开始
[Stop the motor after 1 second.]
[Motor 1 v] [向前 v] 转
等待 (1) 秒
[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.

设定 [Motor 1 v] 转位至 (0) [度 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 unit of measurement:

  • degrees
  • turns

Example

当开始
[Spin the motor to the new 0 position.]
设定 [Motor 1 v] 转位至 [180] [度 v]
[Motor 1 v] 转至 [0] [度 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.

设定 [Motor 1 v] 转速为 (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%.

unit

The unit of measurement:

  • %
  • rpm — rotations per minute

Example

当开始
[Spin forward at the default velocity.]
[Motor 1 v] [向前 v] 转 (90) [转 v] ▶
[Spin slower.]
设定 [Motor 1 v] 转速为 (20) [% v]
[Motor 1 v] [反 v] 转 (90) [转 v] ▶
[Spin faster.]
设定 [Motor 1 v] 转速为 (100) [% v]
[Motor 1 v] [向前 v] 转 (90) [转 v] ▶

set motor stopping#

The set motor stopping block sets how a motor or motor group behaves when it stops.

设定 [Motor 1 v] 停止模式为 [刹车 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:

  • brake — Stops immediately.
  • coast — Slows gradually to a stop.
  • hold — Stops and resists movement using motor feedback.

set motor max torque#

The set motor max torque block sets how much force a motor or motor group can exert.

设定 [Motor 1 v] 最大扭矩为 [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%.

Example

当开始
[Spin the motor at the default torque.]
[Motor 1 v] 转至 (200) [度 v] ▶
等待 (0.5) 秒
[Spin at a lower torque.]
set [Motor1 v] max torque to (20)%
[Motor 1 v] 转至 (0) [度 v] ▶
等待 (0.5) 秒
[Spin at the maximum torque.]
set [Motor1 v] max torque to (100)%
[Motor 1 v] 转至 (200) [度 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 motor or motor group 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.

设定 [Motor 1 v] 超时为 (1) 秒

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

当开始
[Spin the motor forward for 1 second, then reset it.]
设定 [Motor 1 v] 超时为 (1) 秒
[Motor 1 v] [向前 v] 转 (5) [转 v] ▶
[Motor 1 v] 转至 (0) [度 v] ▶

Values#

motor is done?#

The motor is done? block returns a Boolean indicating whether the motor or motor group is not spinning.

  • True — The motor is not spinning.

  • False — The motor is spinning.

Note: This block only detects movement from blocks that can expand to show the and don’t wait option.

<[Motor 1 v] 已结束?>

Parameters

Description

motor

The motor or motor group to check, configured in the Devices window.

Example

当开始
[Drive forward until the motor is done spinning.]
[Motor 1 v] [向前 v] 转 (200) [度 v] ◀ 并且不等待
永久循环
如果 <[Motor 1 v] 已结束?> 那么
驱动停止
否则
驱动 [向前 v]

motor is spinning?#

The motor is spinning? block returns a Boolean indicating whether the motor or motor group is spinning.

  • True — The motor is spinning.

  • False — The motor is not spinning.

Note: This block only detects movement from blocks that can expand to show the and don’t wait option.

<[Motor 1 v] 正在转?>

Parameters

Description

motor

The motor or motor group to check, configured in the Devices window.

Example

当开始
[Move forward while the motor is spinning.]
[Motor 1 v] [向前 v] 转 (200) [度 v] ◀ 并且不等待
当 <[Motor 1 v] 正在转?>
驱动 [向前 v]
结束
驱动停止

motor position#

The motor position block returns the total distance the selected motor or motor group has rotated.

([Motor 1 v] 转位 [度 v])

Parameters

Description

motor

The motor or motor group to check, configured in the Devices window.

unit

The unit of measurement:

  • degrees
  • turns

Example

当开始
[Display the motor's position after spinning.]
在 [Brain v] 上打印 ([Motor 1 v] 转位 [度 v]) ◀ 并设定光标为下一行
[Motor 1 v] [向前 v] 转
等待 (1) 秒
在 [Brain v] ▶上打印 ([Motor 1 v] 转位 [度 v])
[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] 速度 [% v] 值)

Parameters

Description

motor

The motor or motor group to check, configured in the Devices window.

unit

The unit of measurement:

  • %
  • rpm — rotations per minute

Example

当开始
[Display the motor's velocity from spinning.]
在 [Brain v] 上打印 ([Motor 1 v] 速度 [rpm v] 值) ◀ 并设定光标为下一行
[Motor 1 v] [向前 v] 转
等待 (1) 秒
在 [Brain v] ▶上打印 ([Motor 1 v] 速度 [rpm v] 值)
[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] 电流 [amps v])

Parameters

Description

motor

The motor or motor group to check, configured in the Devices window.

Example

当开始
[Display the motor's current from spinning.]
将打印精度设置为 [0.01 v] 到 [Brain v]
在 [Brain v] 上打印 ([Motor 1 v] 电流 [amps v]) ◀ 并设定光标为下一行
[Motor 1 v] [向前 v] 转
等待 (1) 秒
在 [Brain v] ▶上打印 ([Motor 1 v] 电流 [amps v])
[Motor 1 v] 停止