
我这是在arm板上实现的,你看看对你有用没
画正弦波/
void sinmain(void)
{
unsigned int x,y;
//double offset=0;//x坐标偏移量
//for(;;)
{
for(x=320;x>0;x--)
{//画正弦波
y=(int)(100sin(((double)x)/200));//+offset
PutPixel (y+120, x,0x07e0); Delay(10);
}
/offset+=1;
if(offset>=2314)
offset=0;/
Delay(100);
Lcd_ClearScr( (0x00<<11) | (0x00<<5) | (0x00) );
}
}
正弦波输入 振幅,频率,时步,相位
三角波锯齿波输入 振幅,坡1宽,坡2宽,无波宽,时步
三角波 w1=w2, 锯齿波 w1 != w2
程序没有考虑时间 宽度w1=0 或 w2 =0,如果等于0,请给一个非0值,例如 00000001
脉冲方波,请自己模仿三角波程序计算。w期间等于amp,flat_t期间等于0
#include <stdioh>
#include <mathh>
void main()
{
double y[2048];
double pi,r;
double amp,f,phi,dt,t,x;
double w,flat_t,slop1,slop2,L,w1,w2;
int flag_w1=0,flag_w2=0;
long int i;
int N=2048;
char str[5];
pi = atan(10) 40;
fprintf(stderr,"Enter sin or tri\n");
scanf("%s",&str[0]);
if ( strncmp(str,"sin",3) == 0)
{
fprintf(stderr,"enter Amp Hz delta_t phase\n");
fprintf(stderr,"for example: 10 100 0001 1414\n");
scanf("%lf %lf %lf %lf",&,&f,&dt,&phi);
for (i=0;i<N;i++) y[i]= amp sin(20pi f dt i + phi );
for (i=0;i<N;i++) fprintf(stdout,"%lf\n",y[i]);
exit(0);
};
fprintf(stderr,"enter Amp w1 w2 flat_t dt\n");
fprintf(stderr,"for example: 1 1 1 1 001 \n");
scanf("%lf %lf %lf %lf %lf",&,&w1,&w2,&flat_t,&dt);
w = w1+w2;
L = w + flat_t;
slop1 = amp / w1;
slop2 = -amp / w2;
for (i=0;i<N;i++)
{
t = dt (double) i;
x = t - L (double) ( (int) (t / L));
if (x >= 00 && x <= w1) y[i] = slop1 x;
if (x > w1 && x < w ) y[i] = amp + slop2 (x - w1);
if (x >= w && x <= L ) y[i] = 00;
}
for (i=0;i<N;i++) fprintf(stdout,"%lf\n",y[i]);
exit(0);
}
正弦波发生器,c语言编制的DSP实验测试程序。-sine
wave
generator,
c
language
DSP
experimental
testing
procedures
以上就是关于大侠求救~求一单片机C语言输出正弦波全部的内容,包括:大侠求救~求一单片机C语言输出正弦波、高分悬赏!急求!三角波,锯齿,正弦波,脉冲的C语言程序代码,不要单片机方面的,纯C的!、用单片机STC12C5410AD控制DAC0832输出方波,三角波,正弦波的C语言程序怎么写等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)