PWM Amach#

Réamhrá#

Úsáidtear an rang pwm_out chun aschur PWM (Modhnú Leithead Pulse) a rialú ar phort 3-Sreang VEX V5. Ligeann sé do ghléasanna comharthaí cuisle leithead athraitheach a sheoladh chuig comhpháirteanna 3-Sreang comhoiriúnacha.

Tógálaithe Ranga#

pwm_out(
  triport::port &port );

Scriostóir Ranga#

Scriosann sé an réad pwm_out agus scaoileann sé acmhainní gaolmhara.

~pwm_out();

Paraiméadair#

Paraiméadar

Cineál

Cur síos

port

triport::port &

An Port 3-Sreang a bhfuil an t-aschur PWM ceangailte leis, scríofa mar Brain.ThreeWirePort.X nó ExpanderName.X, áit a seasann X do litir an phoirt (mar shampla, Brain.ThreeWirePort.A nó Expander1.A).

Sampla#

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

Feidhmeanna na mBall#

Áirítear leis an rang pwm_out na feidhmeanna ball seo a leanas:

  • state — Socraíonn sé staid an aschuir PWM.

Sula nglaotar ar aon fheidhm pwm_out ball, ní mór sampla pwm_out a chruthú, mar a thaispeántar thíos:

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

Socraíonn sé staid an aschuir PWM go luach sonraithe.

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

Parameters

Paraiméadar

Cineál

Cur síos

value

int32_t

An luach nua le socrú le haghaidh aschuir PWM, ó -100 go +100 faoin gcéad.

units

percentUnits

An t-aonad a úsáidtear chun luach PWM a léiriú: percent / pct — faoin gcéad

Return Values

Ní thugann an fheidhm seo luach ar ais.

Notes
  • Tá luach aschuir PWM idir -100 agus +100 faoin gcéad.

  • Is é percent an t-aonad bailí le haghaidh aschuir PWM.

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

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