Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 261
Creating and Downloading Waveform Files
Programming Examples
out_stream.open("IQ_data");// create a data file
if (out_stream.fail())
{
cout << "Input file opening failed" << endl;
exit(1);
}
//generate the sample data for I and Q. The I channel will have
a sine
//wave and the Q channel will a cosine wave.
for (int i=0; i<SAMPLES; ++i)
{
iqData[2*i] = AMPLITUDE * sin(two_pi*i/(float)SAMPLES);
iqData[2*i+1] = AMPLITUDE * cos(two_pi*i/(float)SAMPLES);
}
// make sure bytes are in the order MSB(most significant byte)
first. (PC only).
char* cptr = (char*)iqData;// cast the integer values to
characters
for (int i=0; i<(4*SAMPLES); i+=2)// 4*SAMPLES
{
char temp = cptr[i];// swap LSB and MSB bytes
cptr[i]=cptr[i+1];
cptr[i+1]=temp;
}
// now write the buffer to a file
out_stream.write((char*)iqData, 4*SAMPLES);
return 0;
}
Содержание X-Series
Страница 4: ...4 ...
Страница 10: ...10 Contents ...