馬達控制器 55#

介紹#

馬達控制器 55 (MC55) 用於控制標準直流馬達。

VEX馬達控制器55.

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

以下是可用方法清單:

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

  • stop – 立即停止直流馬達。

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

  • set_stopping – 設定直流馬達停止時的行為。

  • set_max_torque – 設定直流馬達允許使用的最大扭力。

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

  • current – 傳回直流馬達正在使用的電流大小。

  • temperature – 返回直流馬達的溫度。

建構函式 - 手動初始化馬達控制器 55。

  • Motor55 – 建立馬達控制器 55。

旋轉#

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

Usage:
mc_55.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%.

If VOLT is used in units, this will accept a range from -12.0 to 12.0 where a negative value will spin opposite to the given direction.

units

Optional. The velocity unit:

  • PERCENT
  • RPM – Rotations per minute
  • VelocityUnits.DPS – Degrees per second
  • VOLT (default) – Spins the DC motor at a specified voltage.

# Spin the motor at -2 volts
mc_55.spin(FORWARD, -2)

停止#

stop 立即停止連接的直流電機,使用電流停止模式。

Usage:
mc_55.stop(mode)

範圍

描述

模式

Optional. The stopping behavior to use when the motor stops:

  • BRAKE – Stops immediately.
  • COAST – Slows gradually to a stop.

If the stopping mode is not specified or previously set, the default behavior is BRAKE.

設定速度#

set_velocity 決定直流馬達的轉速。百分比越高,直流馬達轉速越快;百分比越低,直流馬達轉速越慢。

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

Usage:
mc_55.set_velocity(value, units)

範圍

描述

value

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

units

可選。速度單位: PERCENT。

設定停止#

set_stopping 設定直流馬達停止時的行為。

Usage:
mc_55.set_stopping(mode)

參數

描述

mode

How the motor will stop:

  • BRAKE – Stops immediately.
  • COAST – Slows gradually to a stop.

設定最大扭矩#

扭力表示直流馬達在旋轉時能夠產生的推力或拉力的大小。

set_max_torque 設定直流馬達允許使用的最大扭力。

Usage:
mc_55.set_max_torque(value, units)

參數

描述

value

The maximum torque the DC motor is allowed to use. This can be an integer or decimal (float).

units

可選。扭力單位: CurrentUnits.AMP (預設)

設定反轉#

set_reversed 將直流馬達反轉,使 FORWARD 方向順時針旋轉。此方法與建構 Motor55 時將 reverse 參數設為 True 效果相同。

Usage:
mc_55.set_reversed(value)

參數

描述

value

Whether the DC motor’s direction is reversed:

  • True — Reverses the DC motor’s direction.
  • False — Returns the DC motor’s direction to its default.

目前的#

current 返回直流馬達正在使用的電流大小,以安培為單位,範圍從 0.0 到 1.2 A。電流是指流過直流馬達的電量。

電流值越高,代表直流馬達消耗的電流越大。這種情況可能發生在直流馬達提升重物、推動物體或試圖在卡住時移動時。

這可以用來檢查直流馬達在運動過程中是否運轉吃力。如果電流持續過高,馬達可能會發熱或功率利用率降低。

Usage:
mc_55.current(units)

參數

描述

units

可選。目前單位: CurrentUnits.AMP (預設)– 安培

溫度#

temperature 返回直流馬達的溫度。

馬達溫度顯示直流馬達的溫度。溫度越高,表示直流馬達在工作過程中溫度越高。為了保持最佳性能,馬達溫度應保持在 55°C 以下。

如果直流馬達過熱,它會降低最大電流以保護自身。當溫度達到 70°C 時,馬達將停止運轉,直到冷卻。

這可以用來檢查直流馬達在重複運動、長時間運轉或推動物體時是否過熱。

Usage:
mc_55.temperature(units)

參數

描述

units

可選。溫度單位:

  • TemperatureUnits.CELSIUS (預設)
  • TemperatureUnits.FAHRENHEIT
  • PERCENT

建構函數#

建構函式用於手動建立 Motor55 對象,這是在 VEXcode 之外配置 Motor Controller 55 所必需的。

Motor55#

Motor55 創建馬達控制器 55。

Usage:
Motor55(port, reverse)

範圍

描述

port

The 3-Wire Port that the motor controller is connected to:

  • On the EXP 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’s spin should be reversed.

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

# Create a Motor Controller 55 in Port A
mc_55 = Motor55(brain.three_wire_port.a)