The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Pulse Width Modulator (PWM) Refer to Chapter 21 in the reference book “Stellaris® LM3S9B96 Microcontroller.

Slides:



Advertisements
Similar presentations
MOTION CONTROL ECE 105 Industrial Electronics Engr. Jeffrey T. Dellosa College of Engineering and Information Technology Caraga State University Ampayon,
Advertisements

The 8051 Microcontroller and Embedded Systems
More fun with Timer/Counters
Programmable Interval Timer
555 Timer ©Paul Godin Updated February Oscillators ◊We have looked at simple oscillator designs using an inverter, and had a brief look at crystal.
0 - 1 © 2007 Texas Instruments Inc, Content developed in partnership with Tel-Aviv University From MATLAB ® and Simulink ® to Real Time with TI DSPs Class-D.
Introduction of Holtek HT-46 series MCU
Refer to Chapter 6, 9 in the reference book
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – System Control Refer to Chapter 6 in the reference book “Stellaris® LM3S9B96 Microcontroller.
Pulse Width Modulation (PWM) LED Dimmer Circuit
Lecture 27: LM3S9B96 Microcontroller – Inter- Integrated Circuit (I 2 C) Interface.
T IMERS - 2. O UTPUT U NIT Each capture/compare block contains an output unit. The output unit is used to generate output signals such as PWM signals.
16-Bit Timer/Counter 1 and 3 Counter/Timer 1,3 (TCNT1, TCNT3) are identical in function. Three separate comparison registers exist. Thus, three separate.
Software Three Main Functions Records/Monitors Zero Detection Points Gives our PWM a starting point Data used to dynamically adjust carrier frequency Detects.
ET3380 Principles and Methods of Electric Power Conversion David Morrisson MS,MBA Week 1.
Digital Fundamentals Floyd Chapter 1 Tenth Edition
Lecture 26: LM3S9B96 Microcontroller – Universal Asynchronous Receivers/Transmitters.
ENEE 440 Chapter Timer 8254 Register Select The 8254 timer is actually 3 timers in one. It is an upgraded version of the 8253 timer which was.
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
Lecture 29: LM3S9B96 Microcontroller – Pulse Width Modulator (PWM)
ARM Timers.
PWM ECE 4437-EMBEDDED SYSTEMS DR. GLOVER CHRISTOPHER AHN & KHOA VAN.
MS_uC / fue1 / V TIMx - Timer Programming Microcontroller TIMx - Timer Autumn term 2012.
Timers ELEC 330 Digital Systems Engineering Dr. Ron Hayne
Timer Peripherals.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
SIGMA-DELTA ADC SD16_A Sigma-Delta ADC Shruthi Sujendra.
Lecture 25: LM3S9B96 Microcontroller – Watchdog Timer.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals with PLD Programming.
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Universal Asynchronous Receivers/Transmitters Refer to Chapter 13 in the reference book “Stellaris®
CCP MODULES  The CCP module (Capture/Compare/PWM) is a peripheral which allows the user to time and control different events.  Capture Mode provides.
Software Three Main Functions Records/Monitors Zero Detection Points Gives our PWM a starting point Data used to dynamically adjust carrier frequency Detects.
1 68HC11 Timer Chapter HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output.
Lecture 12 Multi-Function Timer Pulse Unit 2 (MTU2a)
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals.
Conclusion Speech. Content Organization Pronunciation Handwriting.
8254 Timer.
Floyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd © 2008 Pearson Education Chapter 1.
Refer to Chapter 15 in the reference book
1 68HC11 Timer HC11 or HC12: Chapter HC11 Timer Subsystem  Several timing functions: Basic timing Basic timing Real time interrupts Real time.
June 9, s Massachusetts Institute of Technology 6.11s: Design of Motors, Generators and Drive Systems Switching Patterns and Simple Implementation.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose This course provides an introduction to the peripheral functions.
NATCAR SUMMER CLASS II 6 July 2004 Chung Hsieh. Topic of Discussion Power Supply Motor Drive Circuits Braking.
Lecture 4 General-Purpose Input/Output NCHUEE 720A Lab Prof. Jichiang Tsai.
Lecture 22: LM3S9B96 Microcontroller – SysTick and General-Purpose Timers.
#1 of 10 Tutorial Introduction PURPOSE -To explain how to configure and use the Timer Interface Module in common applications OBJECTIVES: -Identify the.
Timer 1 and 2 operation, PWM Principles. Timer 1 Operation.
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Watchdog Timers Refer to Chapter 11 in the reference book “Stellaris® LM3S9B96 Microcontroller.
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Interrupts Refer to Chapter 4 in the reference book “Stellaris® LM3S9B96 Microcontroller - DATA.
-AT91SAM7X256 – Pulse Width Modulation YoonMo Yeon
Electronic Devices and Circuit Theory
Application Case Study Christmas Lights Controller
Why are Timer Functions Important?
Timers and Event Counters
ECE 3430 – Intro to Microcomputer Systems
Timer and Interrupts.
Microcontroller Applications
Refer to Chapter 5 in the reference book
Predefined Speed Control of BLDC Motor
Refer to Chapter 10 in the reference book
Pulse Width Modulation (PWM) Motor Feedback - Shaft Encoder
RX 8-Bit Timer (TMR) 4/20/2011 Rev. 1.00
Unit IV 555 Timer.
ME 4447/6405 Pulse Width Modulation (PWM)
Digital Fundamentals Floyd Chapter 1 Tenth Edition
Lecture 12 Multi-Function Timer Pulse Unit 2 (MTU2a)
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.
Presentation transcript:

