Ποτενσιόμετρο#
Εισαγωγή#
The pot and potV2 classes are used with Potentiometers, which are analog sensors that measure the angular position of a rotating shaft. A Potentiometer outputs a voltage proportional to its position.
Ανάλογα με την έκδοση του ποτενσιόμετρου, η ποσότητα περιστροφής που μπορεί να ανιχνεύσει ποικίλλει:
Ποτενσιόμετρο - Έως 250 μοίρες
Ποτενσιόμετρο V2 - 330 μοίρες (Συνεχές)
|
|
|---|---|
Ποτενσιόμετρο |
Ποτενσιόμετρο V2 |
Ποτενσιόμετρο#
Class Constructors#
pot(
triport::port &port );
Class Destructor#
Destroys the pot object and releases associated resources.
~pot();
Parameters#
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The 3-Wire Port the Potentiometer is connected to, written as |
Example#
// Create a pot instance in Port A
pot PotentiometerA = pot(Brain.ThreeWirePort.A);
Ποτενσιόμετρο V2#
Class Constructors#
potV2(
triport::port &port );
Class Destructor#
Destroys the potV2 object and releases associated resources.
~potV2();
Parameters#
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The 3-Wire Port the Potentiometer V2 is connected to, written as |
Examples#
// Create a Potentiometer V2 on 3-Wire Port A
potV2 PotentiometerV2A = potV2(Brain.ThreeWirePort.A);
Συναρτήσεις Μελών#
The pot and potV2 classes include the following member functions:
angle— Returns the angular position of the Potentiometer in degrees or as a percent.
Before calling any pot or potV2 member functions, a pot or potV2 instance must be created, as shown below:
/* 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 );
Parameters2 — Αυτή η συνάρτηση αντιπροσωπεύει τη γωνία ως τις επιλεγμένες μονάδες περιστροφής.
double angle( rotationUnits units );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The unit that represents the position as a percentage of full rotation: |
|
|
The unit that represents the angle:
|
Επιστροφές:
An
int32_twhen usingpercentUnits.A
doublewhen usingrotationUnits.
// 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);

