0% found this document useful (0 votes)
219 views

Introduction To Pulse Width Modulation (PWM)

Pulse width modulation (PWM) is a technique for controlling the power delivered to a device by alternately turning an output signal on and off within a specified period. The duty cycle, which is the ratio of on time to total period time, determines the average voltage seen by the load. PWM can be used to control motors, LED intensity, and other applications by digitally controlling the duty cycle. Software PWM uses a counter and output pins to generate the PWM signal, while hardware PWM IP provides a configurable and precise PWM generation core.

Uploaded by

Florin Giurca
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
219 views

Introduction To Pulse Width Modulation (PWM)

Pulse width modulation (PWM) is a technique for controlling the power delivered to a device by alternately turning an output signal on and off within a specified period. The duty cycle, which is the ratio of on time to total period time, determines the average voltage seen by the load. PWM can be used to control motors, LED intensity, and other applications by digitally controlling the duty cycle. Software PWM uses a counter and output pins to generate the PWM signal, while hardware PWM IP provides a configurable and precise PWM generation core.

Uploaded by

Florin Giurca
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Introduction to

Pulse Width Modulation (PWM)


What is PWM?
 Output signal alternates between on and off
within specified period.
 Control the power received by a device.
 The voltage seen by the load is directly
proportional to the source voltage.

10/24/2016 2
What is PWM?
1
Duty cycle = 20%
on off
0.2

Duty cycle = 50%


0.5 on off

Width
period

 Depending on the requirement the width of


the pulse is modulated (adjusted).
 Duty cycle = ton / (ton + toff).
10/24/2016 3
Why PWM?

Maximum
voltage

100 %
75 %
50 %

 Analog voltage control:


o Voltage can be changed to control the motor speed
o Can NIOS change voltage ?
10/24/2016 4
Why PWM?
1

50 % =
0
t t
Analog Digital
control control

 Digital voltage control:


o Can only control ‘1’ and ‘0’
o X% of maximum analog voltage = X% of duty cycle
10/24/2016 5
PWM Control Example
 Disco gate:
o 100 % open gate = 10 persons per second
o 50% open gate = 5 persons per second
 Analog control:
o Open 50 % gate
o Total how many people can go in 10 seconds?
 Digital control:
o Open 100 % gate on every odd second (1,3,5,7,9, ..)
o Total how many people can go in 10 seconds?

10/24/2016 6
Usage of PWM
 Motor Control

 Intensity of LED

10/24/2016 7
How to generate PWM signal?
 Software method
o Using counter
• Count to 100 in a loop
• Set the output value to 1 in the beginning of the loop
• Set the output value to 0 as soon as the counter
reaches the value of required duty cycle.
• Continue the process
o Using interrupt
• Home work
• Think about the concept

10/24/2016 8
Your tasks
 Create projects in a usual way using provided
SOPCINFO file.
 Type the code in your application project.
 Change duty cycle variable and observe the
effect on oscilloscope or LED.
 Using oscilloscope, verify the duty cycle.
o Is it precise?
o Is it efficient?

10/24/2016 9
Software PWM
 Output pin:
o GPIO_0[0] ==> find this pin in the user manual
o Using the manual find out the correct pin and
observe the resulting PWM on the oscilloscope
o In C program, use the following instructions to
change the output
• IOWR(PIO_0_BASE, 0, 0); // set output 0
• IOWR(PIO_0_BASE, 0, 1); // set output 1
 Control LED (optional):
o Apply the PWM signal to LED, observe the intensity
10/24/2016 10
Questions

10/24/2016 11
Hardware PWM IP
PWM NIOS core JTAG Uart

Blaster
USB
RAM
Your PC

 Programmable/configurable
 Precise

10/24/2016 12
Hardware PWM IP
 Follow the simple use sequence
o Enable
o Configure
o Modify
o Disable
 Only one function for controlling two PWM signals
motor_setting(phase1, duty1,
phase2, duty2,
period, enable);
10/24/2016 13
Hardware PWM IP
motor_setting(phase1, duty1,
phase2, duty2,
period, enable);
Enable mask= 1
Common Disable = 0
period

10/24/2016 14
Questions

10/24/2016 15

You might also like