Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: Pulse Width Mudulation(PWM)
Description: explanation and code for generating a pwm square wave with variable duty cycle in 8051 or any other micro controller. explained with softwares used and snapshots

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


PULSE WITH MODULATION
OBJECTIVE:
The objective is to generate a pulse of constant time period on a certain pin of 8051
Microcontroller and to increase and decrease the duty cycle of the generated pulse using two
control push buttons such that its time period remains unchanged
...
The code is as
follows:
#include ...
h>
sbit pulse = P1^0;
sbit inc = P2^0;
sbit dec = P2^1;
void msdelay(int);
main()
{
int i=200;
int j=200;
int D=0x50;
P3=D;
do
{
pulse=1;
msdelay(i);
pulse=0;
msdelay(j);
}
while(inc==0 && dec==0);
check_again:
if(inc==1 && dec==0)
{

while(inc==1 && dec==0)
{
if(inc==1 && dec==0)
{i=i+20; j=j-20; D=D+0x10; P3=D;}
else if(inc==0 && dec==1)
{i=i-20; j=j+20; D=D-0x10; P3=D;}
else
{i=i; j=j;}

do
{
pulse=1;
msdelay(i);
pulse=0;
msdelay(j);
}
while(inc==0 && dec==0);
}
//////// while 1 closed
goto check_again;
}
//////// if closed

else
{
while(inc==0 && dec==1)
{
if(inc==0 && dec==1)
{i=i-20; j=j+20; D=D-0x10; P3=D; }
else if(inc==1 && dec==0)
{i=i+20; j=j-20; D=D+0x10; P3=D;}
else
{i=i; j=j;}

do
{
pulse=1;
msdelay(i);

pulse=0;
msdelay(j);
}
while(inc==0 && dec==0);

}

/////// while 2 closed

goto check_again;
//////// else closed

}

//////// main closed

///////////////// delay function//////////////////

void msdelay(int time)
{
int x,y;
for(x=0; x{ for(y=0; y<1275; y++);}
}

The I write the C language code in Kiel Software and compiled it to generate the required HEX
file
...
The simulated circuit is shown in the figure below
...
While at the same time the resulting duty cycle can also be observed on the
7-segment display as shown in the figure above
...



Title: Pulse Width Mudulation(PWM)
Description: explanation and code for generating a pwm square wave with variable duty cycle in 8051 or any other micro controller. explained with softwares used and snapshots