PWM System. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Similar documents
Hardware Flags. and the RTI system. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

ME 4447/6405 Pulse Width Modulation (PWM)

Oct 30 Announcements. Bonus marked will be posted today Will provide 270 style feedback on multiple-choice questions. [3.E]-1

PWM_8B8C. Block User Guide V01.16

Pulse Width Modulation

The 9S12 Pulse Width Modulation System Huang Sections 8.10 and 8.11 PWM_8B8C Block User Guide

Grundlagen Microcontroller Counter/Timer. Günther Gridling Bettina Weiss

Project Board Game Counter: Digital

Hello, and welcome to this presentation of the FlexTimer or FTM module for Kinetis K series MCUs. In this session, you ll learn about the FTM, its

The MC9S12 Pulse Width Modulation System. Pulse Width Modulation

Chapter 10 Adaptive Delta Demodulator

EECS 270: Lab 7. Real-World Interfacing with an Ultrasonic Sensor and a Servo

ECE 4510/5530 Microcontroller Applications Midterm Review

Counter/Timers in the Mega8

EE 308 Spring 2013 The MC9S12 Pulse Width Modulation System

Microprocessor & Interfacing Lecture Programmable Interval Timer

Chapter 6 PROGRAMMING THE TIMERS

Course Introduction. Content 20 pages 3 questions. Learning Time 30 minutes

EE 308 Spring Using the HCS12 PWM

CS/ECE 6780/5780. Al Davis. Today s topics: Output capture Pulse Width Modulation Pulse Accumulation all useful options for Lab7 1 CS 5780

Hello and welcome to this Renesas Interactive Course that provides an overview of the timers found on RL78 MCUs.

Chapter 5 Sequential Logic Circuits Part II Hiroaki Kobayashi 7/11/2011

MICROCONTROLLER TUTORIAL II TIMERS

Linear Integrated Circuits

EEL 4744C: Microprocessor Applications Lecture 8 Timer Dr. Tao Li

CprE 288 Introduction to Embedded Systems (Output Compare and PWM) Instructors: Dr. Phillip Jones

Reading Assignment. Timer. Introduction. Timer Overview. Programming HC12 Timer. An Overview of HC12 Timer. EEL 4744C: Microprocessor Applications

ERRATUM: In accordance with the standardized nomenciaure adopted at NRAO, the term "instrumental. meridian" should now be "instrumental equator".

PIC Functionality. General I/O Dedicated Interrupt Change State Interrupt Input Capture Output Compare PWM ADC RS232

ENGR-4300 Electronic Instrumentation Quiz 3 Spring 2011 Name Section

ESE 350 Microcontroller Laboratory Lab 5: Sensor-Actuator Lab

TKT-3500 Microcontroller systems

ENGG1015: lab 3. Sequential Logic

IES Digital Mock Test

Datapath Components. Multipliers, Counters, Timers, Register Files

Timer 0 Modes of Operation. Normal Mode Clear Timer on Compare Match (CTC) Fast PWM Mode Phase Corrected PWM Mode

Timer A (0 and 1) and PWM EE3376

ATmega16A Microcontroller

Freescale Semiconductor, I

Module -18 Flip flops

Freescale Semiconductor, I

Laboratory Exercise 1 Microcontroller Board with Driver Board

HIGH LOW Astable multivibrators HIGH LOW 1:1

PAK-VIIIa Pulse Coprocessor Data Sheet by AWC

CHAPTER III THE FPGA IMPLEMENTATION OF PULSE WIDTH MODULATION

1 Second Time Base From Crystal Oscillator

Lab 5 Timer Module PWM ReadMeFirst

Timer/Counter with PWM

DASL 120 Introduction to Microcontrollers

Design and build a prototype digital motor controller with the following features:

ECOM 4311 Digital System Design using VHDL. Chapter 9 Sequential Circuit Design: Practice

Electronic Instrumentation

Module-20 Shift Registers

