Potenciometrs#
Ievads#
pot un potV2 klases tiek izmantotas ar potenciometriem, kas ir analogie sensori, kas mēra rotējošas vārpstas leņķisko pozīciju. Potenciometrs izvada spriegumu, kas ir proporcionāls tā pozīcijai.
Atkarībā no potenciometra versijas, tā nosakāmā rotācijas vērtība atšķiras:
Potenciometrs - līdz 250 grādiem
Potenciometrs V2 - 330 grādi (nepārtraukts)
|
|
|---|---|
Potenciometrs |
Potenciometrs V2 |
Potenciometrs#
Class Constructors#
pot(
triport::port &port );
Class Destructor#
Iznīcina pot objektu un atbrīvo saistītos resursus.
~pot();
Parameters#
Parametrs |
Tips |
Apraksts |
|---|---|---|
|
|
3 vadu ports, kuram ir pievienots potenciometrs, tiek pierakstīts kā |
Example#
// Create a pot instance in Port A
pot PotentiometerA = pot(Brain.ThreeWirePort.A);
Potenciometrs V2#
Class Constructors#
potV2(
triport::port &port );
Class Destructor#
Iznīcina objektu potV2 un atbrīvo saistītos resursus.
~potV2();
Parameters#
Parametrs |
Tips |
Apraksts |
|---|---|---|
|
|
3 vadu ports, kuram ir pievienots potenciometrs V2, tiek pierakstīts kā |
Examples#
// Create a Potentiometer V2 on 3-Wire Port A
potV2 PotentiometerV2A = potV2(Brain.ThreeWirePort.A);
Dalībnieku funkcijas#
pot un potV2 klasēs ir iekļautas šādas dalībfunkcijas:
angle— Atgriež potenciometra leņķisko pozīciju grādos vai procentos.
Pirms jebkuru pot vai potV2 dalībfunkciju izsaukšanas ir jāizveido pot vai potV2 instance, kā parādīts zemāk:
/* 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#
Atgriež potenciometra leņķisko pozīciju.
1 — Šī funkcija attēlo leņķi procentos.
int32_t angle ( percentUnits units = percentUnits::pct );
Parameters2 — Šī funkcija attēlo leņķi kā izvēlētās rotācijas mērvienības.
double angle( rotationUnits units );
Parametrs |
Tips |
Apraksts |
|---|---|---|
|
|
Vienība, kas attēlo pozīciju procentos no pilnas rotācijas: |
|
|
Leņķa mērvienība:
|
Atgriešana:
int32_t, ja tiek izmantotipercentUnits.doubleja tiek izmantotasrotationUnits.
// 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);

