Pulse Width Modulation with microcontrollers

Those following the ProtoStack tutorials will be happy to hear that there is a new installment which explains Pulse Width Modulation. If you’ve never heard of PWM before, it’s a method of generating a signal that is logic 1 for a portion of the time and logic 0 for the remainder of the time. It is the most commonly used method for dimming an LED, and that’s [Daniel’s] example in this tutorial. But you’ll also find it used in many other applications such as servo motor control and piezo speaker control.

[Daniel] starts off with a brief explanation of duty cycle, then moves on to some examples of hardware and software PWM. Many of the AVR microcontrollers have a hardware PWM feature that allows you to configure a pin that toggles based on a target timer value. This is demonstrated using an ATmega168, but a method of using interrupts and your own code is also covered in case you don’t have a hardware PWM pin available.

6 thoughts on “Pulse Width Modulation with microcontrollers

  1. Hi
    Nice tutorial. Nowdays I am also working on PWM. I i I am able to generate PWM from lookup table. Would like to understand the flow diagram for multiple pwm control. i am doing coding in assembly. also using interrupts. On for duty cycle and other for freq. and there is also typical prob for 100 percent and 0 percent . how you are handeling it?

  2. Since PWM is often used to drive sets of three LEDs (red-green-blue), I’ve wondered if there is much difference (power wise) in trying to balance the on-off time (ie: all three on and off at the same time; or only one (or two) on at a time) among the three LEDs. Has anyone seen any research on this?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.