0% found this document useful (0 votes)
278 views14 pages

DAC

This document describes an experiment to generate different waveforms using a DAC0800 interfaced with an 8051 microcontroller. The objectives are to interface the DAC0800, develop code to generate waveforms, and use time delays. It provides algorithms, code samples, and connection details to generate square, triangular, staircase and sine waves. The learning outcome is for students to write 8051 C code to generate waveforms and understand using time delays.

Uploaded by

sharada
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
278 views14 pages

DAC

This document describes an experiment to generate different waveforms using a DAC0800 interfaced with an 8051 microcontroller. The objectives are to interface the DAC0800, develop code to generate waveforms, and use time delays. It provides algorithms, code samples, and connection details to generate square, triangular, staircase and sine waves. The learning outcome is for students to write 8051 C code to generate waveforms and understand using time delays.

Uploaded by

sharada
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Experiment No.

PROBLEM DEFINITION: To Illustrate the concept of


DAC(0800) interface by generating different types
of waveforms like Square/Rectangular, Triangular,
Staircase and Sine wave.

Department of Computer Science and Engineering, GIT 1


Objectives of the Experiment:

1. To Interface DAC 0800 to 8051 Microcontroller.


2. To develop an 8051 ‘C’ code to generate different waveforms.

3. To use and generate time delays.

2
Department of Computer Science and Engineering, GIT
Theoretical Background of the Experiment

• DAC 0800 is a 8-bit high speed current output


digital to analog converter.
• DAC 0800 is used to convert the digital data
into analog signal.
• Digital data from any port is given to DAC input.

3
Department of Computer Science and Engineering, GIT
Interfacing Block Diagram

Department of Computer Science and Engineering, GIT 4


Algorithm to generate square wave
STEP 1: INCLUDE HEADER FILE “at89c51ed2.h”
STEP 2: FUNCTION DECALARATION OF DELAY ROUTINE.
STEP 3: BEGIN MAIN
STEP 4: SEND THE VALUE 0X00 ON PORT 0
STEP 5: CALL DELAY
STEP 6: SEND THE VALUE 0XFF ON PORT 0
STEP 7: CALL DELAY
STEP 8: REPEAT STEPS 4 TO 7 FOREVER
STEP 9: END MAIN
STEP 10: DELAY ROUTINE: DECLARE VARIABLES
STEP 11: INITIALIZE FOR LOOP TO INCLUDE CERTAIN DELAY
STEP 12: END DELAY ROUTINE.

Department of Computer Science and Engineering, GIT 5


Code For Square wave
#include “at89c5ed2.h”
void delay(void);
void main ()
{
while(1)
{
P0 = 0x00; // program outputs 0 and 0xff alternatively to port P0 with a delay
delay(); .
P0 = 0xff;
delay();
}
}
void delay(void) // function to generate delay
{
int i;
for(i=0;i<=300;i++);
}

Department of Computer Science and


03/25/2020 6
Engineering, GIT
Algorithm to generate Staircase wave

STEP 1: INCLUDE HEADER FILE “at89c51ed2.h”


STEP 2: DECLARE VARIABLES
STEP 3: BEGIN MAIN
STEP 4: INITIALIZE FOR LOOP; for (i=0;i<255;i+50) FOR STEP SIZE OF 50
ON Y-AXIS
STEP 5: SEND THE VALUES 0 TO 255 ON PORT 0
STEP 6: INITIALIZE FOR LOOP TO INCLUDE CERTAIN DELAY
STEP 7: SEND i+30 ON PORT 0 TO INCLUDE INCREMENT OF 30 ON X-
AXIS.
STEP 8: END MAIN.

Department of Computer Science and


03/25/2020 7
Engineering, GIT
Code for Staircase wave
#include “at89c51ed2.h”
unsigned int i, j;
void main ()
{
while(1)
{
for(i=0;i<=255;i=i+50)
{
P0=i;

for(j=0;j<100;j++)
{
}
P0=i+30;
}
}
}

Department of Computer Science and


03/25/2020 8
Engineering, GIT
Algorithm to generate Triangular wave

STEP 1: INCLUDE HEADER FILE “at89c51ed2.h”


STEP 2: DECLARE THE VARIABLE COUNT
STEP 3: BEGIN MAIN
STEP 4: INITIALIZE FOR LOOP TO COUNT FROM 0 TO 255;
for (count=0; count! =0xff; count++)
STEP 5: SEND COUNT ON PORT 0
STEP 6: INITIALIZE FOR LOOP TO COUNT FROM 255 TO 0;
for (count=0xff; count! =0; count--)
STEP 7: SEND COUNT ON PORT 0
STEP 8: REPEAT STEPS 4 TO 7 FOREVER.
STEP 9: END MAIN
Department of Computer Science and
03/25/2020 9
Engineering, GIT
Code For Triangular wave

#include “at89c51ed2.h
unsigned char count;
void main ()
{
while(1)
{
for(count=0;count!=0xff;count++)
{ P0=count;
}
for(count=0xff; count>0;count--)
{
P0=count;
}
}
}

Department of Computer Science and


03/25/2020 10
Engineering, GIT
Algorithm to generate Sine wave

STEP 1: INCLUDE HEADER FILE “at89c51ed2.h”


STEP 2: DECLARE THE EXTERNAL RAM ARRAY VALUES. ɵ=7.2 DEGREES. 50
VALUES ARE DECLARED IN AN ARRAY.
STEP 3: DECLARE INDEX VARIABLE
STEP 4: BEGIN MAIN
STEP 5: INITIALIZE FOR LOOP for (count=0; count<49; count++)
STEP 6: SEND ARRAY VALUES ON PORT 0
STEP 7: REPEAT STEPS 5 TO 6 FOREVER
STEP 8: END MAIN

Department of Computer Science and


03/25/2020 11
Engineering, GIT
Code For Sine wave
#include “at89c51xd2.h>
xdata unsigned char sine_tab[49]=
{ 0x80,0x90,0xA1,0xB1,0xC0,0xCD,0xDA,0xE5,0xEE,0xF6,0xFB,0xFE,
0xFF,0xFE,0xFB,0xF6,0xEE,0xE5,0xDA,0xCD,0xC0,0xB1,0xA1,0x90,
0x80,0x70,0x5F,0x4F,0x40,0x33,0x26,0x1B,0x12,0x0A,0x05,0x02,
0x00,0x02,0x05,0x0A,0x12,0x1B,0x26,0x33,0x40,0x4F,0x5F,0x70,0x80};
unsigned int count; // index variable for loop count
void main ()
{
while(1)
{
for(count=0;count<49;count++)
{
P0 = sine_tab[count];
}
}
}
 

Department of Computer Science and


03/25/2020 12
Engineering, GIT
CONNECTION DETAILS

• PORT 0 TO CN15.

Department of Computer Science and


03/25/2020 13
Engineering, GIT
Learning Outcomes of the Experiment
At the end of the session, students should be able to :

1) Write the 8051 ‘C’ program to generate various waveforms and understand
how to create and use time delays .

Department of Computer Science and Engineering, GIT 14

You might also like