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.

LOOK UP TABLE for sine wave signal

Status
Not open for further replies.

JJFORTY

Member level 1
Member level 1
Joined
Nov 16, 2004
Messages
40
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
368
look up table excel sin(x)

Hi Guys,

I'm creating a Look-up table to generate digital values of a Sinewave signal. I'm using excel to calculate data. Does anyone know a better software for this application..

Also which is the best and most accurate method to achive the digital sampling.

Thanks for attention..
 

oops forgot to say..

Assembly language programming is required.
 

Here is a sinewave table
 
  • Like
Reactions: adi11

    adi11

    Points: 2
    Helpful Answer Positive Rating
JJFORTY said:
I'm creating a Look-up table to generate digital values of a Sinewave signal. I'm using excel to calculate data. Does anyone know a better software for this application..

Excel is a good start. It is pretty easy to export the data that is calculated to a text file which can be configured as an assembly or C. First you need to format each cell to a binary number by rounding the number (see the ROUND function). Then you can format to hex if you like using the DEC2HEX and convert it to a string by concatenation like

"0x"& C4

where C4 is the cell. Excel is smart enough to convert the cell to a string.

Finally you need to create a VBA macro that takes each cell in turn and outputs it within a formatted line to a file. A possible example would look something like

Open Filename For Append as #1

'set up a,b for output cells

For iUtil=0 to 255

print #1, cells(a,b)
'increment a and/or b as necessary
'print any other format like a comment

next

close.


I realise this is a bit vague and I apologise, but I can't do much more without actually giving you to solution and time does not permit. If you are interested in taking this approach and learning about the many ways to use excel in electronics consider my book "Excel by Example : A Microsoft Excel Cookbook for Electronics Engineers " published by Elsevier/Newnes ISBN 0750677562. It includes this technique plus many other aspects of Excel. See Amazon.com for the TOC.

-Aubrey Kagan
 

    JJFORTY

    Points: 2
    Helpful Answer Positive Rating
JJFORTY, your question seems to say that you need an assembly language program that generates a table of sinewave values. That sounds strange. Please clarify what programming languages you have available, and what format the sine table needs to be.

Here's a little C program that generates a 256-point table of 16-bit sinewave values:
Code:
#include <stdio.h>
#include <math.h>
#define POINTS 256
#define BITS   16

int main(void)
{
  int n;

  for (n=0; n<POINTS; n++)
    printf("%d\n", (int)floor(0.5 + ((1 << (BITS-1)) - 0.50001) * sin(2 * 3.1415926535897932 / POINTS * n)));
  return 0;
}
 
  • Like
Reactions: adi11

    adi11

    Points: 2
    Helpful Answer Positive Rating
one smple and good solution.
sin(x+dx)=sin(x)+dxcos(x)
cos(x+dx)=cos(x)-dxsin(x)
initially take x as 0(binary 16 bit) and dx as 1/16 binary
from sine 0 and cos 0 ,you can get sine 1 and cos 1.proceed till 180 .......any prob...ask me again
 

Sorry for any confusion,

Basically, the idea is to create the digital equivalent of an analogue sine wave (as accurate as possible), store the binary values in a EPROM together with a DAC and Voilà! a Digitally-Generated sine wave source. (so i hope)

I started off by calcualting some vales of sin(x) look-up table attached, Unfortunally due to the limitations or my poor understanding of the software, excel does not recognize some binary values. Hence my first post

Thank you all for your replies, specialy antedeluvian for your comments and recommendation on the book i will defenitally look into that.

Any help or advice would be most appreciated.

Thanks Again.
 

JJFORTY said:
Thank you all for your replies, specialy antedeluvian for your comments and recommendation on the book i will defenitally look into that.

I must apologise. In my rush to get a plug for my book, I forgot to mention that most of what I mentioned is covered in a design idea that I wrote for EDN. The design idea in fact provided the basis for one of the chapters for the book. Of course the book takes the description much slower and the application is far more sophisticated, but the basis of what you need remains in the design idea which you can find here
**broken link removed**

Incidentally, you can also get a broad idea of the general tone of the book from these articles which actually led to the book. See the articles #138,#139, & #140 here.

http://www.dtweed.com/circuitcellar/xkaganau.htm

-Aubrey
 

I have done a project titled"low area cmos chip that gives digital equivalent of an analogue sine wave (as accurate as possible)".
The logic is
sin(x+dx)=sinx+dxcosx
cos(x+dx)=cosx-dxsinx
where i have taken
x as 16bit binary value
dx as 16bit binary value equal to 1
sin 0 = 000000000000000
cos 0 = 111111111111111
This has been worked out on excel sheet.
 

Let's say you create the sine table, what is the frequency(min and max) of the sine that can be produced?
 

thuvu said:
Let's say you create the sine table, what is the frequency(min and max) of the sine that can be produced?
Iam not an expert but I would say it rely only on the D/A converter.
Btw, the idea of Ankit is not bad. Or what about a Pulse Width Modulation, as it doesnt need a D/A.
 

Hai friends.....

I want to create sine look up table at frequency 50Hz and amplitude 2.5.... I confused..... any one clearly said formula and how to create lookup table
 

why can't you use CORDIC to get sine value in digital?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top