The Use and Design of Synchronous Mirror Delays. Vince DiPuccio ECG 721 Spring 2017

Java Bread Board Introductory Digital Electronics Exercise 2, Page 1

UNIT II: Clocked Synchronous Sequential Circuits. CpE 411 Advanced Logic Circuits Design 1

MICROWAVE CRYSTEK. Features. Applications CPLL " 0.800" SMD CORPORATION GHz. Standard 3 Wire Interface

A MORON'S GUIDE TO TIMER/COUNTERS v2.2. by

Graphical Control Panel User Manual

EE251: Thursday October 25

ANALOG TO DIGITAL CONVERTER

Spec. Instructor: Center

ELECTROVATE. Electromania Problem Statement Discussion

MM5452/MM5453 Liquid Crystal Display Drivers

Using the Z8 Encore! XP Timer

DS1802 Dual Audio Taper Potentiometer With Pushbutton Control

Experiment#6: Speaker Control

Chapter 5 Sequential Logic Circuits Part II Hiroaki Kobayashi 6/30/2008

CHAPTER IV DESIGN AND ANALYSIS OF VARIOUS PWM TECHNIQUES FOR BUCK BOOST CONVERTER

COMPUTER ORGANIZATION & ARCHITECTURE DIGITAL LOGIC CSCD211- DEPARTMENT OF COMPUTER SCIENCE, UNIVERSITY OF GHANA

ENGR-4300 Fall 2008 Test 3. Name. Section 1(MR 8:00) 2(TF 2:00) (circle one) Question I (20 points) Question II (15 points) Question III (20 points)

Atmel ATmega328P Timing Subsystems. Reading

Brought to you by. Priti Srinivas Sajja. PS01CMCA02 Course Content. Tutorial Practice Material. Acknowldgement References. Website pritisajja.

CS/EE Homework 9 Solutions

Topics Introduction to Microprocessors

Hello, and welcome to this presentation of the STM32 Infrared Timer. Features of this interface allowing the generation of various IR remote control

MM5452 MM5453 Liquid Crystal Display Drivers

Castle Creations, INC.

CATALOG. ANALOG COMMUNICATION SYSTEMS DIGITAL COMMUNICATION SYSTEMS Microcontroller kits Arm controller kits PLC Trainer KITS Regulated Power supplies

6.111 Lecture # 19. Controlling Position. Some General Features of Servos: Servomechanisms are of this form:

Timing System. Timing & PWM System. Timing System components. Usage of Timing System

ENGR-4300 Electronic Instrumentation Quiz 3 Fall 2010 Name Section

Additional Programs for the Electronics Module Part No

Digital Electronics Course Objectives

For more information on these functions and others please refer to the PRONET-E User s Manual.

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING BENG (HONS) ELECTRICAL & ELECTRONICS ENGINEERING SEMESTER TWO EXAMINATION 2017/2018

Micro Controller Based Ac Power Controller

INF3430 Clock and Synchronization

LSI/CSI LS7290 STEPPER MOTOR CONTROLLER. LSI Computer Systems, Inc Walt Whitman Road, Melville, NY (631) FAX (631)

INTEGRATED CIRCUITS. For a complete data sheet, please also download:

DS1801 Dual Audio Taper Potentiometer

Microcontrollers: Lecture 3 Interrupts, Timers. Michele Magno

Project 3 Build a 555-Timer

EVDP610 IXDP610 Digital PWM Controller IC Evaluation Board

ECE251: Tuesday October 3 0

LM4: The timer unit of the MC9S12DP256B/C

CHAPTER 6 DIGITAL INSTRUMENTS

Select the single most appropriate response for each question.

CMOS Digital Integrated Circuits Lec 11 Sequential CMOS Logic Circuits

Page 1. Last time we looked at: latches. flip-flop

Transcription:

PWM System 1

Pulse Width Modulation (PWM) Pulses are continuously generated which have different widths but the same period between leading edges Duty cycle (% high) controls the average analog voltage of the output signal Uses: DC motor control, positional servo control, audio communication (cellular phones), low cost digital to analog conversion for such things as telephone tone generation 2

