DAC interface to generate
a. Square waveform
b. Tnangular Wavefom
c. Ramp wavefom
d. Sine waveform
8
0
DAC CRO
5 PO
1
C
.a SQUARE WAVE GENERATION
wave using DAC.
Aim: To generate square
PC loaded with Keil
with 89S8252 microcontroller,
Apparatus required: 8051 board
CRO:
micro vision, DAC board,
Procedure: with Keil compiler.
1. Program is edited and is compiled file is downloaded.
2. After successful compilation, hex
CRO.
3. Output is seen in the
Algorithm for Square wavegeneration
and ffh (on) Values through
PO.
Output the values 00h(OfM) a
allow delay.
After feeding the data altered by having suitable combination
of
The duty cycle and the frequency can be
ON and OFF period delays.
waveform is displayed in CRO.
T h e port PO drives the DAC and the output
Program for square wave
#include<reg51.h>
void delay(unsigned int x)
{for(;x>0;x-);
return,
main()
while(1)
PO-Oxf
delay(500)
PO-Ox00:
delay(1500);
.
b
TRIANGULAR WAVEFORM GENERATION.
Aim To generate Triangular wave
using. DAAC.
Algorithm for Triangular wave generation
Output the initial value 00 through PO.
Increment it in steps of 1 until a count value of FFh (5V) is reached. Every time
repeat step 1.
Decrement it in steps of 1 until a zero value is reached and
repeat step 1.
Program for triangular wave:
#include<REG51.H>
main)
unsigned char i=0;
PO Ox00; * P0
while(1) as
Output port */
for(i-0;i<0xff,i++){ * Generate positive slope */
PO 1
for(i-Oxfe;i>Ox00;i-) /* Generate negative slope */
(P0 i;
P1 =i;
..c RAMP/SAW TOOTH WAVEFORM GENERATION
Aim: To generate Ramp/Saw tooth wave using DAC.
Algorithm for Ramp wave generation
Output the initial value 00 through PO.
Increment,it in steps of l until a count value of FFh
repeat step 1. (5V) is reached. Every time
Repeat atep 1&2 continuously.
'
****
Program for Ramp waveform
#include<REGS1.H>
main ()
Unsigned char i=0; /*PO as. Output port */
PO Ox00;
while (1)
*Generate ON pulse */
for (i-0;i<0xffi++)
P1i
POi,
[Link] WAVEFORM GENERATION
Algorithm for Sine wavegeneration
the equation
20°,15°..) of sineusing
.Compute step values (=
different
values thro PO.
. Output the
V= 2.5V +2.5Vsin6.
smoother will be sine wave.
More the steps
E.g.: 0 =0° V+
2.5V
V= 2.5V +2.5Vsine
DAC is 25.6X5V= 128.
The value sent to
Program for sine wave
#include <REG51xD2.H>
main)
static inta[13]={128,192,238,255,238,192,128,64,17,0,17,64,128);
unsigned char i=0 /* PO as Output port */
P0 Ox00;
while (1)
/*Output different values */
for(i-0;i<13;i++)
{PO=a[1];}
wwmw