Potencjometr#
Wstęp#
Klasy pot i potV2 są używane z potencjometrami, czyli czujnikami analogowymi mierzącymi położenie kątowe obracającego się wału. Potencjometr generuje napięcie proporcjonalne do swojego położenia.
W zależności od wersji potencjometru, zakres wykrywanych obrotów jest różny:
Potencjometr - do 250 stopni
Potencjometr V2 - 330 stopni (Ciągły)
|
|
|---|---|
Potencjometr |
Potencjometr V2 |
Potencjometr#
Class Constructors#
pot(
triport::port &port );
Class Destructor#
Destroys the pot object and releases associated resources.
~pot();
Parameters#
Parametr |
Typ |
Opis |
|---|---|---|
|
|
Port 3-żyłowy, do którego podłączony jest potencjometr, zapisany jako |
Example#
// Create a pot instance in Port A
pot PotentiometerA = pot(Brain.ThreeWirePort.A);
Potencjometr V2#
Class Constructors#
potV2(
triport::port &port );
Class Destructor#
Niszczy obiekt potV2 i zwalnia powiązane zasoby.
~potV2();
Parameters#
Parametr |
Typ |
Opis |
|---|---|---|
|
|
Port 3-żyłowy, do którego podłączony jest potencjometr V2, zapisany jako |
Examples#
// Create a Potentiometer V2 on 3-Wire Port A
potV2 PotentiometerV2A = potV2(Brain.ThreeWirePort.A);
Funkcje członkowskie#
Klasy pot i potV2 zawierają następujące funkcje członkowskie:
angle— Zwraca położenie kątowe potencjometru w stopniach lub procentach.
Przed wywołaniem jakiejkolwiek funkcji członkowskiej pot lub potV2 należy utworzyć instancję pot lub potV2 , jak pokazano poniżej:
/* 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#
Zwraca położenie kątowe potencjometru.
1 — Funkcja ta przedstawia kąt jako wartość procentową.
int32_t angle ( percentUnits units = percentUnits::pct );
Parameters2 — Funkcja ta przedstawia kąt jako wybrane jednostki obrotu.
double angle( rotationUnits units );
Parametr |
Typ |
Opis |
|---|---|---|
|
|
Jednostka reprezentująca położenie jako procent pełnego obrotu: |
|
|
Jednostka reprezentująca kąt:
|
Zwroty:
Wartość
int32_tprzy użyciupercentUnits.doubleprzy użyciurotationUnits.
// 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);

