You are on page 1of 38

GOKARAJU RANGARAJU INSTITUTE OF ENGINEERING AND TECHNOLOGY

Hyderabad, Andhra Pradesh.

DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING

GENERATION OF PULSE WIDTH MODULATION SIGNALS USING SINUSOIDAL WAVE FORM

By : B.RAJASEKAR RAJU G.SAI KRISHNA M.SAI KUMAR P.SURESH L.VAMSI KRISHNA

CONTENTS

TOPIC

PAGE NO.

Abstract 1. Introduction 1.1 Objective 1.2 1.3 What is pwm? Introductio

i 01

2. Block Diagram & Description

05

2.1 2.2

Block Diagram Description of Block Diagram

3. Hardware Design

09

3.1 Microcontroller AT89C51 3.2 CRO

4. Software Design

26

4.1Proteus design.

5. Source code

27

Topic

Page no.

6 Applications

28

6.1 Application
7. References

29

ABSTRACT :

This paper presents the generation of pulse width modulation (PWM) by using MICROCONTROLLER (8051).In this the sinusoidal wave is generated by and is compared with the saw tooth wave. These wave forms are compared to generate required pulse width modulation signal (PWM). Pulse width modulation (PWM) is a very efficient way of providing intermediate amounts of electrical power between fully on an fully off. a simple power switch with a typical power source provides full power only when switched on. The term duty cycle describes the proportion of on time to the regular interval or period of time a low duty cycle corresponds to low power , because the power is off for most of the time. duty cycle is expressed in percent,100% being fully on.PWM works well with digital controls ,which, because of their on/off nature , can easily set the needed duty cycle.PWM of a signal or power source involves the modulation of its duty cycle ,to either convey information over a communication channel or control the amount of power sent to a load. Pulse Width Modulation, abbreviated as PWM, is a method of transmitting information on a series of pulses. The data that is being transmitted is encoded on the width of these pulses to control the amount of power being sent to a load. In other words, pulse width modulation is a modulation technique for generating variable width pulses to represent the amplitude of an input analog signal or wave. The popular applications of pulse width modulation are in power delivery, voltage regulation and amplification and audio effects.

Chapter 1: INTRODUCTION

1.1 Objective :
Generating PWM pulses using MICROCONTROLLER (8051).

1.2 What is pwm?


(Pulse Width Modulation) A modulation technique that uses a digital circuit to create a variable analog signal. PWM is a simple concept: open and close a switch at uniform, repeatable intervals. Analog circuits that vary the voltage tend to drift, and it costs more to produce ones that do not than it does to make digital PWM circuits. In addition, control of almost everything today is already in the digital realm. For example, PWM is widely used to control the speed of a DC motor and the brightness of a bulb, in which case the PWM circuit is used to open/close a power line. If the line were opened for 1ms and closed for 1ms, and this were continuously repeated, the target would receive an average of 50% of the voltage and run at half speed or half brightness. If the line were opened for 1ms and closed for 3ms, the target would receive an average of 25%. Today, PWM technique has been used in wide applications, such voltage control, current control, motor control, power control, UPS, inverter etc.,.

1.3 Introduction:

Pulse width modulation (PWM) is a very efficient way of providing intermediate amounts of electrical power between fully on an fully off. a simple power switch with a typical power source provides full power only when switched on.PWM is comparatively recent technique ,made practical by modern electronic power switches although one of its applications was in Sinclair x10,a 10 W audio amplifier available in kit form in 1960s. 1

Fig 1.1

In the past, when only partial power is needed (such as sewing machine motor),a rheostat (located in the sewing machine foot pedal ) connected in series with the motor adjusted the amount of the current flowing through the motor, but also wasted power as heat in the resistor element. It was an insufficient scheme, but tolerable because the total power is low.this was one of the several methods of controlling power. There were otherssome stil in usesuch as variable autotransformers, including the trade nmarked autrastat for theoretical lighting and the variac,for general power adjustment. These were quite efficient, but also relatively costly.