Software Approach Assume PER is the desired period in microseconds DUTY is the desired duty cycle (%) Then calculate PWIDTH = DUTY * PER OFFTIME = PER PWIDTH PER PWIDTH OFFTIME Algorithm: Repeat forever: Turn on output pin Delay for PWDITH microseconds Turn off output pin Delay for OFFTIME microseconds Disadvantages: Wastes a lot of CPU time doing delay loops CPU can only do one thing 3

Hardware Approach We can automatically generate a PWM signal using simple digital hardware elements T flip flop Register Comparator Counter T flip flop Toggles its state if the T input = 1 T T t + 1 Res / 0 1 t t 4

Register A collection of D flip-flops D0 D 0 8-bit register D1 D 1 D[7..0] pre [7..0] Clk clr Dn-1 D n-1 Parallel load, parallel access Clk 5

Comparator A combinational circuit that just compares two N-bit numbers When they are equal it outputs a 1 8 8 Comparator Eq XOR is a 1-bit comparator a b DIFF = a $ b a b E = (a $ b) To compare two N-bit numbers for equality a 0 b 0 a 1 b 1 : E a n-1 b n-1 6

Counter A sequential circuit that automatically counts up by 1 every clock tick When reset is asserted, or count reaches a maximum, goes to 0 1 T 0 0 T 1 n-bit counter Clock 8 Reset 0 1 T 2 An n-bit counter can be constructed by chaining together n flip-flops (T or D) In a synchronous counter, all the f/f s change state simultaneously with the clock 0 1 2 Clk T 3 7

PWM generation - hardware approach This comparator fires when count reaches PWMDTY... it then causes T to toggle ( goes to 1 and / to 0) PWMPER T flip flop Clk 8-bit counter Reset Comparator 8-bit register (PWMDTY) Clk T Res / PWMDTY Comparator 8-bit register (PWMPER) This comparator fires when count reaches PWMPER... it then resets the counter and forces to 0 (and / to 1) Just load registers PWMDTY, PWMPER in units of clock ticks No further action needed! 8

PWM generation - hardware approach We have a free running counter (incremented by system clock) We have one register for the pulse width and the other for the period At the start of the period, the counter is zero and the output is high When the value in the counter equals the value in the first register, the output goes low When the value in the counter equals the value in the 2 nd register, the output goes high and the counter resets to zero counter starts counting from 0 count matches 1 st register count matches 2 nd register We have a choice of polarity: pulse high or pulse low 9

Clock signal and PWM duty = # clock ticks in this interval period = # clock ticks in this interval one clock tick clk PWM out start of period end of duty end of period The duration of one clock tick is the resolution by which we can set duty and period time 10

reset clock source This is the E-clock (or a scaled version of it) GATE (clock edge sync) up/ down 8-bit counter PWMCNTx Free running counter 1. When count reaches PWMDTY, force output low 8-bit compare= PWMDTYx T R From port PTP data register M U X M U X to pin driver 8-bit compare= PPOLx 2. When count reaches PWMPER, force output high PWMPERx T R CAEx PWMEx Figure 8.44 PWM channel block diagram 11

Clock for PWM The E-clock is really fast! At 24 MHz, one clock tick is 0.042 us (microseconds) If we let the counter count at that frequency, we could only have very short periods Maximum period would be 256 ticks, or 10.7 us To allow longer periods, we scale (reduce the frequency) of the E-clock There are two clock divider stages: First divider divides by M, where M=1,2,4,8,, 128 Second is an additional divide by 2*N, where N is any number, 1 through 256 12

PWM Clock You can use the clock from the first divider (Clock A ) or from the second divider (Clock SA, or Scaled A ) Clock A is the system clock divided by M, where M=1,2,4,8,, 128 Clock SA is generated by an additional division by N*2, for N=1 through 256 System Clock (24 MHz) First Divider Second Divider /1, 2, 4,..., 128 /N, N=1..256 /2 Clock SA Clock A 13

