Pulse Width Modulation (PWM)#
Introduction#
Pulse Width Modulation (PWM) outputs a timed pulse signal from a 3-Wire port, letting the V5 Brain control legacy motor controllers or servos by varying the pulse width (duty cycle) every 16 milliseconds (ms).
Note: Pwm objects generate a raw RC-style PWM waveform:
0% output produces a 1.5 ms pulse.
100% output produces a 2.0 ms pulse.
-100% output produces a 1.0 ms pulse.
This page uses pwm_a as the example PWM output’s name. Replace it with your own configured name as needed.
Below is a list of available methods:
Constructor – Manually initialize and configure a PWM output.
Pwm– Create a PWM output.
value#
value returns the PWM output’s value from -100 to 100 as a percent.
Usage:
pwm_a.value()
Parameters |
Description |
|---|---|
This method has no parameters. |
state#
state sets the state of the PWM output as a percent.
Usage:
pwm_a.state(value)
Parameters |
Description |
|---|---|
|
The value to set for the PWM output, from -100 to 100. |
Constructor#
Constructors are used to create Pwm objects, which are necessary for configuring a PWM output.
Pwm#
Pwm creates a PWM output.
Usage:
Pwm(port)
Parameter |
Description |
|---|---|
|
The 3-Wire Port that the PWM output is connected to:
|
# Create a PWM output in Port A
pwm_a = Pwm(brain.three_wire_port.a)