PWM出力#

導入#

pwm_out クラスは、VEX EXP 3線式ポートのPWM(パルス幅変調)出力を制御するために使用されます。これにより、デバイスは可変幅のパルス信号を互換性のある3線式コンポーネントに送信できます。

クラスコンストラクタ#

pwm_out(
  triport::port &port );

クラスデストラクタ#

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

~pwm_out();

パラメータ#

パラメータ

タイプ

説明

port

triport::port &

PWM出力が接続されている3線式ポートは、 Brain.ThreeWirePort.X または ExpanderName.Xのように記述され、 X はポート文字です (例: Brain.ThreeWirePort.A または Expander1.A)。

例#

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

メンバーの機能#

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

  • state — PWM出力の状態を設定します。

Before calling any pwm_out member functions, a pwm_out instance must be created, as shown below:

/* This constructor is required when using VS Code.
PWM configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */

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

state#

PWM出力の状態を指定された値に設定します。

Available Functions
void state(
  int32_t      value,
  percentUnits units );

Parameters

パラメータ

タイプ

説明

value

int32_t

PWM出力に設定する新しい値。範囲は-100~+100パーセント。

units

percentUnits

PWM値を表す単位: percent / pct パーセント

Return Values

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

Notes
  • PWM出力値の範囲は-100%から+100%です。

  • PWM出力の有効な単位は percentのみです。

Examples
// Set the PWM Output to 50%
pwm.state(50, percent);

// Set the PWM Output to -75%
pwm.state(-75, percent);