維克多汽車#

介紹#

VEX Victor 馬達控制器 是一款傳統的馬達控制器,它接收來自主機的 3 線 PWM 訊號來控制無法直接插入智慧型連接埠的 VEXpro/EDR 直流馬達。

本頁以 victor_motor 作為 Victor 馬達控制器的範例名稱。請根據需要將其替換為您自己配置的名稱。

以下是可用方法清單:

  • spin – 使馬達正轉或反轉,直到停止。

  • stop – 立即停止馬達。

  • set_velocity – 告訴馬達旋轉的速度。

  • set_reversed – 設定馬達反轉其旋轉方向。

建構子 – 手動初始化 Victor 馬達控制器。

  • MotorVictor – 建立一個 Victor 馬達控制器。

旋轉#

spin 使用 目前馬達轉速 使連接的馬達沿指定方向旋轉。

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

參數

描述

direction

馬達旋轉方向:

  • 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 立即停止連接的馬達。

Usage:
victor_motor.stop()

參數

描述

此方法沒有參數。

設定速度#

set_velocity 告訴馬達旋轉的速度。百分比越高,馬達旋轉速度越快;百分比越低,馬達旋轉速度越慢。

每個項目開始時,每個連接的馬達預設以 50% 的速度旋轉。

Usage:
victor_motor.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 將馬達反轉,使 FORWARD 方向順時針旋轉。此方法與建構 MotorVictor 時將 reverse 參數設為 True 效果相同。

Usage:
victor_motor.set_reversed(value)

參數

描述

value

馬達方向是否反轉:

  • True — 反轉馬達方向。 4
  • 假False 預設方向

建構函數#

建構函式用於建立 MotorVictor 對象,這些物件是配置 Victor 馬達控制器所必需的。

MotorVictor#

MotorVictor 創建一個 Victor 馬達控制器。

Usage:
MotorVictor(port, reverse)

範圍

描述

port

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

  • On the EXP Brain – brain.three_wire_port.x 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’s spin should be reversed.

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

# Create a Victor Motor Controller in Port A
victor_motor = MotorVictor(brain.three_wire_port.a)