Έξοδος PWM#

Εισαγωγή#

The pwm_out class is used to control PWM (Pulse Width Modulation) output on a VEX EXP 3-Wire port. It allows devices to send variable-width pulse signals to compatible 3-Wire components.

Κατασκευαστές κλάσεων#

pwm_out(
  triport::port &port );

Καταστροφέας κλάσης#

Destroys the pwm_out object and releases associated resources.

~pwm_out();

Παράμετροι#

Παράμετρος

Τύπος

Περιγραφή

port

triport::port &

The 3-Wire Port the PWM output is connected to, written as Brain.ThreeWirePort.X or ExpanderName.X, where X is the port letter (for example, Brain.ThreeWirePort.A or Expander1.A).

Παράδειγμα#

// Create the pwm_out instance on 3-Wire Port A
pwm_out pwm = pwm_out(Brain.ThreeWirePort.A);

Συναρτήσεις Μελών#

The pwm_out class includes the following member functions:

  • state — Sets the state of the PWM output.

Before calling any pwm_out member functions, a pwm_out instance must be created, as shown below:

/* This constructor is required when using VS Code.
PWM configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */

// Create the pwm_out instance on 3-Wire Port A
pwm_out pwm = pwm_out(Brain.ThreeWirePort.A);

state#

Ορίζει την κατάσταση της εξόδου PWM σε μια καθορισμένη τιμή.

Available Functions
void state(
  int32_t      value,
  percentUnits units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

value

int32_t

Η νέα τιμή που θα οριστεί για την έξοδο PWM, από -100 έως +100 τοις εκατό.

units

percentUnits

The unit used to represent the PWM value: percent / pct — percent

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Η τιμή εξόδου PWM κυμαίνεται από -100 έως +100 τοις εκατό.

  • The only valid unit for PWM output is percent.

Examples
// Set the PWM Output to 50%
pwm.state(50, percent);

// Set the PWM Output to -75%
pwm.state(-75, percent);