PWM Pulse Width Modulation

Slides:



Advertisements
Similar presentations
By: Zak Ahmad Phuc Dao Joel Toussaint. Outline Introduction PWM Definitions Generation Types PWM on the HCS 12 Applications 2 Presented by Zak Ahmad.
Advertisements

Analog-to-Digital Converter (ADC) And
8253/54 Timer Section /54 Timer Description and Initialization
Sensors Interfacing.
PWM Pulse Width Modulation
Abstract Conclusion PWM Modulating Signal Results Generation of DSP-based patterns to control three phase inverters substantially helped the development.
Digital to Analog and Analog to Digital Conversion
Announcements Assignment 8 posted –Due Friday Dec 2 nd. A bit longer than others. Project progress? Dates –Thursday 12/1 review lecture –Tuesday 12/6 project.
Data Acquisition Risanuri Hidayat.
5/4/2006BAE Analog to Digital (A/D) Conversion An overview of A/D techniques.
Lecture 9: D/A and A/D Converters
1. Output signal alternates between on and off within specified period Controls power received by a device The voltage seen by the load is directly proportional.
DIGITAL SYSTEMS TCE INTERFACING WITH ANALOG DEVICES (Week 12)
Interfacing with the Analog World Wen-Hung Liao, Ph.D.
Analogue to Digital Conversion
EET260: A/D and D/A converters
4.2 Digital Transmission Pulse Modulation (Part 2.1)
COMP3221: Microprocessors and Embedded Systems Lecture 20: Analog Output Lecturer: Hui Wu Session 2, 2004.
Electronic Instrumentation 1 Experiment 7 Digital Logic Devices and the 555 Timer Part A: Basic Logic Gates Part B: Flip Flops Part C: Counters Part D:
Pulse Width Modulation
Pulse Width Modulation Professor: Dr. Miguel Alonso Jr.
Pulse Width Modulation A Student Presentation By: Wayne Maxwell Martin Cacan Christopher Haile.
Digital to Analog Converters
THANGJAM105/MAPLD1 EFFICIENT FPGA IMPLEMENTATION OF PWM CORE.
Digital to Analog and Analog to Digital Conversion
Introductory Digital Concepts
General Licensing Class G7A – G7C Practical Circuits Your organization and dates here.
Power Electronics and Drives (Version ) Dr. Zainal Salam, UTM-JB 1 Chapter 3 DC to DC CONVERTER (CHOPPER) General Buck converter Boost converter.
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
1 Sensors and Measurements Penderia & Pengukuran ENT 164 Signal Processing Elements Hema C.R. School of Mechatronics Engineering Northern Malaysia University.
Digital Fundamentals Floyd Chapter 1 Tenth Edition
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
8253 TIMER. Engr 4862 Microprocessors 8253 / 8254 Timer A.k.a. PIT (programmable Interval Timer), used to bring down the frequency to the desired level.
Chapter 13 Linear-Digital ICs. Copyright ©2009 by Pearson Education, Inc. Upper Saddle River, New Jersey All rights reserved. Electronic Devices.
Lecture 29: LM3S9B96 Microcontroller – Pulse Width Modulator (PWM)
PIT: Programmable Interval Timer
Electronics for PS and LHC transformers Grzegorz Kasprowicz Supervisor: David Belohrad AB-BDI-PI Technical student report.
General Licensing Class Oscillators & Components Your organization and dates here.
ACOE2551 Microprocessors Data Converters Analog to Digital Converters (ADC) –Convert an analog quantity (voltage, current) into a digital code Digital.
Lecture # 12&13 SWITCHING-MODE POWER SUPPLIES
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals with PLD Programming.
PWM Circuit Based on the 555 Timer. Introduction In applications LED Brightness Control we may want to vary voltage given to it. Most often we use a variable.
Lecture 15: Digital to Analog Converters Lecturers: Professor John Devlin Mr Robert Ross.
Data Acquisition ET 228 Chapter 15 Subjects Covered Analog to Digital Converter Characteristics Integrating ADCs Successive Approximation ADCs Flash ADCs.
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals.
Automatic accident avoiding system PROJECT MEMBERS MUTHUKUMAR.K (05ME33) SAKTHIDHASAN.S (05ME39) SAKTHIVEL.N (05ME40) VINOTH.S (05ME56) PROJECT GUIDE:
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Pulse Width Modulator (PWM) Refer to Chapter 21 in the reference book “Stellaris® LM3S9B96 Microcontroller.
8254 Timer.
Floyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd © 2008 Pearson Education Chapter 1.
School of Computer and Communication Engineering, UniMAP Mohd ridzuan mohd nor DKT 122/3 - DIGITAL SYSTEM I Chapter.
Digital to Analog Converter (DAC)
Chapter 9 CAPACITOR.
Lecture Notes / PPT UNIT III
Electronic Devices and Circuit Theory
UNIT III DC Choppers.
Why are Timer Functions Important?
Timers and Event Counters
EI205 Lecture 13 Dianguang Ma Fall 2008.
Digital Communication
Programmable Interval Timer
Oct 30 Announcements Code Marked and on Blackboard
Oct 30 Announcements Code Marked and on Blackboard
CBC Fundamentals Lecture is based on material from Robotic Explorations: A Hands-on Introduction to Engineering, Fred Martin, Prentice Hall, 2001.
ME 4447/6405 Pulse Width Modulation (PWM)
General Licensing Class
UNIT-8 INVERTERS 11/27/2018.
Digital Fundamentals Floyd Chapter 1 Tenth Edition
Analog-to-digital converter
8253 – PROGRAMMABLE INTERVAL TIMER (PIT). What is a Timer? Timer is a specialized type of device that is used to measure timing intervals. Timers can.
Chapter 7 Converters.
Presentation transcript:

PWM Pulse Width Modulation ME 4447/6405 November 6th, 2012 Ellen Qiulei Huang Juan Orphee Austin Farmer

Outline Introduction Analog vs. Digital Actuation -- What is PWM? Analog vs. Digital Actuation Consideration on PWM frequency Implementation on the HCS12 --Register Setup Examples of PWM configuration using assembly and C -- Applications of PWM

Presenter: Ellen Qiulei Huang Introduction -- What is PWM? Analog vs. Digital Actuation Consideration on PWM frequency Implementation on the HCS12 -- Register Setup Examples of PWM configuration using assembly and C -- Applications of PWM

Ellen Qiulei Huang What is PWM? Pulse Width Modulation (PWM) is a technique for delivering partial power to a load via digital means. The on-off behavior changes the average power of signal. Output signal alternates between on and off within specified period. http://www.youtube.com/watch?v=Lf7JJAAZxEU

Duty Cycle A percentage measurement of how long the signal stays on. Ellen Qiulei Huang A percentage measurement of how long the signal stays on. Period (T) Duty Cycle (D) VL VH On Off

Duty Cycle Duty Cycle: Average signal : Ellen Qiulei Huang Duty Cycle Duty Cycle: Average signal : (Usually, VL is taken as zero volts for simplicity.) Period (T) Duty Cycle (D) VL VH On Off

Duty Cycle Characteristic Ellen Qiulei Huang Duty Cycle Characteristic The average value of a PWM signal increases linearly with the duty cycle

Types of PWM – Left Aligned Ellen Qiulei Huang Types of PWM – Left Aligned Lead edge is fixed, the trailing edge is modulated. On Off On Off Vhi Vhi Duty Cycle ~30% Duty Cycle ~60% Vlo Vlo Period Period

Types of PWM – Right Aligned Ellen Qiulei Huang Types of PWM – Right Aligned Trailing edge is fixed, lead edge is modulated. Off On Off On Vhi Vhi Duty Cycle ~30% Duty Cycle ~60% Vlo Vlo Period Period

Types of PWM – Center Aligned Ellen Qiulei Huang Types of PWM – Center Aligned Center of signal is fixed, both edges are modulated Off On Off Off On Off Vhi Vhi Duty Cycle ~30% Duty Cycle ~60% Vlo Vlo Period Period

