Potansiyometre#

giriiş#

pot ve potV2 numaralı potansiyometre sınıfları, dönen bir milin açısal konumunu ölçen analog sensörler olan potansiyometrelerle birlikte kullanılır. Bir potansiyometre, konumuna orantılı bir voltaj çıkışı verir.

Potansiyometrenin modeline bağlı olarak, algılayabildiği dönüş miktarı değişir:

  • Potansiyometre - 250 dereceye kadar

  • Potansiyometre V2 - 330 derece (Sürekli)

VEX V5 Potansiyometre V1.

VEX V5 Potansiyometre V2.

Potansiyometre

Potansiyometre V2

Potansiyometre#

Class Constructors#

pot(
  triport::port &port );

Class Destructor#

pot nesnesini yok eder ve ilgili kaynakları serbest bırakır.

~pot();

Parameters#

Parametre

Tip

Tanım

port

triport::port &

Potansiyometrenin bağlı olduğu 3 telli port, Brain.ThreeWirePort.X veya ExpanderName.Xşeklinde yazılır; burada X port harfidir (örneğin, Brain.ThreeWirePort.A veya Expander1.A).

Example#

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

Potansiyometre V2#

Class Constructors#

potV2(
  triport::port &port );

Class Destructor#

potV2 nesnesini yok eder ve ilişkili kaynakları serbest bırakır.

~potV2();

Parameters#

Parametre

Tip

Tanım

port

triport::port &

Potansiyometre V2’nin bağlı olduğu 3 Kablolu Port, Brain.ThreeWirePort.X veya ExpanderName.Xşeklinde yazılır; burada X port harfidir (örneğin, Brain.ThreeWirePort.A veya Expander1.A).

Examples#

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

Üye Fonksiyonları#

pot ve potV2 sınıfları aşağıdaki üye fonksiyonlarını içerir:

  • angle — Potansiyometrenin açısal konumunu derece veya yüzde olarak döndürür.

Herhangi bir pot veya potV2 üye fonksiyonunu çağırmadan önce, aşağıda gösterildiği gibi bir pot veya potV2 örneği oluşturulmalıdır:

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

Potansiyometrenin açısal konumunu döndürür.

1 — Bu fonksiyon açıyı yüzde olarak ifade eder.

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

2 — Bu fonksiyon, seçilen dönüş birimleri cinsinden açıyı temsil eder.

double angle(
  rotationUnits units );

Parameters

Parametre

Tip

Tanım

units

percentUnits

Pozisyonu tam dönüşün yüzdesi olarak temsil eden birim: % percent / pct (varsayılan) — yüzde, %0 ile %100 arası.

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

İadeler:

  • percentUnits kullanıldığında int32_t.

  • double kullanıldığında 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);