PWM 输出#
介绍#
The pwm_out class is used to control PWM (Pulse Width Modulation) output on a VEX V5 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();
参数#
范围 |
类型 |
描述 |
|---|---|---|
|
|
The 3-Wire Port the PWM output is connected to, written as |
例子#
// 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 Functionsvoid state(
int32_t value,
percentUnits units );
范围 |
类型 |
描述 |
|---|---|---|
|
|
PWM 输出的新设置值,范围从 -100% 到 +100%。 |
|
|
The unit used to represent the PWM value:
|
此函数不返回值。
NotesPWM 输出值范围为 -100% 至 +100%。
The only valid unit for PWM output is
percent.
// Set the PWM Output to 50%
pwm.state(50, percent);
// Set the PWM Output to -75%
pwm.state(-75, percent);