For about a century , some variables-speed electric motors have had decent efficiency, but there was some what more complex than constant-speed motor, and some times required external electrical apparatus, such as a bankof variable power resistors. However there is a great need for applying partial power in other devices, such as electric stoves,lamp dimmers and robotic servos.basically, a PWM variable-power scheme switches the power quickly between fully on and fully off. In any event, the switching rate is much faster than what would effect theload, which is tosay the device that uses the power. In practice, applying full power for part of the time doesnnot cause any problems;PWM is practical. 2 The term duty cycle describes the proportion of on time to the regular interval or period of time a low duty cycle corresponds to low power , because the power is off for most of the time. duty cycle is expressed in percent,100% being fully on. PWM works well with digital controls ,which, because of their on/off nature , can easily set the needed duty cycle. PWM of a signal or power source involves the modulation of its duty cycle ,to either convey information over a communication channel or control the amount of power sent to a load.

Fig 1.2 Pulse width modulation is used to reduce the total power delivered to a load without resulting in loss, which normally occurs when a power source is limited by a resistive element. The underlying principle in the whole process is that the average power delivered is directly proportional to the modulation duty cycle. If the modulation rate is high, it is possible to smooth out the pulse train using passive electronic filters and recover an average analog wave form. Multi-phase machines and drives is a topic of growing relevance in recent years, and it presents many challenging issues that still need further research. This is the case of multi-phase 3 space vector pulse width modulation (SVPWM), which shows not only more space vectors than the standard three-phase case, but also new subspaces where the space vectors are mapped. Different approaches have been recently followed, and the aim of this paper is to review and classify these methods. Comparative results are included to highlight the weak and strong points of the different methods. Finally some conclusions are extracted pointing out the problems that still need to be solved.

Chapter 2: Block Diagram & Description


2.1 Block Diagram

GENERATION OF PMW SIGNALS USING 89C51 IN PROTEUS SOFTWARE: SCHEMATIC:


Fig 2.1

Output waveform

Fig 2.2

2.2

Description of Block Diagram

Figure 2.1 shows the schematic diagram.

C program is writtensuch that the sine wave and ramp wave are compared to each other such that PWM pulses are produced.

Initially the source code should be written on notepad.

This code should be verified for any warning and error instructions and this error less program should be used to create HEX file in KIEL.

This HEX file is dumped in to the 89C51 in PROTEUS software where we designed the schematic as shown the figure.

External clock signal must be give to the 89c51 microcontroller using crystal oscillator and also capacitors as shown in the figure.

As the program is written in such a way that the output signals(pwm) obtained after comparing sine wave with ramp signal is assigned to pin1 of port1,the oscilloscope is 6

connected to the pin1 of port1.

Figure2.2 shows the output pulse width modulation signals.

GENERATION OF PMW SIGNALS USING MATLAB

Fig 2.3

Description:

We can also generate pwm signals using matlab software.

Above block diagram consists of the following: 1. Sinewave generator 2. Signal generator in which sawtooth wave form is selected. 3. Relational operator 4. Scope 7

Relational operator compares the two input signals(i.e.,sinewave and sawtooth) which
are given to the two input terminals of relational operator.

The function of relational operator is, when the magnitude of sinewave is greater than the
sawtooth wave a pulse is generated and when the magnitude of sine is less than the sawtooth wave ,the magnitude of the pulse will be zero.

Chapter 3: Hardware Design

Microcontroller

Definition :
An embedded microcontroller is chip which has a computer processor with all its support functions (clock & reset), memory (both program and data), and I/O(including bus interface) built in to the device. These built in function minimize the need for external circuits and devices to be designed in the final application.

Types of Microcontroller:
Creating application for microcontrollers is completely different than any other development job in computing and electronics. In most other application one probably have a number of subsystems and interface already available for his/her use. This is not the case with a microcontroller where one is responsible for-

Power distribution System clocking Interface design and wiring System programming Application programming Device programming

Before selecting a particular device for an application, its important to understand what the different option and features are and what they can mean with regard to developing application. 9

Embedded Microcontroller

When all the hardware required to run the application is provided on the chip, it is refer to as an embedded microcontroller. All that is typically required to operate the device is power, reset, and a clock. Digital I/O pins are provided to allow interfacing with external devices.

External Memory Microcontroller

Sometimes, the program memory is insufficient for an application or , during debug; a separate ROM(or even RAM) would make the work easier. Some microcontrollers including the 8051 allow the connection of external memory.

