Triangular Wave Generation Using 8051
SOFTWARE: KEIL MICRO VISION 4
SIMULATOR: KEIL MICRO VISION 4
PROGRAM:
#include<reg51.h>
void delay(int q); // delay function
void main()
{
while(1)
{
int i=0;
for(i=0;i<=255;i++) // increamenting slope
{
P1=i; // value sending to port 1
delay(5); // delay
}
for(i=255;i>=0;i--) // decrementing slope
{
P1=i; // value sending to port 1
delay(5); // delay
}
}
}
void delay(int q) // delay function
{
int r;
while(q>0)
{
for(r=0;r<q*1275;r++);
q--;
}
}
PROGRAM DESCRIPTION:
In this project,I have generated the triangular wave on Port 1 of 8051.
For creating incrementing slope of triangular wave,I have send the values from 0 to 255 to Port 1.I have send one value at a time.After sending each value,I have provided some delay to Port 1.Thus I have created incrementing slope of triangular wave.For creating decrementing slope of triangular wave,I have used the same method.Only the difference is the values from 255 to 0 are send to Port 1.
Thus I have created triangular wave on Port 1.
VIDEO:
Comments
Post a Comment