/*______________________________________________________________________ MAKESPLT.C Test Signal Generator for Floating Point Data Revision: 2.0, 18-FEB-91, Steven Cox, Analog Devices 10-APR-91, Ronnin Yee, Analog Devices ______________________________________________________________________*/ /* Includes Random numbers */ #include #include #define MAX_LEN 4096 double x[MAX_LEN]; /*made global for a huge array*/ main() { int i, j, n, num_sines, pstart, plength; float amplitude, freq; double pi=3.14159265359; FILE *even_file; FILE *odd_file; char filename[25], s_c_p; printf("%c%c%c%c",27,91,50,74); /*clear screen*/ printf("%c%c%c",27,91,72); /*curser home*/ printf(" _________MAKESPLT_________\n"); printf("Generates a floating point test data file of summed sines,\n"); printf("cosines, pulses and random data. This can be used to test\n"); printf("ADSP-21020 RFFT4 code and to generate Sine and Cosine arrays.\n"); printf("The data is saved in two files; one contains the even indexed\n"); printf("data and the other contains the odd indexed data.\n"); printf("Version 0.1, Ronnin Yee, Analog Devices\n"); printf("_______________________________________________________________\n"); printf("\nEnter the output filename for even samples: "); scanf(" %s",filename); even_file=fopen(filename,"w"); printf("\nEnter the output filename for odd samples: "); scanf(" %s",filename); odd_file=fopen(filename,"w"); printf("Enter the number of points (max %d) -> ",MAX_LEN); scanf(" %d",&n); printf("Enter the number of waveforms to add --> "); scanf(" %d",&num_sines); /*clear accumulator*/ for (i=0; i <= n-1; i++) { x[i]=0.0; } /*sum up all signals together*/ for (j=1; j <= num_sines; j++) { printf("\nWave #%d (S)ine, (C)osine, (P)ulse or (R)andom ? ",j); scanf(" %c",&s_c_p); printf("Wave #%d Enter amplitude ---------------> ",j); scanf(" %f",&litude); if(s_c_p == 's' || s_c_p == 'S') { printf("Wave #%d Enter frequency bin (0 to %d) -> ",j,n-1); scanf(" %f",&freq); for (i=0; i <= n-1; i++) { x[i]=x[i]+( amplitude*sin(2.0*pi*(double)i*freq/(double)n) ); } } else if(s_c_p == 'c' || s_c_p == 'C') { printf("Wave #%d Enter frequency bin (0 to %d) -> ",j,n-1); scanf(" %f",&freq); for (i=0; i <= n-1; i++) { x[i]=x[i]+( amplitude*cos(2.0*pi*(double)i*freq/(double)n) ); } } else if(s_c_p == 'p' || s_c_p == 'P') { printf("Wave #%d Enter pulse start bin (0 to %d) -> ",j,n-1); scanf(" %d",&pstart); printf("Wave #%d Enter pulse length (1 to %d) -> ",j,n-pstart); scanf(" %d",&plength); for (i=pstart; i <= pstart+plength-1; i++) { x[i]=x[i]+amplitude; } } else if(s_c_p == 'r' || s_c_p == 'R') { for (i=0; i <= n-1; i++) { x[i]=x[i]+amplitude*((rand()-16384.0)/16384.0)*(rand()/32767.0); } } else printf("Not S,C,P or R. You wasted that wave\n"); } /*end j*/ /*write results*/ printf("\n"); for (i=0; i <= n-1; i+=2) { fprintf(even_file,"%22.14e\n",x[i]); fprintf(odd_file,"%22.14e\n",x[i+1]); printf("%d : %22.14e : %22.14e\r",i,x[i],x[i+1]); } fclose(even_file); fclose(odd_file); printf("\nFinished\n"); }