ポテンショメータ#

導入#

pot 、および potV2 クラスは、回転軸の角度位置を測定するアナログセンサーであるポテンショメータで使用されます。ポテンショメータは、その位置に比例した電圧を出力します。

ポテンショメータのバージョンによって、検出できる回転量が異なります。

  • ポテンショメータ - 最大250度

  • ポテンショメータV2 - 330度(連続)

VEX V5 ポテンショメータ V1.

VEX V5 ポテンショメータ V2.

ポテンショメータ

ポテンショメータV2

ポテンショメータ#

Class Constructors#

pot(
  triport::port &port );

Class Destructor#

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

~pot();

Parameters#

パラメータ

タイプ

説明

port

triport::port &

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

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#

パラメータ

タイプ

説明

port

triport::port &

ポテンショメータV2が接続されている3線式ポートは、 Brain.ThreeWirePort.X または ExpanderName.Xのように表記され、 X はポート文字です(例: Brain.ThreeWirePort.A または Expander1.A)。

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 );

2 — この関数は、選択された回転単位として角度を表します。

double angle(
  rotationUnits units );

Parameters

パラメータ

タイプ

説明

units

percentUnits

The unit that represents the position as a percentage of full rotation: percent / pct (default) — percent, from 0 to 100%.

units

rotationUnits

角度を表す単位:

  • deg / degrees — 度、ポテンショメータの場合は 0 ~ 250、ポテンショメータ V2 の場合は 0 ~ 330
  • turns / rev — 回転

Return Values

返品:

  • percentUnitsを使用する場合は int32_t になります。

  • doubleを使用する場合は rotationUnits になります。

Examples
// 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);