Pulse Width Modulation



Similar documents
AVR Timer/Counter. Prof Prabhat Ranjan DA-IICT, Gandhinagar

PWM IN AVR. Developed by: Krishna Nand Gupta Prashant Agrawal Mayur Agarwal

DIGITAL-TO-ANALOGUE AND ANALOGUE-TO-DIGITAL CONVERSION

Experiment 8 : Pulse Width Modulation

1/22/16. You Tube Video. Definitions. Duty Cycle: on-time per period (specified in per cent)

Chapter 6: From Digital-to-Analog and Back Again

ARRL Morse Code Oscillator, How It Works By: Mark Spencer, WA8SME

CHAPTER 11: Flip Flops

Pulse Width Modulated (PWM) Drives. AC Drives Using PWM Techniques

Switch Mode Power Supply Topologies

Digital to Analog and Analog to Digital Conversion

ETEC Digital Controls PIC Lab 10 Pulse Width Modulation

AMZ-FX Guitar effects. (2007) Mosfet Body Diodes. Accessed 22/12/09.

LAB 7 MOSFET CHARACTERISTICS AND APPLICATIONS

Objectives. Electric Current

The full wave rectifier consists of two diodes and a resister as shown in Figure

Pulse Width Modulated (PWM)

Introduction to Electronic Signals

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

Interfacing Analog to Digital Data Converters

Display Board Pulse Width Modulation (PWM) Power/Speed Controller Module

Using Arduino Microcontrollers to Sense DC Motor Speed and Position

Timer A (0 and 1) and PWM EE3376

Fundamentals of Signature Analysis

Introduction to Power Supplies

RC Circuits and The Oscilloscope Physics Lab X

AVR127: Understanding ADC Parameters. Introduction. Features. Atmel 8-bit and 32-bit Microcontrollers APPLICATION NOTE

Conversion Between Analog and Digital Signals

EET272 Worksheet Week 9

PCM Encoding and Decoding:

TEA1024/ TEA1124. Zero Voltage Switch with Fixed Ramp. Description. Features. Block Diagram

1. Learn about the 555 timer integrated circuit and applications 2. Apply the 555 timer to build an infrared (IR) transmitter and receiver

Constructing a precision SWR meter and antenna analyzer. Mike Brink HNF, Design Technologist.

Solar Energy Conversion using MIAC. by Tharowat Mohamed Ali, May 2011

Analog & Digital Electronics Course No: PH-218

Precision Diode Rectifiers

Principles of Adjustable Frequency Drives

Lecture - 4 Diode Rectifier Circuits

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

Theory of Operation. Figure 1 illustrates a fan motor circuit used in an automobile application. The TPIC kω AREF.

Frequency Response of Filters

The 2N3393 Bipolar Junction Transistor

Drive circuit basics + V. τ e. Industrial Circuits Application Note. Winding resistance and inductance

LOW COST MOTOR PROTECTION FILTERS FOR PWM DRIVE APPLICATIONS STOPS MOTOR DAMAGE

Signal Processing in So.ware and Electric Field Sensing

98% Efficient Single-Stage AC/DC Converter Topologies

A Digital Timer Implementation using 7 Segment Displays

Basic Pulse Width Modulation

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

LED DIMMING A HELPFUL GUIDE...

Technical Manual. FAN COIL CONTROLLER COOLING or HEATING ANALOG or PWM Art A

Adding Pneumatic Preset Counter. Type 497. Continuously visible preset Integrated pneumatic reset 3 or 5-digit display Convenient button setting

Micro-Step Driving for Stepper Motors: A Case Study

Bi-directional Power System for Laptop Computers

Cornerstone Electronics Technology and Robotics I Week 15 Voltage Comparators Tutorial

Pulse Width Modulated (PWM) Controller for 12 Volt Motors

EXPERIMENT NUMBER 5 BASIC OSCILLOSCOPE OPERATIONS

Pulse Width Modulation (PWM) LED Dimmer Circuit. Using a 555 Timer Chip

Dual-Low Frequency Oscillator

APPLICATION NOTES: Dimming InGaN LED

Fundamentals of Power Electronics. Robert W. Erickson University of Colorado, Boulder

[F/T] [5] [KHz] [AMP] [3] [V] 4 ) To set DC offset to -2.5V press the following keys [OFS] [+/-] [2] [.] [5] [V]

