Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Where can I find a look up table for sine wave and cos wave?

Status
Not open for further replies.

Victory1981

Newbie level 6
Joined
May 21, 2003
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
177
look-up table sin

Hi,everyone.
Where can I find a look up table for sine wave and cos wave?
I want to make a function(wave) generator. I use Flex10K10(has 6144bit RAM) and a 8 bit DAC.
But the problem is where can I get a LUT for sine wave and cos wave?
Can you help me.
Thanks in advance.
 

sine wave lut

Hello Victory1981,

why don't you generate the table by yourself? You can do that for example with Mathlab or a C-Compiler. After that you can insert the table into your HDL as an array. The sythesis tool will put the table into LUTs of the the FPGA or into Embedded RAM/ROM.

by,
cube007
 

lut for sine wave and cosine wave

There are some second order effects involved. Rounding off to the number of bits for your DAC is important. The errors will produce extra spurious outputs. You should look at a book on DDS to find the details of how to do the rounding and how to test in a computer program for spurs.
 

how to make look up table for sine wave

why do you want to generate a lookuptable for sine and cos function.
because sine and cosine are the same functions with only a phaseshift of 90° you need only one LUT for both. -> sin(x) = cos(x+pi/2)

Next sin (x) = - sin(X+pi) means you only need to store positive values of the halfwave and multiply them by -1 if your phase was in a certain interval.

And at last you don't need to store the second half of the positive wave eigther. for values in x =[0;pi] it's true: sin (x) = sin(pi-x) you only need the values for x=[0;pi/2].
This is done in DDS chips.

so if your application is really time critical you could think of saving the memory for the cosine table. If you have a bit time you can save 7/8 th of the memory or increase your resolution by factor 8 with the same amout of memory.

For improving the signal you should round your float values from the genrating program to your target bit width. after this you can noiseshape the quantizated signal. And dither will additionally improve the quality. these techniques techniques are described in a lot of audio systems.
 

sine wave look up table dac

I generate the LUT with Turbo C, it's very easy.
I am just too busy yesterday so ask for your help,
and I'm now free so I make a program by myself.
Thanks all the same.
Here is my code, if anyone needs it, modify it as you wish.

Compiler Turbo C 2.0

It's for 8 bit DAC. and 256bytes RAM for cosine wave,
256bytes for sine wave, 256bytes for triangular wave.


#include "stdio.h"
#include "math.h"
#define pi 3.14
main()
{int sinwave[256],coswave[256],triwave[256];
int i;
FILE *sinmif,*cosmif,*trimif;
sinmif=fopen("sinwave.mif","w");
cosmif=fopen("coswave.mif","w");
trimif=fopen("triwave.mif","w");
for (i=0;i<=255;i++)
{ sinwave=(int)((sin(i*2*pi/255)+1)*128);
coswave=(int)((cos(i*2*pi/255)+1)*128);
if (i<128)
triwave=2*i;
else
triwave=2*(255-i);
fprintf(sinmif,"%d:%d\n",i,sinwave);
fprintf(cosmif,"%d:%d\n",i,coswave);
fprintf(trimif,"%d:%d\n",i,triwave);
}
}
 

Re: sine wave look up table dac

Would I remove the cos and tri wave parts if I wanted just a sine wave? Also, how would I then implement this into VHDL? I already created the RAM and have an 8 bit DAC as well. Thanks. I have 44 frequencies defined in MATLAB spread across 4 separate octaves.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top