ビクター883モーター#

導入#

motor_victor クラスは、3線式ポートに接続された Victor 883 モーターコントローラーを制御するために使用されます。Victor 883 モーターコントローラーは、V5 Brain から PWM 信号を送信し、スマートポートに直接接続できない互換性のある VEXpro または VEX EDR DC モーターを制御します。

Victor 883モーターコントローラーはVEXcodeでは設定できないため、使用するにはコードで手動で構築する必要があります。

クラスコンストラクタ#

1 — 指定された 3 線ポートに接続された Victor 883 モーター コントローラー用の motor_victor オブジェクトを作成します。

motor_victor( triport::port& port );

2 — 指定された 3 線ポート上に motor_victor オブジェクトを作成し、必要に応じてその方向を反転します。

motor_victor(
 triport::port& port,
 bool           reverse );

クラスデストラクタ#

motor_victor オブジェクトを破棄し、関連するリソースを解放します。

~motor_victor();

パラメータ#

パラメータ

タイプ

説明

port

triport::port&

Victor 883 モーターが接続されている 3 線ポートは、 Brain.ThreeWirePort.X または ExpanderName.Xのように記述され、 X はポート文字です (たとえば、 Brain.ThreeWirePort.A または Expander1.A)。

reverse

bool

モーターの回転方向を反転するかどうかを設定します。

  • false (デフォルト) — モーターの回転方向を反転しません。
  • true — モーターの回転方向を反転します。

例#

// Create the motor_victor instance on 3-Wire Port A
motor_victor victor = motor_victor(Brain.ThreeWirePort.A);

// Create the motor_victor instance with reversed direction
motor_victor victor2 = motor_victor(Brain.ThreeWirePort.B, true);

メンバーの機能#

motor_victor クラスには、以下のメンバ関数が含まれています。

  • spin — モーターを指定された方向に回転させます。

  • stop — モーターを停止します。

  • setVelocity — モーターに回転速度を指示します。

  • setReversed — モーターの回転方向を反転するかどうかを設定します。

motor_victor メンバ関数を呼び出す前に、以下に示すように motor_victor インスタンスを作成する必要があります。

/* This constructor is required to use a
Victor 883 Motor. Replace the values
as needed. */

// Create the motor_victor instance on 3-Wire Port A
motor_victor victor = motor_victor(Brain.ThreeWirePort.A);

spin#

モーターを指定された方向に永久に回転させます。

Available Functions

1 — 現在設定されているモーター速度を使用してモーターを回転させます。

void spin(
 directionType dir );

2 — モーターを指定された速度で回転させます。

void spin(
 directionType dir,
 double        velocity,
 velocityUnits units );

Parameters

パラメータ

タイプ

説明

dir

directionType

モーターが回転する方向: forward または reverse。

velocity

double

percentを使用する場合、0% から 100% までの回転速度。

units

velocityUnits

速度の単位:

  • percent / pct — パーセント
  • rpm — 毎分回転数
  • dps — 毎秒角度

Return Values

この関数は値を返しません。

Notes
  • モーターは、stop が呼び出されるか、別の動作関数が実行されるまで回転し続けます。

Examples
// Spin forward, then stop
victor.spin(forward);
wait(1, seconds);
victor.stop();

// Spin forward at 100 rpm
victor.spin(forward, 100, rpm);
wait(1, seconds);
victor.stop();

stop#

モーターの回転を停止します。

Available Functions
void stop();

Parameters

この関数は引数を受け付けません。

Return Values

この関数は値を返しません。

Notes
  • stop を呼び出すと、モーターの現在の動作が即座に停止します。

Examples
// Spin and then stop
victor.spin(forward);
wait(1, seconds);
victor.stop();

setVelocity#

モーターの回転速度を指定します。パーセンテージが高いほどモーターの回転速度が速くなり、低いほど回転速度が遅くなります。

すべてのプロジェクトは、接続されている各モーターがデフォルトで50%の速度で回転する状態から始まります。

Available Functions
void setVelocity(
    double       velocity,
    percentUnits units );

Parameters

パラメータ

タイプ

説明

velocity

double

percentを使用する場合、0% から 100% までの回転速度。

units

percentUnits

速度の単位:percent pct パーセント

Return Values

この関数は値を返しません。

Notes
  • 速度を明示的に指定しない後続の Victor 883 モーターの動作関数 (spin など) は、この値を使用します。

Examples
// Set velocity to 50%, then spin
victor.setVelocity(50, percent);
victor.spin(forward);

setReversed#

モーターの回転方向を反転させるかどうかを設定します。

Available Functions
void setReversed( bool value );

Parameters

パラメータ

タイプ

説明

value

bool

モーターの回転方向を反転するかどうか:

  • true — モーターの回転方向を反転します。
  • false — モーターの回転方向をデフォルトに戻します。

Return Values

この関数は値を返しません。

Notes Examples
// Reverse the motor direction
victor.setReversed(true);
victor.spin(forward); // Will actually spin in reverse