393号发动机#

介绍#

Motor 393 是一款直流电机,由 VEX 电机控制器 29 (MC29) 控制。MC29 将来自 3 线 Brain 端口的脉冲宽度调制 (PWM) 信号转换为驱动 Motor 393 的可变电压。

VEX电机控制器29.

本页面使用 motor_393 作为示例电机 393 的名称。请根据需要将其替换为您自己配置的名称。

以下是可用方法列表:

  • spin – 使电机 393 正转或反转,直到停止。

  • stop – 立即停止电机 393。

  • set_velocity – 告诉电机 393 旋转的速度。

  • set_reversed – 设置电机 393 的方向反转。

构造函数 - 手动初始化电机控制器 29。

  • Motor29 – 创建电机控制器 29。

旋转#

spin 使用 当前电机速度 使连接的电机 393 沿指定方向旋转。

Usage:
motor_393.spin(direction, velocity, units)

参数

描述

direction

电机 393 的旋转方向:

  • FORWARD – 默认为逆时针
  • REVERSE – 默认为顺时针

velocity

Optional. The velocity to spin with from 0% to 100% when using PERCENT. This can be an integer or decimal (float). If the velocity is not specified or previously set, the default velocity is 50%.

units

可选。速度单位:

  • PERCENT
  • RPM (默认)– 每分钟转数
  • VelocityUnits.DPS – 每秒度数

停止#

stop 立即停止连接的电机 393。

Usage:
motor_393.stop()

参数

描述

此方法没有参数。

设置速度#

set_velocity 告诉电机 393 的旋转速度。百分比越高,电机 393 的旋转速度越快;百分比越低,电机 393 的旋转速度越慢。

每个项目开始时,每个电机 393 默认以 50% 的速度旋转。

Usage:
motor_393.set_velocity(value, units)

范围

描述

velocity

The velocity to spin with from 0% to 100% when using PERCENT. This can be an integer or decimal (float).

units

可选。速度单位:

  • PERCENT
  • RPM (默认)– 每分钟转数
  • VelocityUnits.DPS – 每秒度数

设置反转#

set_reversed 将电机 393 设置为反转,以便 FORWARD 方向顺时针旋转。此方法与构造 Motor29 时将 reverse 参数设置为 True 效果相同。

Usage:
motor_393.set_reversed(value)

参数

描述

value

电机 393 的旋转方向是否反转:

  • True — 反转电机 393 的旋转方向。4
  • 假False 默认值

构造函数#

构造函数用于手动创建 Motor29 对象,这些对象对于在 VEXcode 之外配置电机控制器 29/电机 393 是必要的。

Motor29#

Motor29 创建电机控制器 29。

Usage:
Motor29(port, reverse)

范围

描述

port

The 3-Wire Port that the Motor Controller 29 is connected to:

  • On the V5 Brain – Ports.PORTx where x is the number of the port.
  • On a 3-Wire Expander – expander.a where expander is the name of the expander instance.

reverse

Optional. Sets whether the Motor 393’s spin should be reversed.

  • True – FORWARD will spin clockwise
  • False (default) – FORWARD will spin counterclockwise

# Create a Motor Controller 29 in Port A
motor_393 = Motor29(brain.three_wire_port.a)