Waveform and List Format
R&S
®
SGT100A
517
User Manual 1176.8674.02 ─ 07
// SICO.wv
// Generating a binary data set from the I/Q pairs in the file SICO.txt
// and storing the result to file SICO.wv
FILE *fp_sour, *fp_dest;
float i_float, q_float;
unsigned short i_usint, q_usint;
fp_sour = fopen("SICO.TXT", "rt");
if (fp_sour == 0)
return -1;
fp_dest = fopen("SICO.WV", "wb");
if (fp_dest == 0)
{
fclose(fp_sour);
return -1;
}
// Write required tags to waveform file
fprintf(fp_dest, "{TYPE: SMU-WV,0}");
fprintf(fp_dest, "{CLOCK: 10e6}");
fprintf(fp_dest, "{SAMPLES: %d}", samples);
// RMS, Peak
fprintf(fp_dest, "{LEVEL OFFS: %f,%f}", -1.0f * 20.0f * log10(1.0f/sqrt(2.0f)), 0.0f);
fprintf(fp_dest, "{WAVEFORM-%d:#", (samples * 4) + 1);
for (i=0; i<samples; i++)
{
// Read I/Q pair from ASCII file
if (fscanf(fp_sour, "%f %f", &i_float, &q_float) == EOF)
break;
// Convert I/Q pair to unsigned short
i_usint = (unsigned short)floor((i_float * 32767.0) + 0.5);
q_usint = (unsigned short)floor((q_float * 32767.0) + 0.5);
// Write converted I/Q pair to waveform file
fwrite(&i_usint, 2, 1, fp_dest);
fwrite(&q_usint, 2, 1, fp_dest);
}
fprintf(fp_dest, "}");
fclose(fp_dest);
fclose(fp_sour);
return 0;
}
12.3 Editing Waveform Files
You can edit the internally and externally crated waveform files. The waveform con-
tains binary and ASCII data.
Consider the following rules while editing files with binary data.
Editing Waveform Files