0% found this document useful (0 votes)
119 views19 pages

Pulse Width Modulation (PWM) : ECET 209 - Lecture 19 Introduction To Microcontrollers

Pulse width modulation (PWM) is a technique used to encode information in a digital signal by varying the width (or duty cycle) of pulses. PWM is commonly used to control motor speed, light dimming, voltage levels in power supplies, and audio amplification. Microcontrollers can generate PWM signals through sequential software, timer interrupts, or automatic hardware PWM using features like output compare registers and timer counter control registers to vary the pulse width. Common PWM modes include clear timer on compare match, toggle on compare match, fast PWM, and phase correct PWM.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
119 views19 pages

Pulse Width Modulation (PWM) : ECET 209 - Lecture 19 Introduction To Microcontrollers

Pulse width modulation (PWM) is a technique used to encode information in a digital signal by varying the width (or duty cycle) of pulses. PWM is commonly used to control motor speed, light dimming, voltage levels in power supplies, and audio amplification. Microcontrollers can generate PWM signals through sequential software, timer interrupts, or automatic hardware PWM using features like output compare registers and timer counter control registers to vary the pulse width. Common PWM modes include clear timer on compare match, toggle on compare match, fast PWM, and phase correct PWM.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Pulse Width Modulation (PWM)

ECET 209 – Lecture 19


Introduction to Microcontrollers
What is Pulse Width Modulation?

Pulse Width Modulation

D
F

ECET 209 Purdue University 2


Where is PWM Used?

• Motor Controllers
– Speed
• Light Dimmers
– Brightness
• Switching Power Supplies
– Output Voltage
• Audio Amplifiers
ECET 209 Purdue University 3
Methods to Produce PWM

• The Microcontroller is capable of producing


PWM is several ways
– Sequential Flow
– Timer Interrupts
– Auto PWM Generation

ECET 209 Purdue University 4


Sequential Flow
#include <delay.h>
void main (void)
{
DDRA = 0xFF;
while(1)
{
PORTA.0 = 1;
delay_ms(5);
PORTA.0 = 1;
delay_ms(5);
}
}
ECET 209 Purdue University 5
Automatic PWM

• The Microcontroller has special hardware


that will automatically create a PWM output
(no software required)

ECET 209 Purdue University 6


Output Compare Register
Pulse Width Modulation with Timer0
255
OCR0

ECET 209 Purdue University 7


Output Compare Register
Pulse Width Modulation with Timer0
255
OCR0

0
D
F

ECET 209 Purdue University 8


Automatic PWM

ECET 209 Purdue University 9


Output Compare Register
TCNT0 OCR0

Waveform Generator

ECET 209 Purdue University 10


Automatic PWM

• Several Different Modes of PWM


– Clear Timer on Compare Match
– Toggle on Compare Match
– Fast PWM
– Phase Correct PWM

ECET 209 Purdue University 11


Clear Timer on Compare Match

Clear Timer on Compare Match


255
OCR0

ECET 209 Purdue University 12


Clear Timer and Toggle on
Compare Match
Clear Timer on Compare Match with Toggle
255
OCR0

OC0

ECET 209 Purdue University 13


Fast PWM
Fast PWM
255
OCR0

OC0

ECET 209 Purdue University 14


Phase Correct PWM
Pulse Width Modulation with Timer0
255

OCR0

OC0

ECET 209 Purdue University 15


Fast PWM
Fast PWM
255
OCR0

OC0

ECET 209 Purdue University 16


Timer Counter Control Register

ECET 209 Purdue University 17


Timer Counter Control Register

ECET 209 Purdue University 18


Timer Counter Control Register

ECET 209 Purdue University 19

You might also like