CONSTANT CURRENT REGULATOR INDUPERM TYPE CCR 951. Standarddescription of CONSTANT CURRENT REGULATOR TYPE CCR 951.

DAC Digital To Analog Converter

Application Note SX V Timer (Next Gen 555) Application Note AN Advanced Communications and Sensing

Low Cost Pure Sine Wave Solar Inverter Circuit

Pulse width modulation

Programmable Single-/Dual-/Triple- Tone Gong SAE 800

Diode Applications. by Kenneth A. Kuhn Sept. 1, This note illustrates some common applications of diodes.

Atmel Norway XMEGA Introduction

Single-Stage High Power Factor Flyback for LED Lighting

Decimal Number (base 10) Binary Number (base 2)

AP-1 Application Note on Remote Control of UltraVolt HVPS

Series and Parallel Circuits

Timer, Interrupt, Exception in ARM

Basic Op Amp Circuits

Properties of electrical signals

Timer Value IRQ IACK

Measurement of Capacitance

Phase-Control Alternatives for Single-Phase AC Motors Offer Smart, Low-Cost, Solutions Abstract INTRODUCTION

Design and Development of Speed Control of Induction motor drive using Pulse-Width Modulation

FREQUENCY CONTROLLED AC MOTOR DRIVE

AP331A XX G - 7. Lead Free G : Green. Packaging (Note 2)

LEVERAGING FPGA AND CPLD DIGITAL LOGIC TO IMPLEMENT ANALOG TO DIGITAL CONVERTERS

If an occupancy of room is zero, i.e. room is empty then light source will be switched off automatically

Current Loop Tuning Procedure. Servo Drive Current Loop Tuning Procedure (intended for Analog input PWM output servo drives) General Procedure AN-015

PHYSICS 111 LABORATORY Experiment #3 Current, Voltage and Resistance in Series and Parallel Circuits

Digital to Analog Converter. Raghu Tumati

Eliminate Ripple Current Error from Motor Current Measurement

Design Project: Power inverter

AP Physics Electricity and Magnetism #4 Electrical Circuits, Kirchoff s Rules

Features. Applications

Tamura Closed Loop Hall Effect Current Sensors

Operational Amplifier as mono stable multi vibrator

Programming Logic controllers

Series AMLDL-Z Up to 1000mA LED Driver

ANADOLU UNIVERSITY DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING

Transcription:

Pulse Width Modulation Pulse width modulation (PWM) is a powerful technique for controlling analog circuits with a microprocessor's digital outputs. PWM is employed in a wide variety of applications, ranging from measurement and communications to power control and conversion. Analogue circuits An analogue signal has a continuously varying value, with infinite resolution in both time and magnitude. A nine-volt battery is an example of an analog device, in that its output voltage is not precisely 9V, changes over time, and can take any real-numbered value. Analogue signals are distinguishable from digital signals because the latter always take values only from a finite set of predetermined possibilities, such as the set 0V, 5V. Analogue voltages and currents can be used to control things directly, like the volume of a car radio. In a simple analogue radio, a knob is connected to a variable resistor. As you turn the knob, the resistance goes up or down. As that happens, the current flowing through the resistor increases or decreases. This changes the amount of current driving the speakers, thus increasing or decreasing the volume. An analogue circuit is one, like the radio, whose output is linearly proportional to its input. Digital control By controlling analogue circuits digitally, system costs and power consumption can be drastically reduced. In a nutshell, PWM is a way of digitally encoding analogue signal levels. Through the use of high-resolution counters, the duty cycle of a square wave is modulated to encode a specific analogue signal level. The PWM signal is still digital because, at any given instant of time, the full DC supply is either fully on or fully off. The voltage or current source is supplied to the analog load by means of a repeating series of on and off pulses. The on-time is the time during which the DC supply is applied to the load, and the offtime is the period during which that supply is switched off. Figure 1 shows three different PWM signals. Figure 1a shows a PWM output at a 10% duty cycle. That is, the signal is on for 10% of the period and off the other 90%. Figures 1b and 1c show PWM outputs at 50% and 90% duty cycles, respectively. These three PWM outputs encode three different analogue signal values, at 10%, 50%, and 90% of the full strength. If, for example, the supply is 9V and the duty cycle is 10%, a 0.9V analogue signal results.

