954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Generating sine wave

HI All
How can we generate a sine wave without using the sin() function.

Thanks
pretu

pretu
Newbie Poster
3 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

you can use the sine series for calculation upto a certain accuracy and then plot the curve

HI All
How can we generate a sine wave without using the sin() function.

Thanks
pretu

Jishnu
Posting Pro
518 posts since Oct 2006
Reputation Points: 193
Solved Threads: 25
 

I'm assuming you don't want to use the cosine function either :) You could create a table of results and read the values off that instead of using the sine function. Alternatively you could use exponentials and imaginary numbers ...

twomers
Posting Virtuoso
1,877 posts since May 2007
Reputation Points: 453
Solved Threads: 57
 

Take a look at the code snippet at:
http://www.daniweb.com/code/snippet66.html

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

What's with all the "how to do x without using the obvious x" questions?
http://www.daniweb.com/techtalkforums/thread80025.html

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

Hi all
How use sine wave psoc programing in micro controller cy8c27443 code

vinai05
Newbie Poster
1 post since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

Try the sine series .

nbaztec
Posting Pro in Training
475 posts since May 2010
Reputation Points: 57
Solved Threads: 60
 
HI All How can we generate a sine wave without using the sin() function. Thanks pretu


You can try Taylor series also.

0x69
Junior Poster
131 posts since Apr 2010
Reputation Points: 51
Solved Threads: 9
 
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
int main(void)
{

  int gdriver = DETECT, gmode;
  float x,w1,w,a,f,fs;
  cout<<"\n\tEnter amplitude:";
  cin>>a;
  cout<<"\n\tEnter freq.:";
  cin>>f;
  cout<<"\n\tEnter sampling points:";
  cin>>fs;
  w=2*3.14*f;

  initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
  line(0, 0,0,500);
  line(0,200,800,200);
 // getch();

  for(int n=0;n<640;n++)
  {
	w1=w*n;
	x=a*sin(w1/fs);
	x=x+200;
	putpixel(n,x,25);
  }
  getch();
		closegraph();
   return 0;
}
jayeshkamble143
Newbie Poster
1 post since Jul 2011
Reputation Points: 6
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You