Potentiometer#

Einführung#

Die Klassen pot und potV2 werden mit Potentiometern verwendet. Potentiometer sind analoge Sensoren, die die Winkelposition einer rotierenden Welle messen. Ein Potentiometer gibt eine Spannung aus, die proportional zu seiner Position ist.

Je nach Ausführung des Potentiometers variiert der erfassbare Drehwinkel:

  • Potentiometer – Bis zu 250 Grad

  • Potentiometer V2 - 330 Grad (Dauerbetrieb)

Das VEX V5 Potentiometer V1.

Das VEX V5 Potentiometer V2.

Potentiometer

Potentiometer V2

Potentiometer#

Class Constructors#

pot(
  triport::port &port );

Class Destructor#

Zerstört das Objekt pot und gibt die zugehörigen Ressourcen frei.

~pot();

Parameters#

Parameter

Typ

Beschreibung

port

triport::port &

Der 3-Draht-Anschluss, an den das Potentiometer angeschlossen ist, wird als Brain.ThreeWirePort.X oder ExpanderName.Xgeschrieben, wobei X der Anschlussbuchstabe ist (zum Beispiel Brain.ThreeWirePort.A oder Expander1.A).

Example#

// Create a pot instance in Port A
pot PotentiometerA = pot(Brain.ThreeWirePort.A);

Potentiometer V2#

Class Constructors#

potV2(
  triport::port &port );

Class Destructor#

Zerstört das Objekt potV2 und gibt die zugehörigen Ressourcen frei.

~potV2();

Parameters#

Parameter

Typ

Beschreibung

port

triport::port &

Der 3-Draht-Anschluss, an den das Potentiometer V2 angeschlossen ist, wird als Brain.ThreeWirePort.X oder ExpanderName.Xgeschrieben, wobei X der Anschlussbuchstabe ist (zum Beispiel Brain.ThreeWirePort.A oder Expander1.A).

Examples#

// Create a Potentiometer V2 on 3-Wire Port A
potV2 PotentiometerV2A = potV2(Brain.ThreeWirePort.A);

Mitgliedsfunktionen#

Die Klassen pot und potV2 umfassen die folgenden Memberfunktionen:

  • angle — Gibt die Winkelposition des Potentiometers in Grad oder als Prozentwert zurück.

Bevor Sie eine pot oder potV2 Memberfunktion aufrufen, muss eine pot oder potV2 Instanz erstellt werden, wie unten gezeigt:

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

Gibt die Winkelposition des Potentiometers zurück.

1 — Diese Funktion stellt den Winkel als Prozentwert dar.

int32_t angle (
  percentUnits units = percentUnits::pct );

2 — Diese Funktion stellt den Winkel als die gewählte Rotationseinheit dar.

double angle(
  rotationUnits units );

Parameters

Parameter

Typ

Beschreibung

units

percentUnits

The unit that represents the position as a percentage of full rotation: percent / pct (default) — percent, from 0 to 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

Rückgabe:

  • Ein int32_t bei Verwendung percentUnits.

  • A double bei Verwendung 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);