- 8th March 2006, 14:56 #1
- Join Date
- Jul 2004
- 7 / 7
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, 14:56
- Join Date
- Dec 2005
- 5 / 5
microcontroller sine wave
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, 21:31
- Join Date
- Jun 2005
- Kent, UK
- 96 / 96
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.
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.
- 29th March 2006, 23:10
- Join Date
- Feb 2006
- 19 / 19
signal generator using 8051
This is like asking you want to build a 100 story building in the twentieth century using nothing but the blocks they used to make the pyramids 3000 years ago. It doesn't work that way. The DAC you are talking about is pretty good for DC motor control and stuff but it was never meant for something like sine-wave generation (way to slow). Get yourself the book "Digital Frequency Synthesis Demystified" available on this board. It will show you how to use a chip with a DAC that runs in the 10MHz+ range with onboard filters and logic to make sine-wave and triangle-wave synthesis a piece of cake.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:
If you want something simpler, get youself a 8038 chip and wire it up. It will work ffine for sine-waves < 100 KHz (but really in this business, DDS is the future, learn it)