The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Pulse Width Modulator (PWM) Refer to Chapter 21 in the reference book “Stellaris® LM3S9B96 Microcontroller - DATA SHEET”

Pulse Width Modulator (PWM) zUsing analog signal (continuous in terms of both voltage and current) to control devices (e.g., a rheostat) zSimple and straightforward zBUT: not easy to regulate, not power efficient, not resilient to noise zPWM is a powerful technique for digitally encoding analog signal levels zThe average value of voltage (and current) fed to the load is controlled by turning the switch between supply and load on and off at a fast pace zE.g., several times a minute in an electric stove, 120 Hz in a lamp dimmer, from few kilohertz (kHz) to tens of kHz for a motor drive, tens or hundreds of kHz in audio amplifiers and computer power supplies zThe duty cycle of the square wave is modulated to encode an analog signal zPower loss in the switching devices is very low: “on” no current, “off” not voltage drop

Pulse Width Modulator (PWM)

H Bridge for Motor Control An H bridge is an electronic circuit that enables a voltage to be applied across a load in either directionelectronic circuit S1S2S3S4Result 1001Motor moves right 0110Motor moves left 0000Motor free runs 0101Motor brakes Shoot-through

Pulse Width Modulator (PWM) zThe Stellaris PWM module consists of four PWM generator blocks and a control block zEach PWM generator block has the following features: zProvides low-latency shutdown and prevents damage to the motor being controlled zOne 16-bit counter zTwo PWM comparators zPWM signal generator zDead-band generator

Pulse Width Modulator (PWM) zThe control block determines the polarity of the PWM signals and which signals are passed through to the pins zThe PWM control block has the following options: zPWM output enable of each PWM signal zOptional output inversion of each PWM signal zOptional fault handling for each PWM signal zSynchronization of timers/comparators/PWM generators across the PWM generator blocks zInterrupt status summary of the PWM generator blocks zExtended fault capabilities with multiple fault signals, programmable polarities, and filtering

Block Diagram

PWM Module Block Diagram

Functional Description zPWM Timer zIn Count-Down mode: zThe timer counts from the load value to zero zGoes back to the load value, and continues to count down zIn Count-Up/Down mode: zThe timer counts from zero up to the load value zCounts down to zero zCounts up to the load value, and so on zCount-Down mode is used for generating left- or right- aligned PWM signals, while the Count-Up/Down mode is used for generating center-aligned PWM signals

Functional Description zPWM Timer zOutputs three signals that are used in the PWM generation process: zThe direction signal (“dir” signal): “low” when counting down, and “high” when counting up zA single-clock-cycle-width High pulse when the counter is zero (“zero” signal) zA single-clock-cycle-width High pulse when the counter is equal to the load value (“load” signal)

Functional Description zPWM Comparators zEach PWM generator has two comparators that monitor the value of the counter zWhen either comparator matches the counter, they output a single-clock-cycle-width High pulse, "cmpA" and "cmpB” zThese qualified pulses are used in the PWM generation process

Signals Used in PWM Generation

Functional Description zPWM Signal Generator ztakes the “load”, “zero”, “cmpA”, and “cmpB” pulses (qualified by the dir signal) zgenerates two internal PWM signals, “pwmA” and “pwmB” zIn Count-Down mode: zero, load, match A down, and match B down zIn Count-Up/Down mode: zero, load, match A down, match A up, match B down, and match B up zFor each event, the effect on each output PWM signal is programmable

PWM Generation Example In Count- Up/Down Mode zpwmA is set to drive High on match A up, drive Low on match A down, and ignore the other four events zpwmB is set to drive High on match B up, drive Low on match B down, and ignore the other four events

Functional Description zDead-Band Generator zThe generated pwmA and pwmB signals can be passed to the dead-band generator zIf the dead-band generator is disabled, pwmA and pwmB signals will not be modified zIf the dead-band generator is enabled, the pwmB signal is lost and two PWM signals are generated based on the pwmA signal, pwmA’ and pwmB’ zpwmA’ is pwmA with the rising edge delayed zpwmB’ is the inversion of pwmA with a delay added between the falling edge of pwmA and the rising edge of pwmB’

PWM Dead-Band Generator

Functional Description zInterrupt/ADC-Trigger Selector zThe same four (or six) counter events can be used to generate an interrupt zAny of these events or a set of these events can be selected zDifferent or the same events can be selected to generate an ADC trigger