An external memory microcontroller seems to primarily differ from a microprocessor in the areas of built in peripheral features. These features could include memory device selection (avoiding the need for external address decoders or DRAM address multiplexers), timers, interrupt controllers, DMA, and I/O devices like serial ports.

Features of AT89C51
Compatible with MCS-51 Products. 4K Bytes of In-System Reprogrammable Flash Memory.Endurance: 1,000 Write/Erase Cycles. Fully Static Operation: 0 Hz to 24 MHz. Three-level Program Memory Lock. 128 x 8-bit Internal RAM. 32 Programmable I/O Lines. Two 16-bit Timer/Counters. Six Interrupt Sources. Programmable Serial Channel. 10 Low-power Idle and Power-down Modes

Description:
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density non-volatile memory technology and is compatible with the industry-standard MCS-51 instruction set and pin out. The on-chip flash allows the program memory to be reprogrammed in-system or by a conventional non-volatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications

11

PIN DIAGRAM OF 8051

Fig 3.1

12

BLOCK DIAGRAM

fig 3.2

13

Fig 3.3

Pin Description
VCC Supply voltage.

GND Ground. Port 0 Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as highimpedance inputs. Port 0 may also be configured to be the multiplexed loworder address/data bus during accesses to

14 external program and data memory. In this mode P0 has internal pullups. Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pullups are required during program verification.

Port 1 Port 1 is an 8-bit bi-directional I/O port with internal pullups.The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pullups and can be used as inputs. As inputs,Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 1 also receives the low-order address bytes during Flash programming and verification.

Port 2 Port 2 is an 8-bit bi-directional I/O port with internal pullups.The Port 2 output buffers can sink/source four TTL inputs.When 1s are written to Port 2 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this application, it uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the highorder address bits and some control signals during Flash programming and verification.

Port 3 Port 3 is an 8-bit bi-directional I/O port with internal pullups.The Port 3 output buffers can sink/source four TTL inputs.When 1s are written to Port 3 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pullups. Port 3 also serves the functions of various special features of the AT89C51 as listed below:

15

Port 3 also receives some control signals for Flash programming and verification.

RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.

ALE/PROG Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming.In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.

16 PSEN Program Store Enable is the read strobe to external program memory. When the AT89C51 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.

EA/VPP External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP.

XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2 Output from the inverting oscillator amplifier.

Oscillator Characteristics XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator, as shown in Figure 1. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 hould be left unconnected while XTAL1 is driven as shown in Figure 2. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.

17

OSCILLATOR CONNECTIONS

Fig 3.4

18

External Clock Drive Configuration

Fig 3.5

Idle Mode In idle mode, the CPU puts itself to sleep while all the onchip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. It should be noted that when idle is terminated by a hard ware reset, the device normally resumes program execution, rom where it left off, up to two machine

19 cycles beforethe internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory. Power-down Mode In the power-down mode, the oscillator is stopped, and theinstruction that invokes power down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the power-down mode is terminated. The only exit from power-down is a hardware reset. Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize.

Status of External Pins During Idle and Power-down Modes

Table 3.1

Program Memory Lock Bits On the chip are three lock bits which can be left unprogrammed(U) or can be programmed (P) to obtain the additional features listed in the table below. When lock bit 1 is programmed, the logic level at the EA pin is sampled and latched during reset. If the device is powered up without a reset, the latch initializes to a random value, and holds that value until reset is activated. It is

20 necessary that the latched value of EA be in agreement with the current logic level at that pin in order for the device to function properly.

Lock Bit Protection Modes

Table 3.2

Programming Algorithm:
Before programming the AT89C51, the address, data and control signals should be set up according to the Flash programming mode table and Figure 3 and Figure 4. To program the AT89C51, take the following steps. 1. Input the desired memory location on the address lines. 2. Input the appropriate data byte on the data lines. 3. Activate the correct combination of control signals. 4. Raise EA/VPP to 12V for the high-voltage programming mode. 5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write

21 cycle is self-timed and typically takes no more than 1.5 ms.

Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached.

Data Polling: The AT89C51 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written datum on PO.7. Once the write cycle has been completed, true data are valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated.

Ready/Busy: The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled high again when programming is done to indicate READY.

Program Verify: If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read back via the address and data lines for verification. The lock bits cannot be verified directly. Verification of the lock bits is achieved by observing that their features are enabled.

