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)
|
|
|---|---|
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 |
|---|---|---|
|
|
Der 3-Draht-Anschluss, an den das Potentiometer angeschlossen ist, wird als |
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 |
|---|---|---|
|
|
Der 3-Draht-Anschluss, an den das Potentiometer V2 angeschlossen ist, wird als |
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 );
Parameters2 — Diese Funktion stellt den Winkel als die gewählte Rotationseinheit dar.
double angle( rotationUnits units );
Parameter |
Typ |
Beschreibung |
|---|---|---|
|
|
The unit that represents the position as a percentage of full rotation: |
|
|
The unit that represents the angle:
|
Rückgabe:
Ein
int32_tbei VerwendungpercentUnits.A
doublebei VerwendungrotationUnits.
// 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);