Functional Description zSynchronization zFour PWM generators providing eight PWM outputs zUnsynchronized: each PWM generator and its two output signals are used alone, independent of other PWM generators zSynchronized: The PWM generator and its two outputs signals are used in conjunction with other PWM generators using a common and unified time base zSet the “SYNCn” bits in the PWMSYNC register will cause corresponding PWM generators reset their counter together

Functional Description zFault Conditions zWhen fault conditions happen, the PWM function must be stopped and the PWMn signals should be set to a safe state zTwo basic situations cause fault conditions: zThe microcontroller is stalled and cannot perform the necessary computation in the time required for motion control zAn external error or event is detected zThe following inputs can be used to generate a fault condition zFAULTn fault input pins zA stall of the controller generated by the debugger zThe trigger of an ADC digital comparator zFault conditions are calculated on a per-PWM generator basis

Functional Description zOutput Control Block zTakes care of the final conditioning of the pwmA' and pwmB' signals before they go to the pins as the PWMn signals. zThe set of PWM signals that are actually enabled to the pins can be modified via the PWNENABLE register zDuring fault conditions, PWMn usually must be driven to safe values zUse PWMFAULT register to specify whether the output continues to use the generated signal or an encoding specified in the PWMFAULTVAL register zA final inversion can be applied to any of the PWMn signals using the PWMINVERT register

Initialization and Configuration zThe following example shows how to initialize PWM Generator 0 with a 25-kHz frequency, a 25% duty cycle on the PWM0 pin, and a 75% duty cycle on the PWM1 pin, assuming the system clock is 20 MHz 1.Enable the PWM clock by writing a value of 0x to the RCGC0 register 2.Enable the clock to the appropriate GPIO module via the RCGC2 register 3.In the GPIO module, enable the appropriate pins for their alternate function using the GPIOAFSEL register 4.Configure the PMCn fields in the GPIOPCTL register to assign the PWM signals to the appropriate pins 5.Configure the RCC register in the System Control module to use the PWM divide (USEPWMDIV) and set the divider (PWMDIV) to divide by 2 (000).

Recall: Clock Control

Initialization and Configuration 6.Configure the PWM generator for countdown mode with immediate updates to the parameters 1.Write the PWM0CTL register with a value of 0x Write the PWM0GENA register with a value of 0x C 3.Write the PWM0GENB register with a value of 0x C 7.Set the period: for a 25-KHz frequency, the period = 1/25,000, or 40 microseconds. The PWM clock source is 10MHz. Thus, there are 400 clock ticks per period. Use this value to set the PWM0LOAD register. In Count- Down mode, set the LOAD field in the PWM0LOAD register to the requested period minus one 1.Write the PWM0LOAD register with a value of 0x F

Initialization and Configuration 8.Set the pulse width of the PWM0 pin for a 25% duty cycle: Write the PWM0CMPA register with a value of 0x B 9.Set the pulse width of the PWM1 pin for a 75% duty cycle: Write the PWM0CMPB register with a value of 0x Start the timers in PWM generator 0 : Write the PWM0CTL register with a value of 0x Enable PWM outputs: Write the PWMENABLE register with a value of 0x

Key Registers: PWMnCTL

Key Registers: PWMnGENA Register 44: PWM0 Generator A Control (PWM0GENA), offset 0x060 Register 45: PWM1 Generator A Control (PWM1GENA), offset 0x0A0 Register 46: PWM2 Generator A Control (PWM2GENA), offset 0x0E0 Register 47: PWM3 Generator A Control (PWM3GENA), offset 0x120

Key Registers: PWMnGENB Register 48: PWM0 Generator B Control (PWM0GENB), offset 0x064 Register 49: PWM1 Generator B Control (PWM1GENB), offset 0x0A4 Register 50: PWM2 Generator B Control (PWM2GENB), offset 0x0E4 Register 51: PWM3 Generator B Control (PWM3GENB), offset 0x124

Key Registers: PWMnLOAD Register 28: PWM0 Load (PWM0LOAD), offset 0x050 Register 29: PWM1 Load (PWM1LOAD), offset 0x090 Register 30: PWM2 Load (PWM2LOAD), offset 0x0D0 Register 31: PWM3 Load (PWM3LOAD), offset 0x110

Key Registers: PWMnCMPA Register 36: PWM0 Compare A (PWM0CMPA), offset 0x058 Register 37: PWM1 Compare A (PWM1CMPA), offset 0x098 Register 38: PWM2 Compare A (PWM2CMPA), offset 0x0D8 Register 39: PWM3 Compare A (PWM3CMPA), offset 0x118

Key Registers: PWMnCMPB Register 40: PWM0 Compare B (PWM0CMPB), offset 0x05C Register 41: PWM1 Compare B (PWM1CMPB), offset 0x09C Register 42: PWM2 Compare B (PWM2CMPB), offset 0x0DC Register 43: PWM3 Compare B (PWM3CMPB), offset 0x11C

Key Registers: PWMENABLE

Using PWM to Generate Different Frequencies

Using PWM to Generate Different Duty Cycles