Feedback
Feedback

If you are having issues with the exercises, please create a ticket on DevZone: devzone.nordicsemi.com
Click or drag files to this area to upload. You can upload up to 2 files.

Pulse Width Modulation (PWM)

Pulse Width Modulation (PWM) is a technique used to encode information in the form of a varying signal by changing the width of pulses in a sequence of pulses. It is commonly used in electronics to control the average power delivered to a load, such as in motor control, light dimming, or generating analog signals from digital ones.

By varying the width of the pulse, i.e., determining the amount of time the signal should stay high (on) and low (off), we can control the power delivered to the assigned GPIOs. The portion of the period where the PWM signal is high is called the duty cycle.

The duty cycle in PWM is expressed as a percentage and represents the ratio of time the signal is high relative to the total period. A higher duty cycle means that the signal is on for a larger percentage of the period, resulting in a higher average output voltage for that duration. A lower duty cycle leads to a lower average output voltage.

Some terms and formulas that can be good to know are

  • Period: Cycle time, i.e time on + off
  • Frequency: 1/Period
  • Amplitude: Maximum voltage – minimum voltage
  • Duty cycle: Time on / Period

The PWM module enables the generation of a pulse with modulated signals on a GPIO, and implements an up or down counter with four PWM channels that drive assigned GPIOs.

For example, the PWM module on the nRF52840 can provide up to four PWM channels with individual polarity and duty cycle values that can be used independently of each other. This means that you can drive multiple entities using a PWM signal generated from this module, each having a different duty cycle and/or polarity.

There are also different configurations of PWM output:

  • Single-edge controlled PWM output: Falling or rising edge position can be controlled.
  • Double edge controlled PWM output: Both rising and falling edge can be controlled.
PWM up-and-down counter example
PWM up counter example – FallingEdge polarity

Register an account
Already have an account? Log in
(All fields are required unless specified optional)

  • 8 or more characters
  • Upper and lower case letters
  • At least one number or special character

Forgot your password?
Enter the email associated with your account, and we will send you a link to reset your password.