8051,TRIANGULAR+SINE WAVE GENERATOR :pls help!

This forum is about writing software to embedded systems and microcontrollers.

8051,TRIANGULAR+SINE WAVE GENERATOR :pls help!

Postby jenuine on Fri Jan 26, 2007 9:18 am

hi there! 8)
can anyone please help me to program for triangular wave generation. I am using DAC0800 to design a hardware for sine wave and triangular wave generator and it is to be used with microcontroller 8051.I've found the code for sine wave generation, please verify :

AGAIN: MOV DPTR,#TABLE
MOV R2, #COUNT
BACK: CLR A
MOVC A,@A+DPTR
MOV P1,A
INC DPTR
DJNZ R2,BACK
SJMP AGAIN
ORG 300
TABLE: DB 128,192,238,255,238,192
DB 128,64,17,0,17,64,128


SOMEONE PLEASE BE KIND ENOUGH TO WRITE ME A PROGRAM WHICH CAN GENERATE A TRIANGULAR WAVEFORM......

Thanks a Zillion in advance :)
jenuine
 
Posts: 7
Joined: Tue Jan 02, 2007 10:43 pm

Re: 8051,TRIANGULAR+SINE WAVE GENERATOR :pls help!

Postby minar_kuet on Wed Oct 28, 2009 4:14 am

7.5.2 SINE WAVE GENERATION
To generate a sine wave, we first need a table whose values represent the magnitude of the sine
of angles between 0 & 360 degrees. The values for the sine function vary from -1 to +1 for 0 to
360 degrees angles. Therefore, the table values are integer numbers representing the voltage
magnitude of the sine of thita.This method ensures that only integer numbers are outputted to the
DAC(Digital to Analog Converters) by the 8051 Microcontroller. The following table gives the
angles, sine values, the voltage magnitudes, the integer values representing the voltage
magnitude for each angle (with 30 degree increments). To generate we assumed the full-scale
voltage of 10V for DAC Output. Full scale output of DAC is achieved when all the data inputs of
the DAC are high. Therefore to achieve the full-scale 10 V output we use the following equation
:
Vout=5V + 5×sinΘ
Vout of DAC for various angles is calculated as shown in the table:

COMPILED ASSEMBLY CODE FOR SINE WAVE GENERATION
USING TOP VIEW SIMULATOR (VERSION 1.2h)
SINE
PAGE 1
0000 1 ORG 0000H
0000 900300 2 AGAIN: MOV DPTR,#TABLE
0003 7AFF 3 MOV R2,#255
0005 C2E0 4 BACK: CLR 0E0H
0007 93 5 MOVC A,@A+DPTR
0008 85E090 6 MOV 90H,0E0H
000B A3 7 INC DPTR
000C DAF7 8 DJNZ R2,BACK
000E 80F0 9 SJMP AGAIN
0300 10 ORG 300H
11
0300 80C0EEFF 12 TABLE: DB 128,192,238,255,238,192
0304 EEC0
0306 80401100 13 DB 128,64,17,0,17,64,128
030A 114080
14 END
VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND
SINE
PAGE 2
AGAIN. . . . . . . . . . . . . . C ADDR 0000H
BACK . . . . . . . . . . . . . . C ADDR 0005H
TABLE. . . . . . . . . . . . . . C ADDR 0300H
Page 35



TRIANGULAR WAVE GENERATION
If the sequence Y represents triangle wave, the Triangle Wave generates the pattern according to
the following equation.
YI = A*tri(phase[I])
for I = 0, 1, 2, …, N – 1 and where A is amplitude and N is the number of samples.
tri(phase[I] is defined by the following equation.
P/90 for 0≤P<90
Tri(phase[i])= 2-P/90 for 90≤P<270
P/90-4 for 270≤P<360
Angle P (Degrees) Tri(phase[i]) Vout(Voltage Magnitude)
5V+(5V×Tri(phase[i]))
Values sent to
DAC(decimal)
Vout×25.6
0 0 5 128
30 0.3333 6.6654 170
60 0.6666 8.3335 213
90 1.0000 10.0000 255
120 0.6666 8.3335 213
150 0.3333 6.6654 170
180 0 5.000 0
210 -0.3333 3.3333 85
240 -0.6666 1.6765 42
270 -1.0000 0 0
300 -0.6666 1.6765 42
330 -0.3333 3.3333 85
360 0 5.0000 128


COMPILED ASSEMBLY CODE FOR TRIANGULAR WAVE
GENERATION USING TOP VIEW SIMULATOR (VERSION 1.2h)
TRIANGULAR


PAGE 1
0000 1 ORG 0000H
0000 900300 2 AGAIN: MOV DPTR,#TABLE
0003 7AFF 3 MOV R2,#255
0005 C2E0 4 BACK: CLR 0E0H
0007 93 5 MOVC A,@A+DPTR
0008 85E090 6 MOV 90H,0E0H
000B A3 7 INC DPTR
000C DAF7 8 DJNZ R2,BACK
000E 80F0 9 SJMP AGAIN
0300 10 ORG 300H
0300 80C0EEFF 12 TABLE: DB 128,170,213,255,213,170
0304 EEC0
0306 80401100 13 DB 0,85,42,0,42,85,128
030A 114080
14 END
VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND
SINE
PAGE 2
AGAIN. . . . . . . . . . . . . . C ADDR 0000H
BACK . . . . . . . . . . . . . . C ADDR 0005H
TABLE. . . . . . . . . . . . . . C ADDR 0300H
minar_kuet
 

Re: 8051,TRIANGULAR+SINE WAVE GENERATOR :pls help!

Postby Guest on Wed Dec 23, 2009 5:43 am

Is this program useful for microcontroller 8051?
Guest
 


Return to Embedded Software

Who is online

Users browsing this forum: No registered users and 2 guests

cron