/* .nf .pl 66 .po 10 Copyright 1999 Novatech Instruments, Inc. 17962 Midvale Avenue N., Suite 219 Seattle, Washington 98133 FILE: makefile.c This file, written for and compiled by Power C, generates control files for Novatech Instruments, Inc. PC-based Direct Digital Synthesizers. It is provided for exclusive use with Novatech Instruments, Inc. products and is without warranty, expressed or implied. Author: Steven D. Swift, P.E. Principal Engineer Novatech Instruments, Inc. Revision history: Rev 0.00: June 4, 1994 created July 9, 1994 added printing of model number and model frequency limits. Added getdate function. Oct 5, 1994 Changed to show upper and lower limits on Bogus frequency input. Rev 1.00 Mar 15, 1995 Changed lower limit on DDS4pc to 1Hz. Added Revision printout. Rev 2.00 Dec 5, 1998 Added in DDS7pc limits. MASTER RELEASE HAS THIS REVISION HISTORY STRIPPED */ #include #include #include #include #define Rev 2.00 /* generates sweep file for PC-based synthesizers */ void main(int argc, char *argv[]) { FILE *fileptr, *fopen(); double n ; double Start_Freq ; double Stop_Freq ; double Points ; double Step ; double freq; double Atten; double Dwell; int i; int Model; /* 3 means dds3pc, 4 means dds4pc, 7 means dds7pc */ char string[3]; double ratio; double step; double fout; double Fmax; double Fmin; struct date datebuf; char *Month; /* check for file permissions and open if okay */ if (argc == 1) { printf("NO OUTPUT FILE SPECIFIED\n"); printf("usage: makefile OUTPUT\n"); exit(); } if (( fileptr = fopen(argv[1],"w")) == NULL) { printf("CAN'T OPEN %s\n", argv[1]); exit(); } /* input user data first */ printf("\nEnter type of sweep file desired. \n"); printf("\nType \"log\" for logarithmic, type \"lin\" for linear: "); gets(string); printf("\nWhich Model are you using ( DDS7pc, DDS4pc or DDS3pc )? \n"); printf("\nType \"3\" for DDS3pc, \"4\" for DDS4pc, \"7\" for DDS7pc: "); scanf("%d", &Model); if (Model == 3) { Fmax = 12.000e6; Fmin = 2.0; } else if (Model == 4) { Fmax = 34.000e6; Fmin = 1.0; } else if (Model == 7) { Fmax = 68.000e6; Fmin = 100.0; } else { printf("\nBogus Model number! Must be 7, 4 or 3. Try again.\n"); exit(0); } printf("\nInput number of points in your output file (1000 max): "); scanf("%lf", &Points); if( (Points > 1000.0) ) { printf("\nToo many points! Try again.\n"); exit(); } printf("\nInput Start Frequency : "); scanf("%lf", &Start_Freq); if(Start_Freq < Fmin || Start_Freq > Fmax) { printf("\nBogus Starting Frequency!\n"); printf("Model DDS%dPC requires frequency >= %.2lf Hz and <= %.2lf MHz.\n", Model,Fmin,Fmax/1.0e6); exit(0); } printf("\nInput Stop Frequency : "); scanf("%lf", &Stop_Freq); if(Stop_Freq > Fmax || Stop_Freq < Fmin) { printf("\nBogus Stop Frequency!\n"); printf("Model DDS%dPC requires frequency >= %.2lf Hz and <= %.2lf MHz.\n", Model,Fmin,Fmax/1.0e6); exit(0); } printf("\nInput Attenuation in dB: "); scanf("%lf", &Atten); printf("\nInput Dwell time in seconds : "); scanf("%lf", &Dwell); /* find today's date */ getdate(&datebuf); if (datebuf.da_mon == 1) Month = "Jan"; if (datebuf.da_mon == 2) Month = "Feb"; if (datebuf.da_mon == 3) Month = "Mar"; if (datebuf.da_mon == 4) Month = "Apr"; if (datebuf.da_mon == 5) Month = "May"; if (datebuf.da_mon == 6) Month = "Jun"; if (datebuf.da_mon == 7) Month = "Jul"; if (datebuf.da_mon == 8) Month = "Aug"; if (datebuf.da_mon == 9) Month = "Sep"; if (datebuf.da_mon == 10) Month = "Oct"; if (datebuf.da_mon == 11) Month = "Nov"; if (datebuf.da_mon == 12) Month = "Dec"; if (strcmp(string, "log") >= 0) { fprintf(fileptr, "# LOG sweep file for Novatech Model DDS%dPC Synthesizer. \n", Model); fprintf(fileptr, "# Created by makefile.exe, Rev %.2f: %.2d - %s - %.2d.\n", Rev,datebuf.da_day,Month,datebuf.da_year); fprintf(fileptr, "#\n"); fprintf(fileptr, "start\n"); fprintf(fileptr, "#\n"); i = 0; ratio = Stop_Freq / Start_Freq; step = pow( ratio, 1.0/( Points-1.0) ); fout = Start_Freq * pow( step, (double) (i) ); fprintf(fileptr, "out \t %lf \t %.0f \t %.4lf\n",fout,Atten,Dwell); i++; while ( i < (int) Points ) { fout = Start_Freq * pow( step, (double) (i) ); fprintf(fileptr, "out \t %lf \t %.0f \t %.4lf\n",fout,Atten,Dwell); i++; } fprintf(fileptr, "#\n"); fprintf(fileptr, "stop\n"); fprintf(fileptr, "#\n"); } else if (strcmp(string,"lin") >= 0) { fprintf(fileptr, "# LIN sweep file for Novatech Model DDS%dPC Synthesizer. \n", Model); fprintf(fileptr, "# Created by makefile.exe, Rev %.2f: %.2d - %s - %.2d.\n", Rev,datebuf.da_day,Month,datebuf.da_year); fprintf(fileptr, "#\n"); fprintf(fileptr, "start\n"); fprintf(fileptr, "#\n"); i = 0; ratio = Stop_Freq - Start_Freq; step = ratio/(Points-1); fout = Start_Freq + ((double) i )*step; fprintf(fileptr, "out \t %lf \t %.0f \t %.4lf\n",fout,Atten,Dwell); i++; while ( i < (int) Points ) { fout = Start_Freq + ((double) i )*step; fprintf(fileptr, "out \t %lf \t %.0f \t %.4lf\n",fout,Atten,Dwell); i++; } fprintf(fileptr, "#\n"); fprintf(fileptr, "stop\n"); fprintf(fileptr, "#\n"); } else { printf("BOGUS sweep type. Try again.\n"); exit(); } }