전위차계#

소개#

pot , potV2 클래스는 회전축의 각도 위치를 측정하는 아날로그 센서인 전위차계와 함께 사용됩니다. 전위차계는 위치에 비례하는 전압을 출력합니다.

전위차계 버전에 따라 감지할 수 있는 회전량이 다릅니다.

  • 가변저항계 - 최대 250도

  • 전위차계 V2 - 330도 (연속)

VEX EXP 전위차계 V1.

VEX EXP 전위차계 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 — 포텐시오미터의 각도 위치를 도 또는 백분율로 반환합니다.

pot 또는 potV2 멤버 함수를 호출하기 전에 아래와 같이 pot 또는 potV2 인스턴스를 생성해야 합니다.

/* 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

전체 회전 대비 위치를 백분율로 나타내는 단위: percent / pct (기본값) — 0~100%의 백분율.

units

rotationUnits

The unit that represents the angle:

  • deg / degrees — degrees, from 0 to 250 for a Potentiometer or 0 to 330 for a Potentiometer V2
  • turns / rev — revolutions

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