#include #include #include #define s(x) ( (x)*(x) ) #define PI 3.141592 /* RF.c */ /* Program calculates the RF pattern necessary for the waveform generator to perform the pulse. Note: Need a different .RF file for each pulse length. Even for a 90 and 180 .RF pulses need different files for a given power level. Note that program gives the option of whether you want to pad the first 400 ns and the last 400 ns. */ main(argc,argv) int argc; char *argv[]; { float Pulse,Stepsize,Offset,Number_Steps,phase_Step,phase; int i,pad; FILE *fi; if(argc != 5) { printf("USAGE:\n"); printf("Argument 1: Duration of pulse (us)\n"); printf("Argument 2: Stepsize per element (200ns) \n"); printf("Argument 3: Offset in Hz (Downfield is positive)\n"); printf("Argument 4: Pad the first and last 400 ns (0 or 1)\n"); exit(1); } Pulse = (float) atof(argv[1]); Stepsize = (float) atof(argv[2]); Offset = (float) atof(argv[3]); pad = atoi(argv[4]); Number_Steps = 1.0e3*(Pulse/Stepsize); phase_Step = 360.0*Stepsize*1.0e-9/(1.0/Offset); fi = fopen("Output.RF","w"); if(pad == 1) { phase = 0.0; fprintf(fi,"%6.1f\t1023.0\t1.0\t0.0\n",phase); fprintf(fi,"%6.1f\t1023.0\t1.0\t0.0\n",phase); } for(i=1;i<=Number_Steps;i++) { phase = (i-1)*phase_Step; while( phase > 360.0 ) phase -= 360.0; while( phase < 0.0 ) phase += 360.0; fprintf(fi,"%6.1f\t1023.0\t1.0\t1.0\n",phase); } if(pad == 1) { phase = (Number_Steps)*phase_Step; while( phase > 360.0 ) phase -= 360.0; while( phase < 0.0 ) phase += 360.0; fprintf(fi,"%6.1f\t1023.0\t1.0\t0.0\n",phase); phase = (Number_Steps + 1.0)*phase_Step; while( phase > 360.0 ) phase -= 360.0; while( phase < 0.0 ) phase += 360.0; fprintf(fi,"%6.1f\t1023.0\t1.0\t0.0\n",phase); } fclose(fi); }