Analog Generation of PWM Ellen Qiulei Huang Analog Generation of PWM Analog PWM signals can be made by combining a saw- tooth waveform and a sinusoid PWM output is formed by the intersection of the saw-tooth wave and sinusoid. PWM toggles when sine equals saw-tooth.

Digital Generation - Delta Method Ellen Qiulei Huang Digital Generation - Delta Method Limit signals are offset from a reference When output signal reaches limits, PWM state changes

Digital Generation - Delta Method Ellen Qiulei Huang Digital Generation - Delta Method Quantizer converts the difference between output and limits. Quantizer can be realized with a comparator whose output is 1 or 0 if the input signal is positive or negative.

Digital Generation - Delta Sigma Method Ellen Qiulei Huang Digital Generation - Delta Sigma Method PWM signal generated by Delta method Error = Ref – PWM Error is integrated. When integration signal reaches limit, PWM state changes.

Digital Generation - Delta Sigma Method Ellen Qiulei Huang Digital Generation - Delta Sigma Method

Choosing your PWM frequency Ellen Qiulei Huang Choosing your PWM frequency Input signal (PWM) Ripple Output signal (actuator response)

Choosing your PWM frequency Ellen Qiulei Huang Choosing your PWM frequency Resolution: Inversely proportional to the number of distinct duty cycles you can generate for a given period Transitions can only occur on a clock tick Frequency limited by your clock and desired resolution Example: 8 MHz clock, choose PWM to be 4 MHz Limited resolution: only 3 duty cycles to choose from

Avoid ripple, Resolution loss, Power loss, Human hearing Ellen Qiulei Huang Avoid ripple, Resolution loss, Power loss, Human hearing Consideration on PWM frequency Lower Limits Upper Limits Must be at least 10 times higher than the control system frequency Higher than 20kHz – audible frequency of sounds to avoid annoying sound disturbances. If too low the motor is pulsed, not continuous, because the motor’s inductance can not maintain the current Inverse of frequency should be much less than the motor/load time constant Higher error from ripple voltages If too high the inductance of the motor causes the current drawn to be unstable MOSFET transistor generates heat during switching Limited by resolution of controller Eddy currents generated in electromagnetic coils which lead to adverse heating Heat losses in electromagnetic materials is proportional to frequency squared

Advantages of PWM Average value proportional to duty cycle, D Ellen Qiulei Huang Advantages of PWM Average value proportional to duty cycle, D Low power used in transistors used to switch the signal Fast switching possible due to MOSFETS and power transistors at speeds in excess of 100 kHz Digital signal is resistant to noise Less heat dissipated versus using resistors for intermediate voltage values

Disadvantages of PWM Cost Complexity of circuit Voltage spikes Ellen Qiulei Huang Disadvantages of PWM Cost Complexity of circuit Voltage spikes Susceptible to Electromagnetic Interference

Presenter: Juan Orphee Introduction -- What is PWM? Analog vs. Digital Actuation Consideration on PWM frequency Implementation on the HCS12 --Register Setup Examples of PWM configuration using assembly and C -- Applications of PWM

Pulse Width Modulator: PWM8B6CV1 Juan Orphee Pulse Width Modulator: PWM8B6CV1 Use Port P Six 8-bit channels or three 16-bit channels for greater resolution Each channel produces an independent PWM signal Two choices of clock sources per channel which provides for a wide range of frequencies

Juan Orphee PWM Block Diagram -Each channel needs setup of the following registrars: Enable/disable Signal Polarity Clock A or SA, B or SB Prescale A and B clocks Center Alignment Enable Control Register Prescale SA and SB clocks Counter Period Duty Cycle Emergency Shutdown Define PWM signal Vhi Duty Cycle Vlo Period

PWM Register Memory Map Juan Orphee

1-PWM Enable Register (PWME) Juan Orphee PWME in address: $00E0 Set PWMEx to 1 to enable the channel Set PWMEx to 0 to disable the channel

