电机#
介绍#
电机模块可以控制电机正转或反转,将其移动到特定位置,并调整其速度、扭矩和超时设置。它们还可以报告编码器值以跟踪运动和位置。
以下是可用块的列表:
动作——连续旋转电机,直到到达某个位置,或者停止电机。
spin – 无限旋转选定的电机或电机组。
spin for – 以度数或圈数为单位,使电机或电机组旋转特定距离。
旋转到位置 – 将电机或电机组旋转到设定位置。
停止电机 – 停止特定电机或电机组旋转。
设置——配置电机速度、位置、停止模式、扭矩和超时。
设置电机速度 – 以百分比设置电机或电机组的速度。
设置电机位置 – 设置电机或电机组的编码器值。
设置电机停止 – 设置停止行为(制动、滑行或保持)。
[设置电机最大扭矩](#set-motor-max-torque)——限制电机可施加的最大扭矩。
[设置电机超时](#set-motor-timeout)——限制当运动受阻时电机阻塞在放弃之前等待的时间。
值——读取电机运动状态、位置、速度和电流消耗。
行动#
旋转#
旋转块使用 当前电机速度 沿指定方向旋转选定的电机或电机组。
[Motor 1 v] [向前 v] 转
参数 |
描述 |
|---|---|
发动机 |
在设备窗口中配置要旋转的电机或电机组。 |
方向 |
The direction to spin, configured in the Devices window. By default this is:
|
例子
当开始
[Spin the motor forward, then stop.]
[Motor 1 v] [向前 v] 转
等待 (1) 秒
[Motor 1 v] 停止
旋转#
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] ▶
参数 |
描述 |
|---|---|
发动机 |
在设备窗口中配置要旋转的电机或电机组。 |
方向 |
旋转方向,在设备窗口中配置。默认为:
|
距离 |
旋转量,为整数或小数。 |
单元 |
The unit of measurement:
|
扩大箭头 |
默认情况下,这是一个等待块,因此电机会在运行下一个块之前完成移动。要使电机开始移动并立即运行下一个块,请将块扩展为不等待。 |
例子
当开始
[Spin the motor forward once, then reset.]
[Motor 1 v] [向前 v] 转 (90) [度 v] ▶
[Motor 1 v] [反 v] 转 (90) [度 v] ▶
旋转至位置#
旋转到位置块使用当前 电机速度 和 电机位置 将电机或电机组旋转到特定的绝对位置。
[Motor 1 v] 转至 (90) [度 v] ▶
参数 |
描述 |
|---|---|
发动机 |
在设备窗口中配置要旋转的电机或电机组。 |
位置 |
电机或电机组旋转的目标位置。 |
单元 |
The unit of measurement:
|
扩大箭头 |
默认情况下,这是一个等待块,因此电机会在运行下一个块之前完成移动。要使电机开始移动并立即运行下一个块,请将块扩展为不等待。 |
例子
当开始
[Spin the motor, then put the motor at half of a rotation.]
[Motor 1 v] [向前 v] 转
等待 (2) 秒
[Motor 1 v] 转至 (180) [度 v] ▶
停止电机#
停止电机块立即停止选定的电机或电机组。
[Motor 1 v] 停止
参数 |
描述 |
|---|---|
发动机 |
要停止的电机或电机组,在设备窗口中配置。 |
例子
当开始
[Stop the motor after 1 second.]
[Motor 1 v] [向前 v] 转
等待 (1) 秒
[Motor 1 v] 停止
设置#
设置电机位置#
设置电机位置块为电机或电机组设置特定的位置值,从而更新编码器读数。
设定 [Motor 1 v] 转位至 (0) [度 v]
参数 |
描述 |
|---|---|
发动机 |
在设备窗口中配置要设置位置的电机或电机组。 |
位置 |
要设置的编码器位置值。 |
单元 |
The unit of measurement:
|
例子
当开始
[Spin the motor to the new 0 position.]
设定 [Motor 1 v] 转位至 [180] [度 v]
[Motor 1 v] 转至 [0] [度 v] ▶
设定电机速度#
设置电机速度块将电机或电机组的默认旋转速度设置为项目中所有后续电机块的百分比。
设定 [Motor 1 v] 转速为 (50) [% v]
参数 |
描述 |
|---|---|
发动机 |
在设备窗口中配置要设置速度的电机或电机组。 |
速度 |
将默认移动速度设置为 0% 至 100%。 |
单元 |
The unit of measurement:
|
例子
当开始
[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] ▶
设置电机停止#
设置电机停止块设置电机或电机组停止时的行为。
设定 [Motor 1 v] 停止模式为 [刹车 v]
参数 |
描述 |
|---|---|
发动机 |
在设备窗口中配置要设置停止行为的电机或电机组。 |
停止行为 |
Sets how the drivetrain stops:
|
设置电机最大扭矩#
设置电机最大扭矩块设置电机或电机组可以施加多大的力。
设定 [Motor 1 v] 最大扭矩为 [50]%
参数 |
描述 |
|---|---|
发动机 |
在设备窗口中配置要设置最大扭矩的电机或电机组。 |
扭矩 |
允许的最大扭矩,从 0% 到 100%。 |
例子
当开始
[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] ▶
设置电机超时#
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.
**注意:**电机的时间限制用于防止未到达目标位置的电机块停止堆栈中其他块的执行。
设定 [Motor 1 v] 超时为 (1) 秒
参数 |
描述 |
|---|---|
发动机 |
在设备窗口中配置要设置超时的电机或电机组。 |
时间 |
电机块在停止并移动到下一个块之前运行的最大秒数。 |
例子
当开始
[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] ▶
价值观#
电机做好了吗?#
The motor is done? block returns a Boolean indicating whether the motor or motor group 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] 已结束?>
参数 |
描述 |
|---|---|
发动机 |
需要检查的电机或电机组,在设备窗口中配置。 |
例子
当开始
[Drive forward until the motor is done spinning.]
[Motor 1 v] [向前 v] 转 (200) [度 v] ◀ 并且不等待
永久循环
如果 <[Motor 1 v] 已结束?> 那么
驱动停止
否则
驱动 [向前 v]
电机在旋转吗?#
The motor is spinning? block returns a Boolean indicating whether the motor or motor group is spinning.
真 - 电机正在旋转。
错误 - 电机未旋转。
Note: This block only detects movement from blocks that can expand to show the and don’t wait option.
<[Motor 1 v] 正在转?>
参数 |
描述 |
|---|---|
发动机 |
需要检查的电机或电机组,在设备窗口中配置。 |
例子
当开始
[Move forward while the motor is spinning.]
[Motor 1 v] [向前 v] 转 (200) [度 v] ◀ 并且不等待
当 <[Motor 1 v] 正在转?>
驱动 [向前 v]
结束
驱动停止
电机位置#
电机位置块返回所选电机或电机组旋转的总距离。
([Motor 1 v] 转位 [度 v])
参数 |
描述 |
|---|---|
发动机 |
需要检查的电机或电机组,在设备窗口中配置。 |
单元 |
The unit of measurement:
|
例子
当开始
[Display the motor's position after spinning.]
在 ([Motor 1 v] 转位 [度 v]) 上打印 [Brain v] ◀ 并设定光标为下一行
[Motor 1 v] [向前 v] 转
等待 (1) 秒
在 ([Motor 1 v] 转位 [度 v]) ▶上打印 [Brain v]
[Motor 1 v] 停止
电机速度#
电机速度块返回电机或电机组的当前转速,范围从 -100% 到 100% 或 -127 rpm 到 127 rpm。
([Motor 1 v] 速度 [% v] 值)
参数 |
描述 |
|---|---|
发动机 |
需要检查的电机或电机组,在设备窗口中配置。 |
单元 |
The unit of measurement:
|
例子
当开始
[Display the motor's velocity from spinning.]
在 ([Motor 1 v] 速度 [rpm v] 值) 上打印 [Brain v] ◀ 并设定光标为下一行
[Motor 1 v] [向前 v] 转
等待 (1) 秒
在 ([Motor 1 v] 速度 [rpm v] 值) ▶上打印 [Brain v]
[Motor 1 v] 停止
电机电流#
电机电流块返回电机或电机组的电流量,范围从 0.0 到 1.2 安培 (Amperes)。
([Motor 1 v] 电流 [amps v])
参数 |
描述 |
|---|---|
发动机 |
需要检查的电机或电机组,在设备窗口中配置。 |
例子
当开始
[Display the motor's current from spinning.]
将打印精度设置为 [0.01 v] 到 [Brain v]
在 ([Motor 1 v] 电流 [amps v]) 上打印 [Brain v] ◀ 并设定光标为下一行
[Motor 1 v] [向前 v] 转
等待 (1) 秒
在 ([Motor 1 v] 电流 [amps v]) ▶上打印 [Brain v]
[Motor 1 v] 停止