Chip Erase: The entire Flash array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The code array is written with all 1s. The chip erase operation must be executed before the code memory can be re-programmed.

Reading the Signature Bytes: The signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned are as follows.

22 (030H) = 1EH indicates manufactured by Atmel (031H) = 51H indicates 89C51 (032H) = FFH indicates 12V programming (032H) = 05H indicates 5V programming

Programming Interface Every code byte in the Flash array can be written and the entire array can be erased by using the appropriate combination of control signals. The write operation cycle is selftimed and once initiated, will automatically time itself to completion. All major programming vendors offer worldwide support for the Atmel microcontroller series. Please contact your local programming vendor for the appropriate software revision.

3.2 CRO: Cathode-Ray Oscilloscope INTRODUCTION:


The cathode ray oscilloscope(CRO) is a common laboratory instrument that provides accurate time and altitude measurements of voltage signals over a wide range of frequencies. Its reliability,stability and ease of operation make it suitable as a general purpose laboratory instrument.the heart of the CRO is a cathode ray tube shown in figure 3.6.

23

Fig 3.6
The cathode ray is a beam of electrons which are emitted by the heated cathode (negative electrode) and accelerated toward the fluorescent screen. The assembly of the cathode, intensity grid, focus grid, and accelerating anode (positive electrode) is called an electron gun. Its purpose is to generate the electron beam and control its intensity and focus. Between the electron gun and the fluorescent screen are two pair of metal plates - one oriented to provide horizontal deflection of the beam and one pair oriented ot give vertical deflection to the beam. These plates are thus referred to as the horizontal and vertical deflection plates. The combination of these two deflections allows the beam to reach any portion of the fluorescent screen. Wherever the electron beam hits the screen, the phosphor is excited and light is emitted from that point. This coversion of electron energy into light allows us to write with points or lines of light on an otherwise darkened screen.

In the most common use of the oscilloscope the signal to be studied is first amplified and
then applied to the vertical (deflection) plates to deflect the beam vertically and at the same time a voltage that increases linearly with time is applied to the horizontal (deflection) plates thus causing the beam to be deflected horizontally at a uniform (constant> rate. The signal applied to the verical plates is thus displayed on the screen as a function of time. The horizontal axis serves as a uniform time scale CRO Operation: A simplified block diagram of a typical oscilloscope is shown in Fig. 3. In general, the

24 instrument is operated in the following manner. The signal to be displayed is amplified by the vertical amplifier and applied to the verical deflection plates of the CRT. A portion of the signal in the vertical amplifier is applied to the sweep trigger as a triggering signal. The sweep trigger then generates a pulse coincident with a selected point in the cycle of the triggering signal. This pulse turns on the sweep generator, initiating the sawtooth wave form. The sawtooth wave is amplified by the horizontal amplifier and applied to the horizontal deflection plates. Usually, additional provisions signal are made for appliying an external triggering signal or utilizing the 60 Hz line for triggering. Also the sweep generator may be bypassed and an external signal applied directly to the horizontal amplifier. CRO controls: The controls available on most oscilloscopes provide a wide range of operating conditions and thus make the instrument especially versatile. Since many of these controls are common to most oscilloscopes a brief description of them follows.

Block diagram of typical oscilloscope Fig 3.7

25

Chapter 4: Software design

4.1 Proteus design:

26

Chapter 5: Source code in c-language

#include<reg51.h> #include<math.h> sbitpulse=P1^0; voidmain() { inti,j,x,f=50; for(i=0;i<360;i++) { j=i%12; x=5*sin(2*3.14*f*i/18)+5; if(x>j) pulse=1; else pulse=0; } }

27

Chapter 6: Applications
7.1 APPLICATIONS:
Three Phase Induction Motor Speed Controllers. Uninterruptible Power Supplies. Static Inverter Power Supplies. Power Waveform Generators. Speed control of ID fans.

28

Chapter 7: Bibliography

REFERENCE BOOKS:

Programming in ANSI C: E BALAGURUSAMY.


The 8051microcontroller and embedded systems: MUHAMMAD ALI MAZIDI.

JANICE GILLISPIE MAZIDI.

The 8051 microcontroller: KENNETH J. AYALA.

WEB SITES: www.atmel.com www.national.com www.google.com www.scientech.bz

29

You might also like