2-PWM Polarity Register (PWMPOL) Juan Orphee PWMPOL in address: $00E1 Set PPOLx to 0, signal goes from low to high Set PPOLx to 1, signal goes from high to low Signal Starts Here Zero Line

3-PWM Clock Select Register (PWMCLK) Juan Orphee PWMCLK in address: $00E2 Set PCLK(5/4/1)  0 to use clock A Set PCLK(5/4/1)  1 to use clock SA Set PCLK(3/2)  0 to use clock B Set PCLK(3/2)  1 to use clock SB Note: choice of Prescale will determine clock selection

4-PWM Prescale Clock Select Register (PWMPRCLK) Juan Orphee Located at $00E3 Used to prescale clocks A and B Desired PWD Frequency N = bit resolution -Similar for Clock B Bus Clock HCS12 = 8 MHz -If calculated prescaler > 128 then use clock SA -How to convert time (e.g. in seconds) to cycles? Time (sec) x Clock Frequency = Time (sec) x (Buss Clock/Prescaler)

Computing a Prescaler Duty Cycle T (sec) Period Time per clock cycle (sec) = Prescaler x Time (sec) per bus clock cycle 125x10(-9) sec for HCS12 -Resolution = Maximum Clock Counts -Example: An 8 bit counter can count 2^N-1 = 255 clock cycles T (sec) Period

5-PWM Center Align Enable Register(PWMCAE) Juan Orphee Located at $00E4 Set CAEx to 0 for left align signal Set CAEx to 1 for center align signal Note: Can only be set when channel is disabled

Left vs. Center Aligned Juan Orphee Not To Scale PWM Signal Starts

6-PWM Control Register (PWMCTL) Juan Orphee 6-PWM Control Register (PWMCTL) PWMCTL : Located at $00E5 Set CONxy to 0 to keep 6 PWM channels separate (8-bit) Set CONxy to 1 to concatenate PWM channels x and y together (16-bit). x becomes the high byte and y becomes the low byte Channel y determines the configuration Bits PSWAI and PFRZ set either wait or freeze mode Note Changes only occur when both channels are disabled

7-PWM Scale A Register (SA Clock) (PWMSCLA) Juan Orphee 7-PWM Scale A Register (SA Clock) (PWMSCLA) Located at $00E8 Programmable scaling of clock A to generate clock SA Note

PWM Scale B Register (PWMSCLB) Juan Orphee PWM Scale B Register (PWMSCLB) Located at $00E9 Programmable scaling of clock B to generate clock SB Note

8-PWM Channel Counter Register (PWMCNT) Juan Orphee Located at $00EC through $00F1 One per channel It tracks the cycle counts When channel is enabled up-count starts Note Writing to counter while a channel is enable can cause irregular PWM cycles

Counter: Left vs. Center Aligned Juan Orphee In the left aligned mode, the PWM counts up until (period-1) and resets to zero. In the center aligned mode, the PWM counts up until (period-1) and counts down to zero. Note: Period (PWMPER) is expressed in number of cycles PWM Signal Starts

9-PWM Channel Period Register (PWMPER) Juan Orphee =$00F2 Located at $00F2 through $00F7 PWMPERx Store a hexadecimal value to limit maximum value of counter Note : Changes occur when one of following happen Current period ends Counter is written to Channel is disabled What is my PWMPER? PWMPER (cycles) = PWM Period(sec) x Clock Freq(cycles/sec)

10-PWM Channel Duty Register (PWMDTY) Juan Orphee Located at $00F8 through $00FD Store a hexadecimal value to control when signal changes Changes occur when: Current period ends Counter written to Channel is disabled e.g for 60% duty cycle: PWMDTY = 0.6xPWMPER (in cycles)

11-PWM Shutdown Register (PWMSDN) Juan Orphee 11-PWM Shutdown Register (PWMSDN) $00FE

Presenter: Austin Farmer Introduction -- What is PWM? Analog vs. Digital Actuation Consideration on PWM frequency Implementation on the HCS12 - Register configuration Example of PWM configuration using Assembly and C Code Applications of PWM

