PWM出力#
導入#
pwm_out クラスは、VEX V5 3線式ポートのPWM(パルス幅変調)出力を制御するために使用されます。これにより、デバイスは可変幅のパルス信号を互換性のある3線式コンポーネントに送信できます。
クラスコンストラクタ#
pwm_out(
triport::port &port );
クラスデストラクタ#
pwm_out オブジェクトを破棄し、関連するリソースを解放します。
~pwm_out();
パラメータ#
パラメータ |
タイプ |
説明 |
|---|---|---|
|
|
PWM出力が接続されている3線式ポートは、 |
例#
// 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 Functionsvoid state(
int32_t value,
percentUnits units );
パラメータ |
タイプ |
説明 |
|---|---|---|
|
|
PWM出力に設定する新しい値。範囲は-100~+100パーセント。 |
|
|
PWM値を表す単位: |
この関数は値を返しません。
NotesPWM出力値の範囲は-100%から+100%です。
PWM出力の有効な単位は
percentのみです。
// Set the PWM Output to 50%
pwm.state(50, percent);
// Set the PWM Output to -75%
pwm.state(-75, percent);