Figure 1: PWM signals of varying duty cycles Figure 2 shows a simple circuit that could be driven using PWM. In the figure, a 9V battery powers an incandescent lightbulb. If we closed the switch connecting the battery and lamp for 50ms, the bulb would receive 9V during that interval. If we then opened the switch for the next 50ms, the bulb would receive 0V. If we repeat this cycle 10 times a second, the bulb will be lit as though it were connected to a 4.5V battery (50% of 9V). We say that the duty cycle is 50% and the modulating frequency is 10Hz. Figure 2: A simple circuit The AVR atmega16 supports pulse width modulation (PWM) on all three timer counters. Initially we will use the 8 bit timer 0 to implement this function. The AVR supports normal PWM or so called fast PWM. Normal PWM involves starting a counter which counts up to it s maximum value and then reverses, counts back to zero and then repeats. This can be visualised as a sawtooth waveformas shown in Figure 3. In order to create output pulses whose mark:space ratio changes the output compare register (Ref) is loaded with a value so that when the count reaches that value the Output is reversed. Figure 3

As the value of Ref reduces so the width of the pulses increase and as Ref increase then the width of the pulses will decrease. In the atmega16 Ref = OCR0 and the output is OC0 which is bit 3 on PORTB. Section from mega16 datasheet The phase correct PWM mode (WGM01:0 = 1) provides a high resolution phase correct PWM waveform generation option. The phase correct PWM mode is based on a dualslope operation. The counter counts repeatedly from BOTTOM to MAX and then from MAX to BOTTOM. In non-inverting Compare Output mode, the Output Compare (OC0) is cleared on the compare match between TCNT0 and OCR0 while upcounting, and set on the compare match while downcounting. In inverting Output Compare mode, the operation is inverted. The dual-slope operation has lower maximum operation frequency than single slope operation. However, due to the symmetric feature of the dual-slope PWM modes, these modes are preferred for motor control applications. The PWM resolution for the phase correct PWM mode is fixed to eight bits. In phase correct PWM mode the counter is incremented until the counter value matches MAX. When the counter reaches MAX, it changes the count direction. The TCNT0 value will be equal to MAX for one timer clock cycle. The timing diagram for the phase correct PWM mode is shown on Figure 33. The TCNT0 value is in the timing diagram shown as a histogram for illustrating the dual-slope operation. The diagram includes non-inverted and inverted PWM outputs. The small horizontal line marks on the TCNT0 slopes represent compare matches between OCR0 and TCNT0. This technique is effectively digital to analogue conversion. Fast Pulse Width Mode Figure. 4: Fast Pulse Width Mode

Section from mega16 datasheet The fast Pulse Width Modulation or fast PWM mode provides a high frequency PWM waveform generation option. The fast PWM differs from the other PWM option by its single-slope operation. The counter counts from BOTTOM to MAX then restarts from BOTTOM. In non-inverting Compare Output mode, the Output Compare (OC0) is cleared on the compare match between TCNT0 and OCR0, and set at BOTTOM. In inverting Compare Output mode, the output is set on compare match and cleared at BOTTOM. Due to the single-slope operation, the operating frequency of the fast PWM mode can be twice as high as the phase correct PWM mode that use dualslope operation. This high frequency makes the fast PWM mode well suited for power regulation, rectification, and DAC applications. High frequency allows physically small sized external components (coils, capacitors), and therefore reduces total system cost. In fast PWM mode, the counter is incremented until the counter value matches the MAX value. The counter is then cleared at the following timer clock cycle. The timing diagram for the fast PWM mode is shown in Figure 32. The TCNT0 value is in the timing diagram shown as a histogram for illustrating the single-slope operation. The diagram includes non-inverted and inverted PWM outputs. The small horizontal line marks on the TCNT0 slopes represent compare matches between OCR0 and TCNT0. #include <avr/io.h> #include <avr/signal.h> #include <avr/interrupt.h> #define PWM_select ((~(inp(pina)) & 3)) main() unsigned int oldtogs; outp(0x??,ddra); outp(0x??,ddrb); outp(0x??,porta); outp(0x??,tccr0); while (1) if (PWM_select!= (oldtogs)) oldtogs = PWM_select; oldtogs = oldtogs; switch (oldtogs) case 0: break; case 1: break; case 2:

break; case 3: ; Type in the above program and insert the correct values for the registers. Enter comments where relevant and save in your area. Date Tutors signature