Clock A Here are the choices you have for the prescalar (assuming a 24 MHz E-clock): M Clk A freq one tick 256 ticks 1 24000000 4.17E-08 1.07E-05 2 12000000 8.33E-08 2.13E-05 4 6000000 1.67E-07 4.27E-05 8 3000000 3.33E-07 8.53E-05 16 1500000 6.67E-07 1.71E-04 32 750000 1.33E-06 3.41E-04 64 375000 2.67E-06 6.83E-04 128 187500 5.33E-06 1.37E-03 Clock A is the E- clock prescaled by dividing by M This is the time for one clock A period (is just 1/frequency) This is the maximum period you can have with an 8-bit counter (256 ticks) 14

Examples of clock scaling If we want a period of 10 us At the 24 MHz E-clock rate, each clock tick is 0.042 us The desired period is (10 us)/(0.042 us) = 240 ticks This value fits in the 8-bit PWMPER register, so no scaling is necessary (either using the prescaler or the clock divider) We can use clock A with M=1 If we want a period of 20 us If we used the 24 MHz E-clock, the period would be 480 ticks, which is too big for 8 bits We can prescale the E-clock by a factor of 2 this produces clock A at 12 MHz. Each clock tick is 0.083 us. Then the period is (20 us)/(0.083 us) = 240 clock ticks We can use clock A with M=2 Of course, prescaling by larger values of M also works Example: M=4 yields a clock at 6 MHz Then a period of 20 us is 120 clock ticks But in general we want to have as much resolution as possible (ie, period close to 256 ticks) 15

Longer periods e.g., 1 ms At the 24 MHz E-clock rate, each clock tick is 0.042 us The desired period is (1 ms)/(0.042 us) = 24000 ticks too big We can scale by dividing 24MHz by some number, 2*N, where N=1..256, to produce clock SA Let s try to get the period down to 240 clock SA ticks We can do this by dividing clock A by 100 (so N=50) Then clock SA is 24 MHz/100 = 240 khz; one SA tick is 4.2 us Then (1 ms)/(4.2 us) = 240 ticks, so ok We select clock SA and use M=1, N=50 System Clock (24 MHz) First Divider Second Divider /1, 2, 4,..., 128 /N, N=1..256 /2 Clock SA Clock A 16

Other combinations Actually, many possible combinations would yield a period of 1 ms # SA ticks M clock A freq 1 Clk A tick 256 ticks N SA freq 1 Clk SA tick 256 ticks in 0.001 sec 1 24000000 4.17E-08 1.07E-05 50 240000 4.17E-06 1.07E-03 240.0 2 12000000 8.33E-08 2.13E-05 25 240000 4.17E-06 1.07E-03 240.0 4 6000000 1.67E-07 4.27E-05 12 250000 4.00E-06 1.02E-03 250.0 8 3000000 3.33E-07 8.53E-05 6 250000 4.00E-06 1.02E-03 250.0 16 1500000 6.67E-07 1.71E-04 3 250000 4.00E-06 1.02E-03 250.0 32 750000 1.33E-06 3.41E-04 2 187500 5.33E-06 1.37E-03 187.5 64 375000 2.67E-06 6.83E-04 1 187500 5.33E-06 1.37E-03 187.5 128 187500 5.33E-06 1.37E-03 1 93750 1.07E-05 2.73E-03 93.8 These combinations of M,N are ok This is the period in terms of # of Clock SA ticks You probably don t want a combination with a non-integral # ticks 17

Example Find a combination of M,N that yields a 20 ms period (assuming 24 MHz system clock) System Clock (24 MHz) First Divider Second Divider /1, 2, 4,..., 128 /N, N=1..256 /2 Clock SA Clock A 18

Summary / uestions The PWM system accomplishes in hardware what you could also do in software. What is the benefit of doing it in hardware? What are the key digital logic components that make up the PWM system? 19