PWM 출력#

소개#

pwm_out 클래스는 VEX V5 3선 포트의 PWM(펄스 폭 변조) 출력을 제어하는 ​​데 사용됩니다. 이 클래스를 통해 장치는 호환되는 3선 구성 요소로 가변 폭 펄스 신호를 전송할 수 있습니다.

클래스 생성자#

pwm_out(
  triport::port &port );

클래스 소멸자#

pwm_out 객체를 파괴하고 관련 리소스를 해제합니다.

~pwm_out();

매개변수#

매개변수

유형

설명

port

triport::port &

PWM 출력이 연결된 3선 포트는 Brain.ThreeWirePort.X 또는 ExpanderName.X과 같이 표기되며, 여기서 X 는 포트 문자입니다(예: Brain.ThreeWirePort.A 또는 Expander1.A).

예#

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

회원 기능#

pwm_out 클래스에는 다음과 같은 멤버 함수가 포함되어 있습니다.

  • state — PWM 출력의 상태를 설정합니다.

pwm_out 멤버 함수를 호출하기 전에 아래와 같이 pwm_out 인스턴스를 생성해야 합니다.

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

PWM 값을 나타내는 단위: percent 퍼센트 pct 퍼센트

Return Values

이 함수는 값을 반환하지 않습니다.

Notes
  • PWM 출력값의 범위는 -100%에서 +100%까지입니다.

  • PWM 출력에 사용할 수 있는 유일한 유효 단위는 percent 입니다.

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

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