PWM Configuration Example Austin Farmer PWM Configuration Example Use PWM Channel 0 Positive polarity (signal goes from high to low) Left aligned output Frequency: 40 kHz Period = 1/Frequency = 1/40 kHz = 25 μs Choose clock source using resolution: Bus clock frequency: 125 ns  25 μs / 125 ns = 200 cycles 200 < 255, select clock A with prescaler = 1 Duty Cycle = 50% (50% * 200 cycles) = 100 cycles

Configuration Example: Assembly Code Austin Farmer Configuration Example: Assembly Code PWME EQU $00E0 * 1-PWM Enable Register PWMPOL EQU $00E1 * 2-PWM Polarity Register PWMCLK EQU $00E2 * 3-PWM Clock Select Register PWMPRCLK EQU $00E3 * 4-PWM Prescale Clk Select Reg. PWMCAE EQU $00E4 * 5-PWM Center Align Enable Reg. PWMPER0 EQU $00F2 * 9-PWM Channel 0 Period Register PWMDTY0 EQU $00F8 * 10-PWM Channel 0 Duty Register ORG $1000 LDAA #$01 STAA PWMPOL *Positive polarity (starts high) LDAA #$00 STAA PWMCAE *Left aligned output STAA PWMCLK *Use Clock A STAA PWMPRCLK *Clock A prescaler = 1 LDAA #$C8 STAA PWMPER0 *Period =(25μs/125ns)= 200 = $C8 LDAA #$64 STAA PWMDTY0 *Duty cycle=(200*50%)= 100 = $64 STAA PWME *Enable PWM Channel 0 ...

Configuration Example: C Code Austin Farmer Configuration Example: C Code #include <hidef.h> /* common defines and macros */ #include <mc9s12c32.h> /* derivative information */ #pragma LINK_INFO DERIVATIVE “mc9s12c32” // Set up chip in expanded mode MISC = 0x03; PEAR = 0x0C; MODE = 0xE2; //Set up PWM Registrer PWMCLK = 0; // Sets source clock to clock A PWMPOL = 1; // Positive Polarity (signal goes from high to low) PWMCTL = 0; // Makes all channels 8-bit PWMCAE = 0; // Signals are left aligned PWMPER0 = 200; // Sets the period of the signal to 200 clock cycles PWMDTY0 = 100; // Makes the duty cycle 100 clock cycles (50% of 200) PWMPRCLK = 0; // Sets the prescaler to 1 PMWE = 1; // Enables and starts Channel 0 of PWM ….

Austin Farmer Motivation for PWM In the past, motors were controlled at intermediate speeds by using variable resistors to lower delivered power (inefficient) Example: Foot pedal on sewing machines is a variable resistor connected in series to control speed PWM provides a more compact way of applying adjustable power to devices

Applications of PWM Voltage regulation DC Motors Telecommunications Austin Farmer Applications of PWM Voltage regulation DC Motors Telecommunications Audio and Video Effects

Application: Voltage Regulation Austin Farmer Application: Voltage Regulation PWM is used in efficient voltage regulators With appropriate duty cycle, the output will approximate voltage at the desired level Switching noise can be filtered

Application: DC Motors Austin Farmer Application: DC Motors Commonly used to control the speed of a DC motor Continuous application of PWM cycle results in average voltage being applied to motor Output speed of motor is proportional to input voltage http://www.youtube.com/watch?v=Lf7JJAAZxEU Used in Lab 3

Application: Telecommunications Austin Farmer Application: Telecommunications Pulses of various lengths will be sent at regular intervals (the carrier frequency of the modulation) The widths of the pulses correspond to specific data values encoded at one end and decoded at the other Leading edge of the data used as clock because small offset is included More resistant to noise effects than binary data alone

Applications: Audio and Video Austin Farmer Applications: Audio and Video In audio circuits, PWM can produce an effect similar to a chorus Used in new class of efficient audio amplifiers PWM dimming provides superior color quality in LED video display (millions of colors)

Questions?