清霜一梦

计算ptd

0
阅读(1070)

因为公司的IC扫描sensor的频率常常和adapter中的noise频率重叠,导致IC接收到的数据出错。所以我们经常会用示波器看adapter的Noise,再用傅里叶变换找到相应应该回避的频段,包括倍频,分频的频段。懒人自有自己的做法,所以写了个小程序用来计算回避的频段。

复制代码

1 // date : 2013/8/26 2 // designer :pengxiaoen 3 //function : g 4 5 #include "stdio.h" 6 7 FILE *fp1; 8 double noise[10]; 9 double ptd[10][6];10 11 double function_ptd ()12 {13 int m=0;14 double temp;15 while (noise[m])16 { 17 temp = 24000000/noise[m]-1; 18 ptd[m][0] = temp /5; 19 ptd[m][1] = temp/4;20 ptd[m][2] = temp/3;21 ptd[m][3] = temp/2;22 ptd[m][4] = temp;23 ptd[m][5] = temp*2;24 25 m++;26 27 }28 }29 30 int main ()31 {32 int i=0;33 int j=0;34 for (j=0;j<10;j++) noise[j] =0; 35 36 printf("0 to end\n");37 printf ("The %d number is :",(i+1));38 scanf ("%lf",&noise[i]);39 40 while (noise[i])41 {42 i++;43 printf ("The %d number is :",(i+1));44 scanf ("%lf",&noise[i]); 45 } 46 function_ptd ();47 48 for(i=0;i<10;i++)49 { for(j=0;j<6;j++) 50 printf ("%8.0lf",ptd[i][j]); 51 printf("\n");52 }53 printf("\n\n");54 system ("pause");55 }

复制代码

24M 是IC的固定频率。输入的是测量到的Noise频率,以0 作为终止。


Baidu
map