ポテンショメータ#
導入#
pot 、および potV2 クラスは、回転軸の角度位置を測定するアナログセンサーであるポテンショメータで使用されます。ポテンショメータは、その位置に比例した電圧を出力します。
ポテンショメータのバージョンによって、検出できる回転量が異なります。
ポテンショメータ - 最大250度
ポテンショメータV2 - 330度(連続)
|
|
|---|---|
ポテンショメータ |
ポテンショメータV2 |
ポテンショメータ#
Class Constructors#
pot(
triport::port &port );
Class Destructor#
pot オブジェクトを破棄し、関連するリソースを解放します。
~pot();
Parameters#
パラメータ |
タイプ |
説明 |
|---|---|---|
|
|
ポテンショメータが接続されている 3 線ポートは、 |
Example#
// Create a pot instance in Port A
pot PotentiometerA = pot(Brain.ThreeWirePort.A);
ポテンショメータV2#
Class Constructors#
potV2(
triport::port &port );
Class Destructor#
potV2 オブジェクトを破棄し、関連するリソースを解放します。
~potV2();
Parameters#
パラメータ |
タイプ |
説明 |
|---|---|---|
|
|
ポテンショメータV2が接続されている3線式ポートは、 |
Examples#
// Create a Potentiometer V2 on 3-Wire Port A
potV2 PotentiometerV2A = potV2(Brain.ThreeWirePort.A);
メンバーの機能#
pot 、および potV2 クラスには、以下のメンバ関数が含まれています。
angle— ポテンショメータの角度位置を度またはパーセントで返します。
Before calling any pot or potV2 member functions, a pot or potV2 instance must be created, as shown below:
/* This constructor is required when using VS Code.
Potentiometer configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */
// Create a potV2 instance in Port A
potV2 PotentiometerV2A = potV2(Brain.ThreeWirePort.A);
angle#
ポテンショメータの角度位置を返します。
1 — この関数は角度をパーセントで表します。
int32_t angle ( percentUnits units = percentUnits::pct );
Parameters2 — この関数は、選択された回転単位として角度を表します。
double angle( rotationUnits units );
パラメータ |
タイプ |
説明 |
|---|---|---|
|
|
The unit that represents the position as a percentage of full rotation: |
|
|
角度を表す単位:
|
返品:
percentUnitsを使用する場合はint32_tになります。doubleを使用する場合はrotationUnitsになります。
// Get the current angle of the Potentiometer V2 in the
// range 0 to 330 degrees.
double angle = PotentiometerV2A.angle(degrees);
// Print the current angle of the Potentiometer to the
// brain screen.
Brain.Screen.print(angle);

