+ Post New Thread
Results 1 to 4 of 4

8th March 2006, 15:56 #1
 Join Date
 Jul 2004
 Posts
 53
 Helped
 7 / 7
 Points
 2,213
 Level
 10
generate sine wave with microcontroller
I want to design a digital signal generator which can generate digital values for the Sine wave using 8051 and then convert it to analog sine wave using DAC0808. But how to compute values for a function x[n] = sin(w n) using 8051 if i want 50 samples per cycle and 100 Hertz frequency of sine wave. I don't want to use lookup table in which i already have 50 values for 1 cycle of sine wave. I want to compute the values in realtime using 8051. Any DSP concepts which might be good for generating sin(w n) ????

8th March 2006, 15:56

29th March 2006, 22:31 #2
 Join Date
 Dec 2005
 Location
 CATALUNYA
 Posts
 27
 Helped
 5 / 5
 Points
 1,550
 Level
 8
microcontroller sine wave
Hello starfish:
I think it is difficult and very slow for a 8051 do this task.
Usually you'll need a multiplier, and that is by nature, slow.
In addition, Have you tried to generate a simple triangular signal?
In that case you need only make add and subtractions, that's slow too.
Unless you need very slow signals, you'll need others "things" like DSP, Hardware multipliers, (others uControlers, FPGA's)
Why you don't want use a lookup table?
It's,I think, the fastest way to solve your problem.
I hope this help a bit.

29th March 2006, 22:31

30th March 2006, 00:10 #3
 Join Date
 Jun 2005
 Location
 Kent, UK
 Posts
 596
 Helped
 102 / 102
 Points
 5,445
 Level
 17
8051 sine wave
The DAC0808 is an 8bit DAC. It can't be that hard to calculate sin(n) to 8 bit precision. W.n and the output will be integer not floating point.
I'm sure it can be done with integer math operations by suitably scaling the values.
Integer multiplication in a processor that handles data in 8bit chunks isn't paticularly onerous, a few hundred cycles to multiply two 32bit number in the worst case.
Google turns up loads of interesting webpages about generating sine
Here's a page about calculating an 8bit sine value with integer operations.
http://www.ganssle.com/articles/atrig.htm
5000 calculations/second with a reasonably fast 8051 clone sounds feasible.
A lookup table is the best way of doing it. You only need a table for a quarter of a sinewave, you just read the table in reverse and/or invert the values for the other three quarters of a cycle.
When only using 8bit output and a really low frequency like 100Hz it might be feasable to have a lookup table of the time interval between increasing the output by 1 in steps of say 0.5uS, instead of putting out new samples at a fixed interval.

30th March 2006, 00:10

30th March 2006, 09:03 #4
 Join Date
 Feb 2006
 Posts
 199
 Helped
 19 / 19
 Points
 2,402
 Level
 11
signal generator using 8051
I want to design a digital signal generator which can generate digital values for the Sine wave using 8051 and then convert it to analog sine wave using DAC0808.
As posted elsewhere on this board:
h**p://rapidshare.de/files/7833926/Digital_Frequency_Synthesis_Demystified_MAZ.rar.ht ml
If you want something simpler, get youself a 8038 chip and wire it up. It will work ffine for sinewaves < 100 KHz (but really in this business, DDS is the future, learn it)
+ Post New Thread
Please login